Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A(models.Model):
- text = models.TextField(blank=True)
- class B(models.Model):
- a = models.ForeignKey(a, related_name="foo")
- text = models.TextField(blank=True)
- >>> x = A(1)
- >>> y = B(a=x, bar=1)
- >>> x
- <A: A object>
- >>> y
- <B: B object>
- >>> x.__dict__
- {'foo': 0, '_state': <django.db.models.base.ModelState object at 0x3772d10>, 'id': 1}
- >>> y.__dict__
- {'bar': 1, '_a_cache': <A: A object>, '_state':<django.db.models.base.ModelState object at 0x3772d90>, 'id': None, 'a_id': 1}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement