Backend Xpert
Published in

Backend Xpert

Tutorial #6 — Introduction to Django Model Design and it’s optional keyword arguments.

Photo by Kelly Sikkema on Unsplash

Frequently Used Django Fields Options

Frequently Used Django Model Fields

from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField()
from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField(verbose_name = 'Blog Title')
reactdj_score = models.IntegerField(default=10)
from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField(verbose_name = 'Blog Title')
reactdj_score = models.IntegerField(default=10)
published = models.BooleanField(default=False)
from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField(verbose_name = 'Blog Title')
reactdj_score = models.IntegerField(default=10)
published = models.BooleanField(default=False)
avg_rating = models.DecimalField(max_digits=3,decimal_places=2)
from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField(verbose_name = 'Blog Title')
reactdj_score = models.IntegerField(default=10)
published = models.BooleanField(default=False)
avg_rating = models.DecimalField(max_digits=3,decimal_places=2)
thumbnail = models.ImageField(upload_to='images/thumbnails')
from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField(verbose_name = 'Blog Title')
reactdj_score = models.IntegerField(default=10)
published = models.BooleanField(default=False)
avg_rating = models.DecimalField(max_digits=3,decimal_places=2)
thumbnail = models.ImageField(upload_to='images/thumbnails')
medium_url = models.URLField()
from django.db import modelsClass Blog(models.Model):    blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField(verbose_name = 'Blog Title')
reactdj_score = models.IntegerField(default=10)
published = models.BooleanField(default=False)
avg_rating = models.DecimalField(max_digits=3,decimal_places=2)
thumbnail = models.ImageField(upload_to='images/thumbnails')
medium_url = models.URLField()
published_on = models.DateTimeField(auto_now=True)
from django.db import modelsclass Difficulty(models.Model):

difficulty_id = models.CharField(max_length=10,primary_key=True)
name = models.CharField(max_length=200)

Class Blog(models.Model):
blog_id = models.CharField(max_length=25,unique=True)
title = models.TextField(verbose_name = 'Blog Title')
reactdj_score = models.IntegerField(default=10)
published = models.BooleanField(default=False)
avg_rating = models.DecimalField(max_digits=3,decimal_places=2)
thumbnail = models.ImageField(upload_to='images/thumbnails')
medium_url = models.URLField()
published_on = models.DateTimeField(auto_now=True)
difficulty = models.ForeignKey(Difficulty, on_delete=models.CASCADE)

Our series of tutorials are currently organized at — srplabs.in

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store