Answer the question
In order to leave comments, you need to log in
How to properly define relationships in Django models?
Good day I'm struggling
with the following task:
In the django admin panel, you need to combine two models in such a way as to create an Action independently (the usual creation of a record). After that, it was possible to create a bundle and attach existing Actions to it. Also provide links so that you can find out by query which bundle the current Action has already been attached to.
class Action(models.Model):
id = models.AutoField(primary_key=True)
slug = models.CharField(max_length=TYPE_MAX_LENGTH)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __unicode__(self): return self.slug
class Meta(object):
db_table = 'actions'
class Bundle(models.Model):
name = models.CharField(max_length=TYPE_MAX_LENGTH)
active = models.BooleanField(default=False)
def __unicode__(self): return self.name
class Meta(object):
db_table = 'bundle'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question