Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django model queries

from datetime import date

from django.db import models

class Blog(models.Model):
    name = models.CharField(max_length=100)
    tagline = models.TextField()

    def __str__(self):
        return self.name

class Author(models.Model):
    name = models.CharField(max_length=200)
    email = models.EmailField()

    def __str__(self):
        return self.name

class Entry(models.Model):
    blog = models.ForeignKey(Blog, on_delete=models.CASCADE)
    headline = models.CharField(max_length=255)
    body_text = models.TextField()
    pub_date = models.DateField()
    mod_date = models.DateField(default=date.today)
    authors = models.ManyToManyField(Author)
    number_of_comments = models.IntegerField(default=0)
    number_of_pingbacks = models.IntegerField(default=0)
    rating = models.IntegerField(default=5)

    def __str__(self):
        return self.headline
Comment

PREVIOUS NEXT
Code Example
Python :: infinite for loop python 
Python :: print in pythin 
Python :: how to check if a string value is nan in python 
Python :: decoding 
Python :: run flask in background 
Python :: count true in a dataframe 
Python :: python palindrome program 
Python :: pass multiple arguments to map function python 
Python :: python array spread 
Python :: how to generate two random numbers in python 
Python :: Python NumPy column_stack Function Syntax 
Python :: selenium check if driver is open python 
Python :: python how to make a user input function 
Python :: python 3.6 release date 
Python :: flask_jinja structure 
Python :: pandas extracting tables from pdf 
Python :: "scrapy shell" pass cookies to fetch 
Python :: AttributeError: __enter__ in python cde 
Python :: ValueError: tuple.index(x): x not in tuple 
Python :: how to get github repository access in python code directly 
Python :: File "main.py", line 21 print("total harga:idr", bakso bulat +str Minuman Drink): ^ SyntaxError: invalid syntax 
Python :: pystache unescaped characters 
Python :: scikit learn split data set site:stackoverflow.com 
Python :: Highlighting the shortest path in a Networkx graph 
Shell :: install git on amazon linux 
Shell :: how to kill apache process in linux 
Shell :: ubuntu media codecs 
Shell :: linker `cc` not found 
Shell :: kill a port process in ubuntu 
Shell :: Install redis on macbook pro 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =