I have built a real estate management system with Django. I want to know if my design database was wrong. Please let me know how to improve it.
Should I make the models use more than two tables (classes)?
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
name = models.CharField(max_length=50)
image = models.ImageField(upload_to='profiles', default='logo.png')
phone = models.CharField(max_length=11, default='')
bio = models.CharField(max_length=100, default='')
city = models.CharField(max_length=20, default='erbil')
location = models.CharField(max_length=40, default='')
date = models.DateTimeField(default=datetime.now)
active = models.BooleanField(default=False)
def __str__(self):
return f'{self.user}'
class Listing(models.Model):
objects = ListingManager()
company = models.ForeignKey(User, on_delete=models.CASCADE )
title = models.CharField(max_length=200)
slug = models.SlugField(unique=True, default='', blank=True)
address = models.CharField(max_length=200)
city = models.CharField(max_length=100, choices=city_choices, default='lodon')
estate_type = models.CharField(max_length=20, choices=estate_choices, default=house)
description = models.TextField(blank=True)
rent_sale = models.CharField(max_length=20, choices=rent_sale_choice, default=sale)
price = models.IntegerField()
bedrooms = models.IntegerField(default=0)
bathrooms = models.DecimalField(max_digits=2, decimal_places=1)
garage = models.IntegerField(default=0)
sqft = models.IntegerField()
sold = models.BooleanField(default=False)
sold_time = models.DateTimeField(default=datetime.now,blank=True)
photo_main = models.ImageField(upload_to='listings_main')
photo_1 = models.ImageField(upload_to='listings_1', blank=True)
photo_2 = models.ImageField(upload_to='listings_1', blank=True)
photo_3 = models.ImageField(upload_to='listings_1', blank=True)
photo_4 = models.ImageField(upload_to='listings_1', blank=True)
photo_5 = models.ImageField(upload_to='listings_1', blank=True)
photo_6 = models.ImageField(upload_to='listings_1', blank=True)
is_published = models.BooleanField(default=True)
list_date = models.DateTimeField(default=datetime.now, blank=True)
unless = models.CharField(default='', max_length=20)