Python Forum

Full Version: Django - Am I in the right direction for creating the models of my Phone Review appli
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am a beginner in Django. I am building a data model for a Django app, named PhoneReview. It will store reviews related to the latest mobile phone. It's table should include:
a. Brand – details on brand, such as, name, origin, manufacturing since, etc

b. Model – details on model, such as, model name, launch date, platform, etc

c. Review – review article on the mobile phone and date published, etc

d. Many-to-many relationship between Review and Model.

Here are my codes in models.py:
from django.db import models
from django.template.defaultfilters import slugify

# Create your models here.
class Brand(models.Model):
    brandName = models.CharField(max_length=100)
    origin = models.CharField(max_length=100)
    manufacturingSince = models.CharField(max_length=50, default='null')
    def __str__(self):
        return self.brandName

class PhoneModel(models.Model):
    modelName = models.CharField(max_length=100)
    launchDate = models.CharField(max_length=100)
    platform = models.CharField(max_length=100)
    def __str__(self):
        return self.modelName

class Review(models.Model):
    model_name_many_to_many = models.ManyToManyField(PhoneModel)
    reviewArticle = models.CharField(max_length=1000)
    datePublished = models.DateField(auto_now=True)
    slug = models.SlugField(max_length=150, default='null')
    def __str__(self):
        return self.reviewArticle
Are my codes correct? Am I in the right direction?