Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

field in django

from django.db import models

class Student(models.Model):
    FRESHMAN = 'FR'
    SOPHOMORE = 'SO'
    JUNIOR = 'JR'
    SENIOR = 'SR'
    GRADUATE = 'GR'
    YEAR_IN_SCHOOL_CHOICES = [
        (FRESHMAN, 'Freshman'),
        (SOPHOMORE, 'Sophomore'),
        (JUNIOR, 'Junior'),
        (SENIOR, 'Senior'),
        (GRADUATE, 'Graduate'),
    ]
    year_in_school = models.CharField(
        max_length=2,
        choices=YEAR_IN_SCHOOL_CHOICES,
        default=FRESHMAN,
    )

    def is_upperclass(self):
        return self.year_in_school in {self.JUNIOR, self.SENIOR}
Comment

PREVIOUS NEXT
Code Example
Python :: How to find the maximum subarray sum in python? 
Python :: web scraping with selenium 
Python :: aws lambda logging with python logging library 
Python :: python basic data types 
Python :: pandas weighted average groupby 
Python :: os module in python 
Python :: precision accuracy recall python example 
Python :: how to store the variable in dictionary 
Python :: python interview questions and answers pdf 
Python :: convert string to datetime python 
Python :: what is a python module 
Python :: remove first element from list python 
Python :: streamlit cheatsheet 
Python :: how to access pandas column 
Python :: Python list append tutorial 
Python :: Program to Compute LCM Using GCD 
Python :: how to earn money as a python developer 
Python :: python number type 
Python :: print file in python 
Python :: python copy list 
Python :: django create object from dict 
Python :: all string methods in python 
Python :: python unicode point to utf8 string 
Python :: swap list 
Python :: Python program to find second largest 
Python :: python decorator class 
Python :: string length python 
Python :: numpy array into tuple 
Python :: how to change datatype of column in pandas 
Python :: Heroku gunicorn flask login is not working properly 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =