Last active
October 22, 2016 07:05
-
-
Save codeboy101/a4c4ba8c42f9cddeace9a4862f3fd3dd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # frontPage view at last | |
| def login(request): | |
| form = LoginForm() | |
| if request.method == "POST": | |
| form = LoginForm(request.POST) | |
| if form.is_valid(): | |
| input_username = form.cleaned_data["username"] | |
| input_pass = form.cleaned_data["password"] | |
| try: | |
| user = authenticate(username=input_username,password=input_pass) | |
| if user is not None: | |
| login(user) | |
| return redirect("frontPage") | |
| return redirect("register") | |
| except AttributeError as e: | |
| print(e) | |
| return render(request,"story/errLogin.html",{"error":str(e)}) | |
| return render(request,"story/create_login.html",{"loginForm":form}) | |
| def frontPage(request): | |
| print(request.user) | |
| username = "guest" | |
| if request.user.is_authenticated(): | |
| username = request.user | |
| posts = Story.objects.order_by('title') | |
| return render(request,"story/frontPage.html",{'posts':posts,"username":username}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment