from django.shortcuts import render, redirect
from .models import Users
from django.contrib import messages

def index(request):
    return render(request,'reg/index.html')

def register(request):
    if request.method=="POST":
        #if the fields pass the vaildation the  object will be created in the database
        if Users.objects.registration(request):
            context={
                'name':request.POST['first_name'],
                'action': "registered"
            }
            messages.success(request,'Successfully registered')
            return render(request,'reg/show.html', context)
        else:
            return redirect('/')
    else:
        return redirect('/')

def login(request):

    if request.method=="POST":
        login=Users.objects.login(request)
        if login==False:
            return redirect('/')
        else:
            context={
                'name': login.first_name,
                'action': "logged in"
            }
            messages.success(request,'Successfully logged in')
            return render(request,'reg/show.html', context)

    else:
        return redirect('/')

0baad52eb48eaaad6f4f7e850d2930c625cc85b8
<mask token>


def login(request):
    if request.method == 'POST':
        login = Users.objects.login(request)
        if login == False:
            return redirect('/')
        else:
            context = {'name': login.first_name, 'action': 'logged in'}
            messages.success(request, 'Successfully logged in')
            return render(request, 'reg/show.html', context)
    else:
        return redirect('/')

<mask token>


def register(request):
    if request.method == 'POST':
        if Users.objects.registration(request):
            context = {'name': request.POST['first_name'], 'action':
                'registered'}
            messages.success(request, 'Successfully registered')
            return render(request, 'reg/show.html', context)
        else:
            return redirect('/')
    else:
        return redirect('/')


def login(request):
    if request.method == 'POST':
        login = Users.objects.login(request)
        if login == False:
            return redirect('/')
        else:
            context = {'name': login.first_name, 'action': 'logged in'}
            messages.success(request, 'Successfully logged in')
            return render(request, 'reg/show.html', context)
    else:
        return redirect('/')

<mask token>


def index(request):
    return render(request, 'reg/index.html')


def register(request):
    if request.method == 'POST':
        if Users.objects.registration(request):
            context = {'name': request.POST['first_name'], 'action':
                'registered'}
            messages.success(request, 'Successfully registered')
            return render(request, 'reg/show.html', context)
        else:
            return redirect('/')
    else:
        return redirect('/')


def login(request):
    if request.method == 'POST':
        login = Users.objects.login(request)
        if login == False:
            return redirect('/')
        else:
            context = {'name': login.first_name, 'action': 'logged in'}
            messages.success(request, 'Successfully logged in')
            return render(request, 'reg/show.html', context)
    else:
        return redirect('/')

from django.shortcuts import render, redirect
from .models import Users
from django.contrib import messages


def index(request):
    return render(request, 'reg/index.html')


def register(request):
    if request.method == 'POST':
        if Users.objects.registration(request):
            context = {'name': request.POST['first_name'], 'action':
                'registered'}
            messages.success(request, 'Successfully registered')
            return render(request, 'reg/show.html', context)
        else:
            return redirect('/')
    else:
        return redirect('/')


def login(request):
    if request.method == 'POST':
        login = Users.objects.login(request)
        if login == False:
            return redirect('/')
        else:
            context = {'name': login.first_name, 'action': 'logged in'}
            messages.success(request, 'Successfully logged in')
            return render(request, 'reg/show.html', context)
    else:
        return redirect('/')

from django.shortcuts import render, redirect
from .models import Users
from django.contrib import messages

def index(request):
    return render(request,'reg/index.html')

def register(request):
    if request.method=="POST":
        #if the fields pass the vaildation the  object will be created in the database
        if Users.objects.registration(request):
            context={
                'name':request.POST['first_name'],
                'action': "registered"
            }
            messages.success(request,'Successfully registered')
            return render(request,'reg/show.html', context)
        else:
            return redirect('/')
    else:
        return redirect('/')

def login(request):

    if request.method=="POST":
        login=Users.objects.login(request)
        if login==False:
            return redirect('/')
        else:
            context={
                'name': login.first_name,
                'action': "logged in"
            }
            messages.success(request,'Successfully logged in')
            return render(request,'reg/show.html', context)

    else:
        return redirect('/')
