Hi all
I have created two classes. Instances of class A are timeless and instances of class B are different each year. Each instance of class B is associated with an instance of class A.
So I suppose I should do something like this
class A(models.Model):
name = models.CharField(max_length=20, default = 'null')
class B(models.Model):
A = models.ForeignKey('A', on_delete=models.CASCADE, related_name = "bs")
Now I need to declare three fields on class A that point to a different instance of class B for current, past and next year
current_B
previous_B
next_B
I cannot find a way to declare such an association. Could you help me?
Thank you
-- I have created two classes. Instances of class A are timeless and instances of class B are different each year. Each instance of class B is associated with an instance of class A.
So I suppose I should do something like this
class A(models.Model):
name = models.CharField(max_length=20, default = 'null')
class B(models.Model):
A = models.ForeignKey('A', on_delete=models.CASCADE, related_name = "bs")
Now I need to declare three fields on class A that point to a different instance of class B for current, past and next year
current_B
previous_B
next_B
I cannot find a way to declare such an association. Could you help me?
Thank you
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/b68beac2-23fd-4775-9f60-b1e414890f10%40googlegroups.com.
No comments:
Post a Comment