Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ole Gabor Husebø
rodtrad
Commits
39982a74
Commit
39982a74
authored
Feb 25, 2020
by
Ole Gabor Husebø
Browse files
Creating User registration page. (not finished)
parent
bcac9f60
Changes
4
Hide whitespace changes
Inline
Side-by-side
rodTraa/Templates/register.html
View file @
39982a74
{% extends 'startbase.html' %}
{% load static %}
{% load crispy_forms_tags %}
{% block body %}
<div
class=
"content-section"
>
<div
style=
"border-radius: 20px ;margin-top: 80px;width: 60%; margin-left: 20%; background-color: white; height:
4
50px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);"
>
<div
style=
"border-radius: 20px ;margin-top: 80px;width: 60%; margin-left: 20%; background-color: white; height:
6
50px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);"
>
<form
method=
"POST"
action=
"{% url 'register' %}"
>
{% csrf_token %}
<div
style=
"margin-left: 4%; margin-top: 10px; margin-right: 4% "
>
<fieldset
class =
"form-group"
>
<legend
class=
"border-bottom mb-4"
>
Join Today
</legend>
{{ form
.as_p
}}
<legend
class=
"border-bottom mb-4"
>
Bli Med I Dag!
</legend>
{{ form
|crispy
}}
</fieldset>
<div
class=
"form-group"
>
<button
class=
"btn btn-outline-info"
type=
"submit"
>
Sign Up
</button>
<button
class=
"btn btn-outline-info"
type=
"submit"
>
Registrer Deg
</button>
</div>
</div>
</form>
...
...
rodTraa/apps/users/forms.py
0 → 100644
View file @
39982a74
from
django
import
forms
from
django.contrib.auth.models
import
User
from
django.contrib.auth.forms
import
UserCreationForm
class
UserRegisterForm
(
UserCreationForm
):
email
=
forms
.
EmailField
()
class
Meta
:
model
=
User
fields
=
[
'username'
,
'email'
,
'password1'
,
'password2'
]
\ No newline at end of file
rodTraa/apps/users/views.py
View file @
39982a74
from
django.shortcuts
import
render
,
redirect
from
django.contrib.auth.forms
import
UserCreationForm
from
django.contrib
import
messages
from
.forms
import
UserRegisterForm
def
register
(
request
):
if
request
.
method
==
'POST'
:
form
=
User
Creation
Form
(
request
.
POST
)
form
=
User
Register
Form
(
request
.
POST
)
if
form
.
is_valid
():
username
=
form
.
cleaned_data
.
get
(
'username'
)
messages
.
success
(
request
,
f
'Account created for
{
username
}
!'
)
form
.
save
()
return
redirect
(
'startpage/'
)
else
:
form
=
User
Creation
Form
()
form
=
User
Register
Form
()
return
render
(
request
,
'register.html'
,
{
'form'
:
form
})
\ No newline at end of file
rodTraa/rodTraa/settings.py
View file @
39982a74
...
...
@@ -41,6 +41,7 @@ INSTALLED_APPS = [
'apps.staticpages'
,
'apps.feed'
,
'apps.users.apps.UsersConfig'
,
'crispy_forms'
,
]
MIDDLEWARE
=
[
...
...
@@ -124,6 +125,8 @@ USE_TZ = True
STATIC_URL
=
'/static/'
CRISPY_TEMPLATE_PACK
=
'bootstrap4'
STATICFILES_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'static'
)
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment