forked from yahyaaly151989/Mastering_Django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
736a110
commit 15e3bbf
Showing
10 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
Binary file modified
BIN
+1.17 KB
(290%)
Module04/bookmarks/account/__pycache__/forms.cpython-311.pyc
Binary file not shown.
Binary file modified
BIN
+84 Bytes
(110%)
Module04/bookmarks/account/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file modified
BIN
+933 Bytes
(260%)
Module04/bookmarks/account/__pycache__/views.cpython-311.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
from django import forms | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class LoginForm(forms.Form): | ||
username = forms.CharField() | ||
password = forms.CharField(widget=forms.PasswordInput) | ||
|
||
|
||
class UserRegistrationForm(forms.ModelForm): | ||
password = forms.CharField(label= 'password', widget=forms.PasswordInput) | ||
password2 = forms.CharField(label= 'Repeat password', widget=forms.PasswordInput) | ||
|
||
class Meta: | ||
model = User | ||
fields = ['username', 'first_name', 'email'] | ||
|
||
def clean_password2(self): | ||
cd = self.cleaned_data | ||
|
||
if cd['password'] != cd['password2']: | ||
raise forms.ValidationError("Passwords don't match.") | ||
return cd['password2'] |
14 changes: 14 additions & 0 deletions
14
Module04/bookmarks/account/templates/account/register.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %} Create an account {% endblock title %} | ||
|
||
{% block content %} | ||
<h1>Create a new account</h1> | ||
<p>Please, sign up using the following form:</p> | ||
|
||
<form method="post"> | ||
{{user_form.as_p}} | ||
{% csrf_token %} | ||
<p><input type="submit" value="Create an account"></p> | ||
</form> | ||
{% endblock content%} |
11 changes: 11 additions & 0 deletions
11
Module04/bookmarks/account/templates/account/register_done.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %} Welcome {% endblock title %} | ||
|
||
{% block content %} | ||
<h1>Welcome {{ new_user.first_name }}</h1> | ||
<p> | ||
Your account has been created successfully. | ||
Now you can <a href="{% url 'login' %}">login</a> | ||
</p> | ||
{% endblock content%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.