Answers for "django model example"

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
1

django model

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
3

django model example

from django.db import models

class myModel(models.Model):
  input1 = models.CharField(max_length=100)
  input2 = models.TextField()
  input3 - models.DateTimeField(auto_now=True)
  
  def __str__(self):
	return self.input1
Posted by: Guest on February-11-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
6

django models

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

model object means in django

from django.db import models

class Person(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
Posted by: Guest on July-21-2020

Python Answers by Framework

Browse Popular Code Answers by Language