Piyush
Can you tell me what can be wrong.
V
Nerd
in the first place it
username = “”
password = “”
# the above credentials should be correct
user = authenticate(username=username, password=password)
Piyush
I have username and password in response.session which I am retrieving and inserting into data base first and then logging.
Nerd
That the issue
print the username and password you are retrieving and see if it a correct credentials
Piyush
I have printed all details before logging and all info. is all correct.
Nerd
Okay try
Get the user using
user = User.objects.get(username=username)
then check the password
print(user.check_password(password))
Piyush
Ok.
أصل الدين مُوَحِّدٌ
Hello dears, I have this problem, how can I find a solution
أصل الدين مُوَحِّدٌ
.....\Desktop\backend - Copy> pip install gunicorn django-heroku
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip install gunicorn django-heroku
+ ~~~
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Nerd
أصل الدين مُوَحِّدٌ
Yes Python installed But Pip don't work . What could be reason
أصل الدين مُوَحِّدٌ
Nerd
Nerd
Check if it exists
أصل الدين مُوَحِّدٌ
It not in the environment variable path
(env) PS C:\Users\517-2005 Asliddin\Desktop\backend - Copy> pip install django
Fatal error in launcher: Unable to create process using '"C:\Users\Windows 10\Desktop\well(last)\env\Scripts\python.exe" "C:\Users\517-2005 Asliddin\Desktop\backend - Copy\env\Scripts\pip.exe" install django': The system cannot find the file specified.
Piyush
And it is not working no att. Name objects.
Nerd
Nerd
Nerd
Piyush
Every thing is working fine such name of user password but not that user.objects.get()
Nerd
So what does
User.objects.get() return?
Does it return an error?
أصل الدين مُوَحِّدٌ
Nerd
No Bro everything is correct
If it was correct pip would show the issue is
It not finding the command since it not in the global variables
Piyush
User.objects.get :-no attribute name objects it is not returning anything.
Nerd
Okay that the reason,
Add this to your user model
Is it a custom user model? If yes add this
objects = models.Manager()
Piyush
No I only have one custome mode named SignIn which has name,gmail and password field.
Nerd
So from where are you importing the User model?
S
Hai how can I left join 2 table in django
S
Please help me
Piyush
Django.contib.auth import authenticate
Doragonsureiyā
Nerd
S
S
But result is not get what I need
Piyush
This is wrong
So how can I create a session so that of the user registers him self he mist remain loged in until he logs out himself.
Nerd
Piyush
S
What do you need
2 table employee and resignation. in resignation employee forienkey is there. I need a list of all employees with if resignation record there join based on some conditions is_active=true
S
When I tried prefech related and I print the query .it gives the INNER JOIN.
Nerd
You can do
employees = resignation.objects.filter(employee__is_active = true).values(“employee__name”, ….)
S
It gives the list of employees with only record in resignation table
S
In my db total 124 employee 36 are terminated
S
I need 124 employee details with resignation details
Nerd
Oh okay so you want to combine each employees to their resignation details
S
Yes if there combine else null value needed
Nerd
select_related should work
Nerd
Like
class Employees(models.Model):
pass
class resignationDetails(model.Model):
a = models.ForiegnKey(Employees…)
resignationDetails.objects.select_related(“a”)
Nerd
Better still use a forward filter does
resignationDetails.objects.filter(a__is_active = True).values(“a__name”)
Nerd
So you can filter and use the double underscores to retrieve the details of the model
Piyush
It should be
from django.contrib.auth.models import User
Ok so I have imported this User module and applied it like this,User=authenticate(username=num,password =passwo)
User1=User.objects.get(username=num)
Print(user1.checkpassword(passw)).
And same error no att. Name objects.
Nerd
Piyush
Nerd
Yes so then it means as I already said the credentials is wrong
run this let me see
users = User.objects.all()
Nerd
print(users)
Piyush
Ok.
Piyush
It is printing my name. And I think so it is admin.
Piyush
It is not displaying data from my user defined model SignIn.
Teguh
patleaf.js:1 Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
at https://www.paypalobjects.com/pa/3pjs/tl/6.2.0/patleaf.js:1:57765
at _init (https://www.paypalobjects.com/pa/3pjs/tl/6.2.0/patleaf.js:1:57970)
at timeoutCallback (https://www.paypalobjects.com/pa/3pjs/tl/6.2.0/patleaf.js:1:34487)
please help
Nerd
Okay
Now run this
users = User.objects.all().values(“username”
print(users) # all users
print(username) # username being searched
So check if the username is in the users
Nerd
Doragonsureiyā
Nerd
Piyush
Nerd
what is the username you want to sign in with?
Piyush
The one which i have stored in response.session i.e user name after registration.
Nerd
Piyush
I AM REALLY confused will this user show me data from my created model or admin.
Piyush
I can try it first.
Nerd
am just saying that your credentials is wrong
Piyush
How can I create a session that after registration the user remain logging even after he closes his browser.