class Cashbox(models.Model):
cashier = models.OneToOneField('User', null=True, blank=True, related_name='cashbox', on_delete=models.SET_NULL)
User.object.get(pk=1)
user.cashbox = None
AttributeError: 'NoneType' object has no attribute 'cashier_id'
c1 = Cashbox.objects.get(pk=user.cashbox.id)
c1.cashier = None
c1.save()
c2 = Cashbox.object.get(pk=10)
c2.cashier = user
c2.save()
--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9bac63fa-64e3-4353-82ae-6b31fa8f281f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.