Answer the question
In order to leave comments, you need to log in
How to properly organize ForeignKey relationships?
good time
there is a model
class user_alliance(models.Model):
al_leader = models.OneToOneField(User,on_delete=models.CASCADE,related_name='alliance_leader') # Кому принадлежит клан
al_member = models.ForeignKey(User,on_delete=models.CASCADE) # Участники
al_name = models.CharField(default='Альянс',max_length=48)
al_level = models.IntegerField(default=1)
def __str__(self):
return self.al_name
Answer the question
In order to leave comments, you need to log in
first, pep8 and Django rules
class Alliance(models.Model):
leader = ...
member = ...
name = ...
level = ...
class Alliance(models.Model):
...
members = models.ManyToManyField(User)
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question