Search code snippets, questions, articles... Chrome Extension

Create models in Django

from django.db import models

class Person(models.Model):
    name = models.CharField(max_length=30)
    experience = models.IntegerField()
    is_active = models.BooleanField()
    auto_field = models.AutoField() //INTEGER FIELD THAT automatically increments
    emaill = models.EmailField(max_length=100) //CharField that checks - provided value is a valid email
    description = models.TextField() //Used to store large text value
    created_date = models.DateTimeField()
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

You will have to import models form 'django.db' to create a new model and then use models. Model while creating a new class. Django provides different type of data types like CharField, Integer, etc which will help you to design your database.

We have added different type of data type fields in the code snippet like Integer field, Boolean field, Character field, etc. You can use them according to your requirements.

Was this helpful?
0 Comments
Join Devsheet Ask a Question