Commit b1b9220f authored by Ole Gabor Husebø's avatar Ole Gabor Husebø
Browse files

Creating User registration page. (not finished)

parent 874518a1
...@@ -52,7 +52,15 @@ ...@@ -52,7 +52,15 @@
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="col-md-8">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{message.tags}}">
{{ message }}
</div>
{% endfor %}
{% endif %}
</div>
{% block body %} {% block body %}
{% endblock body %} {% endblock body %}
......
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
<p style="font-size:150%; position: absolute; margin-left:10%; margin-top: 5%"><br><br> Registrer ny bruker <br> eller logg inn for å se <br> utfordringer og innhold <br> fra andre brukere </p> <p style="font-size:150%; position: absolute; margin-left:10%; margin-top: 5%"><br><br> Registrer ny bruker <br> eller logg inn for å se <br> utfordringer og innhold <br> fra andre brukere </p>
<img src="{% static 'img/profil.png' %}" alt="" style=" width: 38%; margin-left: 45%; margin-top: 12%; transform: translateY(-50%) rotate(-10deg);"> <img src="{% static 'img/profil.png' %}" alt="" style=" width: 38%; margin-left: 45%; margin-top: 12%; transform: translateY(-50%) rotate(-10deg);">
</div> </div>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'startbase.html' %}
{% load static %}
{% block body %}
<div class="content-section">
<form method="POST">
{% csrf_token %}
<fieldset="form-group>
<legend class="border-bottom mb-4">Join Today</legend>
{{ form.as_p }}
</fieldset>
<div class="form-group">
<button class="btn btn-outline-info" type="submit">Sign Up</button>
</div>
</form>
<div class="border-top pt-3">
<small class="text-muted">
Allready have an account? <a class="ml-2" href="#">Sign In</a>
</small>
</div>
</div>
{% endblock %}
from django.shortcuts import render from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib import messages
# Create your views here. def register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
username = form.cleaned_data.get('username')
messages.success(request, f'Account created for {username}!')
#return redirect('startpage/')
else:
form = UserCreationForm()
return render(request, 'register.html', {'form': form})
\ No newline at end of file
...@@ -37,9 +37,10 @@ INSTALLED_APPS = [ ...@@ -37,9 +37,10 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'apps.users', #'apps.users',
'apps.staticpages', 'apps.staticpages',
'apps.feed', 'apps.feed',
'apps.users.apps.UsersConfig',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -20,10 +20,12 @@ from . import settings ...@@ -20,10 +20,12 @@ from . import settings
from apps.staticpages.views import index from apps.staticpages.views import index
from apps.staticpages.views import startpage from apps.staticpages.views import startpage
from apps.staticpages.views import myprofile from apps.staticpages.views import myprofile
from apps.users import views as user_views
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('register', user_views.register, name='register'),
path('', index), path('', index),
path('startpage/', startpage), path('startpage/', startpage),
path('myprofile/<int:pk>/', myprofile), path('myprofile/<int:pk>/', myprofile),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment