django models list code example

Example 1: create models in django

from django.db import models
# Create your models here.

class Contact(models.Model):
    name = models.CharField(max_length=50)
    email = models.CharField(max_length=50)
    contact = models.CharField(max_length=50)
    content = models.TextField()
    def __str__(self):
        return self.name + ' ' + self.email

Example 2: django models

Models in Django are classes that represent data base tables.

Example 3: listing of django model types

See this link
https://www.webforefront.com/django/modeldatatypesandvalidation.html

Example 4: django model fields list

from posts.model import BlogPost

all_fields = BlogPost._meta.fields
#or
all_fields = BlogPost._meta.get_fields()