Wednesday, February 24, 2021

Re: Problem with view

I changed the classes name and works!
Thank you


Maurizio


Il 25/02/2021 01:09, Kasper Laudrup ha scritto:
> On 24/02/2021 21.00, Maurizio Faccin wrote:
>>
>> Hello,
>> I'am a newbie in usign django and django rest.
>> I have a problem with a modelsetview
>> The message error is:
>>
>> Exception Type:     AttributeError
>> Exception Value:
>>
>> type object 'Fatture' has no attribute 'objects'
>>
>
> You have two classes called Fatture. In your models file and your
> views file. The Python interpreter needs to figure out which one of
> them to use.
>
> When you call the objects method on the Fatture class it is using the
> class inheriting from models.Model but the tries to find the objects
> attribute as a static member in the same class where you're making the
> call.
>
> You could either make it explicit which class to use by prefixing the
> call like *fattura.models.Fatture* but a better solution is probably
> to rename the classes to FattureModel and FattureView. That would also
> follow the naming patter from calling your serializer class
> FatturaSerializer.
>
> 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/fd4fa7e8-90eb-f02d-6472-e3cf077c2409%40tiscali.it.

No comments:

Post a Comment