is this example of model object property usage unique to a logged-in session in django?

Django creates a new instance of the model when you retrieve a concrete object of the query.

You can be pretty confident that temporary variables will be only in that object

You can check it:

In [13]: from django.contrib.auth.models import User

In [14]: users = User.objects.all()

In [15]: u = users.first()

In [16]: u
Out[16]: <User: super>

In [17]: u.tmp = 123

In [18]: u.tmp
Out[18]: 123

In [19]: u2 = users.first()

In [20]: u2.tmp
AttributeError                            Traceback (most recent call last)
<ipython-input-20-f4c979d08460> in <module>
----> 1 u2.tmp

AttributeError: 'User' object has no attribute 'tmp'

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top