Answers for "models django"

8

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
Posted by: Guest on November-06-2020
2

primary key django model

class Garden(models.Model):
    garden_id = models.IntegerField(primary_key=True)
Posted by: Guest on April-29-2020
1

models django

from django.db import models


class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')


class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
Posted by: Guest on May-05-2021
1

from django.db import models

from django.db import models

class Person(models.Model):
  	"""
    	This class creates a new table with 
        the name of your application and that class name. 
        The fully qualified name of the table 
        will be "appName_className". 
        Also, two fields with data type char will be 
        created: first_name and last_name.
    """
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
Posted by: Guest on January-08-2021
0

listing of django model types

See this link
https://www.webforefront.com/django/modeldatatypesandvalidation.html
Posted by: Guest on March-17-2020
6

django models

Models in Django are classes that represent data base tables.
Posted by: Guest on July-04-2020

Browse Popular Code Answers by Language