Python Forum
Django - Am I in the right direction for creating the models of my Phone Review appli
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django - Am I in the right direction for creating the models of my Phone Review appli
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Accessing a data-phone tag from an href KatMac 1 2,886 Apr-27-2021, 06:18 PM
Last Post: buran
Photo After using models.Model on my class Im getting 'ImproperlyConfigured' error Django khavro 1 2,176 Apr-05-2021, 03:11 PM
Last Post: SheeppOSU
  creating an exe file for a python django project Sanjish 0 2,615 Dec-27-2020, 07:33 AM
Last Post: Sanjish
  Instagram Phone Emulation kristianpython 0 2,007 May-19-2020, 11:54 AM
Last Post: kristianpython
  looking for direction - scrappy, crawler, beautiful soup Sly_Corn 2 2,447 Mar-17-2020, 03:17 PM
Last Post: Sly_Corn
  Posting html values to views/models in Django Malt 1 2,157 Sep-04-2019, 01:44 PM
Last Post: fishhook
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,309 Jun-30-2019, 12:21 AM
Last Post: scidam
  Creating few models with one submit depending on the selected items from multiselect? dmytruk 0 1,878 Mar-18-2019, 03:27 AM
Last Post: dmytruk
  data base models IMuriel 1 2,108 Jan-14-2019, 08:55 PM
Last Post: Gribouillis
  Error while creating new Creating Models on Django aniyanetworks 2 5,327 Jul-13-2018, 12:57 PM
Last Post: aniyanetworks

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020