[Fixed]-Strange AttributeError in django

1👍

le_dict is initialised as a queryset because of the use of the ‘filter’ function. I.e. it is not a single object instance.

Therefore, it does not make sense to reference the ‘lease’ attribute as a queryset of many LeaseExtra instances may have been returned.

If you want to reference ‘lease’ of a specific model instance, you can do:

le_dict = LeaseExtra.objects.get(pk=some_id)

The get() method requires that you use a unique identifier such as a primary key to perform your query.

👤zubhav

Leave a comment