48:52 note that he added `error_message = None` to account for the UnboundLocalError that would arise when trying to run views.login_view. It's a pretty easy fix since it just deals with variable scope/locality, but it still should have been mentioned in the video.
First of all thanks for your great efforts delivering this course, waiting for other courses and thanks for the NetNinja to support other Devs. At the beginning of this video you said that this is the last chapter of this course, but at the first part of this tutorial you said that at the end you will build an "Inventory Management System", so are there upcoming videos or this is really the last chapter?
@@SamuelSibarani-nf9vx # Fixed login_view Function: def login_view(request): error_message = None #---------------------------------------- If the request method is not "POST", error_message is not defined, So Define it as we do here. if request.method == "POST": username = request.POST.get("username") password = request.POST.get("password") user = authenticate(request, username=username, password=password) if user is not None: login(request, user) next_url = request.POST.get('next') or request.GET.get('next') or 'home' return redirect(next_url) else: error_message = "Invalid Credentials" context = {'error': error_message} return render(request, 'accounts/login.html', context )
"The view ____ didn't return an HttpResponse object. It returned None instead." If you are getting this error and your code is exactly the same as the code in the video, you may check your browser's login autofill. It may be trying to autofill and submit the login form with an invalid login that you previously saved in the admin dashboard lecture.
i was following up the tutorial and overall until this video everyting was fine. But this one is a bit confusing things are done differenlty especialy with routing and classes
This was the best Django course I found on RUclips that was quick and easy to understand. Thanks a lot! :)
Happy to hear that! :)
@@NetNinja can you tell me why logout.html template is not rendering
@@weeb650 cuz there is no rendering in logout_view func, you have to add it yourself
48:52 note that he added `error_message = None` to account for the UnboundLocalError that would arise when trying to run views.login_view. It's a pretty easy fix since it just deals with variable scope/locality, but it still should have been mentioned in the video.
can you tell me why logout.html template is not rendering
thanks man
really helped to through django , the sessions were informative and i was even able to make written notes put of it
First of all thanks for your great efforts delivering this course, waiting for other courses and thanks for the NetNinja to support other Devs. At the beginning of this video you said that this is the last chapter of this course, but at the first part of this tutorial you said that at the end you will build an "Inventory Management System", so are there upcoming videos or this is really the last chapter?
Sire! You are awesome. THANK YOU!
@NetNinja can you make a tutorial on OOP in Typescript/React 🙏🏽🥺
....and .NET 6😁
Thank you❤️🙌🏽🌹
error_message = None
Pls note this, guys. Thi sis in login_view
49:14
there is error in your code and you don't show the video to fix it, I let AI help me to fix it
what kind of error, importing the views?
@@SamuelSibarani-nf9vx
# Fixed login_view Function:
def login_view(request):
error_message = None #---------------------------------------- If the request method is not "POST", error_message is not defined, So Define it as we do here.
if request.method == "POST":
username = request.POST.get("username")
password = request.POST.get("password")
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
next_url = request.POST.get('next') or request.GET.get('next') or 'home'
return redirect(next_url)
else:
error_message = "Invalid Credentials"
context = {'error': error_message}
return render(request, 'accounts/login.html', context )
also, login.html body should look like this:
Login
{% csrf_token %}
{% comment %} hidden input {% endcomment %}
Username
Password
Login
{% if error %}
{{ error }}
{% endif %}
Don't have an account? Register Here
#-------------------------------------#
And the styles.css should look like this:
body{
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
justify-content: center;
align-content: center;
display: grid;
height: 100vh;
}
.container{
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2{
margin-bottom: 20px;
}
.form-group{
margin-bottom: 15px;
}
label{
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
button{
background: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 6px;
}
button:hover{
color: red;
margin-top: 10px;
}
.error{
color: red;
margin-top: 10px;
}
@54:14 Did anyone understand this very interesting part? 😵
pls also do DRF.
"The view ____ didn't return an HttpResponse object. It returned None instead."
If you are getting this error and your code is exactly the same as the code in the video, you may check your browser's login autofill. It may be trying to autofill and submit the login form with an invalid login that you previously saved in the admin dashboard lecture.
Tq bro 🙏
This one was really confusing, I think fully creating the register page first would be easier to understand
Django-Ninja Plz :)
i was following up the tutorial and overall until this video everyting was fine. But this one is a bit confusing things are done differenlty especialy with routing and classes
Only apiece 😊😊😊