Re: Problems in Django login authentication

2023-07-29 Thread Mohammad Ehsan Ansari
First extend abstract user model or abstract base user model in your user model and after that define auth.model in settings.py hope its workSent from my iPhoneOn 30-Jul-2023, at 10:45 AM, Abdulrahman Abbas  wrote:Can you login with superuser?On Sun, Jul 30, 2023, 02:32 Mh Limon  wrote:Views.py file from django.shortcuts import render,HttpResponse,redirectfrom .models import registrationfrom django.contrib.auth import authenticate,logindef home(request):    return render(request,'home.html')def log_in(request):    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)            return redirect('home')        else:            return HttpResponse("You have incorrect Username or password")    return render(request, 'log_in.html')def sign_up(request):    if request.method == 'POST':        name = request.POST.get('fullname')        username = request.POST.get('username')        email = request.POST.get('email')        pass1 = request.POST.get('password')        pass2 = request.POST.get('confirm_password')        if pass1 != pass2:            return HttpResponse("Password not matched")        else:            db = registration()            db.Name = name            db.username = username            db.Email = email            db.Password = pass1            db.save()            return redirect('log_in')    return render(request,'sign_up.html')This is models.py for sqlite database:
from django.db import modelsclass registration(models.Model):    Name = models.CharField(max_length=100)    username = models.CharField(max_length=100)    Email = models.CharField(max_length=100)    Password = models.CharField(max_length=100)when providing the correct username and password, the system consistently displays an error message stating "You have incorrect Username or password."please help me to solve this error.




-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4003937f-9045-4cea-bd6c-b071d7b1a6c3n%40googlegroups.com.




-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGGqo0MMu55nqSSKhW2%2BjGgGCGf62JJoBuCZA2wgK3NONCxzCg%40mail.gmail.com.




-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/BF995111-54EC-4CD1-A3E8-FE4F35AE49B1%40gmail.com.


Re: Django call_command from Admin

2022-10-21 Thread Mohammad Ehsan Ansari
Please refer the signal concept in django you will get how to implement it

On Thu, 20 Oct, 2022, 9:36 pm Aziz Mek,  wrote:

> Hi All,
>
> I was wondering  if you have come across the following:
>
> I have a field in the model that's empty, when the user fills it up and
> clicks Save, it
> should trigger/call a management Command (This command is already build
> that sends emails ), Django docs say i can use call_command but not sure
> how to implement it with the save
>
> I am just after the trigger really when the save takes place
>
> Many thanks in advance
>
> Kind regards
> Aziz
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a0ca69f0-6065-4b86-a977-cfb6dcab8fd7n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF8ux6Li0BjKS2zvQuPWL6zq-R6Buo9wa1fBx68m4ESpTptHug%40mail.gmail.com.


Re: Not avle to login with google in my website

2022-09-25 Thread Mohammad Ehsan Ansari
Add into allowed origin

On Fri, 23 Sep, 2022, 7:20 pm Rajesh Kumar,  wrote:

> Hi All,
> I have integrated the social_django package for social logins like google
> and Fb ...etc.
> But It's working in localhost fine but after deployed in AWS ec2 with
> docker It's not working
> Authorization Error coming: redirect_uri https://0.0.0.0:8000/. but
> it should redirect to HTTPS://{my_domain}/
>
> If anybody can help with that It would be very helpful for me.
> Thanks in advance
>
> Rajesh Kumar
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKNDe%3D%3DQTdff8ZzOiHN6wdqcOH1L%3DXU7iE5%2BQj3Dht4o1gNktA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF8ux6LKQ_XxCZYq58cPRGPwFB89MuhtBr8-_r%3D_-fC-D14bmw%40mail.gmail.com.


Re: DRF and React - request.user is "Anonymous user"

2022-09-19 Thread Mohammad Ehsan Ansari
yes you need

On Tue, 20 Sept 2022 at 09:49, Jackson Patrick 
wrote:

> Do i need to pass token in headers?
>
> On Tue, 20 Sep, 2022, 9:44 am Mohammad Ehsan Ansari, 
> wrote:
>
>> make sure you have listed auth as jwt and added permission class for
>> authentication
>>
>> On Monday, 12 September 2022 at 09:52:22 UTC+5:30 jacks...@gmail.com
>> wrote:
>>
>>> I have used simple JWT for authentication and i have successfully logged
>>> in and am getting tokens also. But when i do a request.user in backend i
>>> get "Annonymous user".
>>> Tried passing Authorization header in axios post in FE REACT but it
>>> throws error. Am setting both refresh and access in a state variable and
>>> store it in local storage . Am really new into this and I'm totally stuck
>>> here.
>>>
>>> All i did was to temporarily solve the issue is to send the user id from
>>> frontend to backend and by the way it's a bad practice.
>>>
>>> So please help me out in this guys.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/1f69ceeb-7294-4d51-a25c-b1a222c534d0n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/1f69ceeb-7294-4d51-a25c-b1a222c534d0n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAG2dbb0KZ79AbF35cuyq9Rk%2BkC1v8-YwCJeQN5xFrwvG%3DgSnNw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAG2dbb0KZ79AbF35cuyq9Rk%2BkC1v8-YwCJeQN5xFrwvG%3DgSnNw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF8ux6LhGJ8C3d59r%3DzV_5159hwRkZsFRjiGzU6Vq7mknjEfUg%40mail.gmail.com.


Re: DRF and React - request.user is "Anonymous user"

2022-09-19 Thread Mohammad Ehsan Ansari
make sure you have listed auth as jwt and added permission class for 
authentication 

On Monday, 12 September 2022 at 09:52:22 UTC+5:30 jacks...@gmail.com wrote:

> I have used simple JWT for authentication and i have successfully logged 
> in and am getting tokens also. But when i do a request.user in backend i 
> get "Annonymous user".
> Tried passing Authorization header in axios post in FE REACT but it throws 
> error. Am setting both refresh and access in a state variable and store it 
> in local storage . Am really new into this and I'm totally stuck here.
>
> All i did was to temporarily solve the issue is to send the user id from 
> frontend to backend and by the way it's a bad practice.
>
> So please help me out in this guys.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1f69ceeb-7294-4d51-a25c-b1a222c534d0n%40googlegroups.com.


Re: session id attribute error

2022-09-19 Thread Mohammad Ehsan Ansari
Hi SessionStore is a model class? if yes you can use pk instant of id


On Monday, 19 September 2022 at 22:48:02 UTC+5:30 aashishk...@gmail.com 
wrote:

> Do this 
>
> request.session.get(‘id’)
>
> On Mon, 19 Sep 2022 at 1:30 PM, shiva singh  wrote:
>
>> hello everyone please help me how can solve this problem:-[image: 
>> image.jpeg]  
>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f1b3116a-a14a-45fb-84d0-c4f95a05fdf0n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f80105fe-94e0-4ae8-a2b4-d8173a2c608an%40googlegroups.com.