Monday, April 27, 2020

Re: AttributeError: type object 'User' has no attribute 'objects'

i got answer

i was doing this:
from .models import User
user = User.objects.filter(pk=user_id)

instead i do this:
from .models import MyUser
user =  MyUser.objects.filter(pk=user_id)


error gone




On Mon, Apr 27, 2020 at 6:57 AM Kasper Laudrup <laudrup@stacktrace.dk> wrote:
Hi Sagar,

On 27/04/2020 14.25, sagar ninave wrote:
> i am getting this error
>

It's hard to guess since you don't show where your User class comes
from, but it doesn't seem like its inheriting from the Django model class.

The error message is quite clear. Look at your User model.

Btw. just a hint: please try to "return early". It is quite difficult to
see which else branches are connected to which if statements in the code
following the one throwing the exception.

Kind regards,

Kasper Laudrup

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/96eba188-98e9-4284-cbab-a3aa3c909c05%40stacktrace.dk.


--

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA6pdZ818Ju8uHr%3DdDayJr3NKwE%2B%2BJ%2BQQZk1iOHqG1EL4yjO1g%40mail.gmail.com.

No comments:

Post a Comment