Answer the question
In order to leave comments, you need to log in
How to automatically create a model in Django?
For example, I have two models
#Room apps
class Room(models.Model):
name_room = models.CharField(max_length=20)
def __str__(self):
return self.name_room
#Furniture apps
class Furniture(models.Model):
name_furniture = models.CharField(max_length=20)
about_furniture = models.TextField(max_length=156)
image_furniture = models.ImageField(upload_to='room_media')
def __str__(self):
return self.name_furniture
Answer the question
In order to leave comments, you need to log in
room = models.ForeignKey(Room, on_delete=models.CASCADE)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question