diff --git a/catalog/templates/base_generic.html b/catalog/templates/base_generic.html
index df7eab42..f1109c9f 100644
--- a/catalog/templates/base_generic.html
+++ b/catalog/templates/base_generic.html
@@ -38,6 +38,7 @@
{% else %}
Login
+ Register
{% endif %}
diff --git a/locallibrary/forms.py b/locallibrary/forms.py
new file mode 100644
index 00000000..6817089b
--- /dev/null
+++ b/locallibrary/forms.py
@@ -0,0 +1,11 @@
+from django.contrib.auth.forms import BaseUserCreationForm
+from django import forms
+from django.contrib.auth.models import User
+
+class PasswordUserCreationForm(BaseUserCreationForm):
+ """Form for signing on a new user with an email address"""
+ email = forms.EmailField(label='email',required=True)
+
+ class Meta:
+ model = User
+ fields = ('username', 'email', 'password1', 'password2')
\ No newline at end of file
diff --git a/locallibrary/urls.py b/locallibrary/urls.py
index 1dd9547f..b5ba2233 100644
--- a/locallibrary/urls.py
+++ b/locallibrary/urls.py
@@ -35,7 +35,6 @@
from django.conf import settings
from django.conf.urls.static import static
-
urlpatterns+= static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
@@ -45,9 +44,10 @@
path('', RedirectView.as_view(url='/catalog/', permanent=True)),
]
-
+from . import views
# Add Django site authentication urls (for login, logout, password management)
urlpatterns += [
path('accounts/', include('django.contrib.auth.urls')),
+ path('register/', views.register_user, name='register'),
]
diff --git a/locallibrary/views.py b/locallibrary/views.py
new file mode 100644
index 00000000..d235a1be
--- /dev/null
+++ b/locallibrary/views.py
@@ -0,0 +1,18 @@
+
+from django.shortcuts import render, redirect
+from locallibrary.forms import PasswordUserCreationForm
+from django.contrib.auth import login
+
+
+def register_user(request):
+ if request.method != 'POST':
+ form = PasswordUserCreationForm()
+ else:
+ form = PasswordUserCreationForm(request.POST)
+ if form.is_valid():
+ user = form.save()
+ login(request, user)
+ return redirect('index')
+
+ context = {'form': form}
+ return render(request, 'registration/register_user.html', context)
diff --git a/templates/registration/register_user.html b/templates/registration/register_user.html
new file mode 100644
index 00000000..7cd5ca2b
--- /dev/null
+++ b/templates/registration/register_user.html
@@ -0,0 +1,11 @@
+{% extends "base_generic.html" %}
+
+{% block content %}
+
+
+
+{% endblock %}