Skip to content

Commit

Permalink
views.py of users
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin-Tony committed Apr 11, 2021
1 parent 4e29ed1 commit 2adb643
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions users/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#from django.shortcuts import render

from django.shortcuts import render,redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib import messages
from django.contrib.auth.decorators import login_required


# Create your views here.


@login_required
def register(request):
if request.user.username!='admin':
return redirect('not-authorised')
if request.method=='POST':
form=UserCreationForm(request.POST)
if form.is_valid():
form.save() ###add user to database
messages.success(request, f'Registered successfully!')
return redirect('dashboard')
else:
form=UserCreationForm()
return render(request,'users/register.html', {'form' : form})



0 comments on commit 2adb643

Please sign in to comment.