No. 375, Django+xadmin build a standard online education platform-Create a course organization app, generate 3 tables in the models.py file, city tables, course organization tables, instructor tables

Source: Internet
Author: User

No. 375, Django+xadmin build a standard online education platform-Create a course organization app, generate 3 tables in the models.py file, city tables, course organization tables, instructor tables

Create a course agency APP named App_organization, write a database operations file models.py

models.py File

#!/usr/bin/env python#-*-coding:utf-8-*- from __future__ Importunicode_literals fromDatetimeImportdatetime fromDjango.dbImportModels#Importing Models ObjectsclassCitydict (models. Model): Name= Models. Charfield (max_length=20, verbose_name='City') desc= Models. Charfield (max_length=200, verbose_name='Description') Add_time= Models. Datetimefield (Default=datetime.now, verbose_name='Add Date')    classMeta:verbose_name='City Table'verbose_name_plural=Verbose_nameclasscourseorg (models. Model): Name= Models. Charfield (max_length=50, verbose_name='Name of Institution') desc= Models. TextField (verbose_name='Organization Description') Click= Models. Integerfield (default=0, verbose_name='Number of clicks') Fav_nums= Models. Integerfield (default=0, verbose_name='Number of Favorites') Image= Models. ImageField (upload_to='org/%y/%m', verbose_name='Cover Map', max_length=100) Address= Models. Charfield (max_length=150, verbose_name='Agency Address') City= Models. ForeignKey (Citydict, verbose_name='foreign key City table') Add_time= Models. Datetimefield (Default=datetime.now, verbose_name='Add Date')    classMeta:verbose_name='Course Organization Table'verbose_name_plural=Verbose_nameclassTeacher (models. Model): Org= Models. ForeignKey (courseorg, verbose_name='FOREIGN key Course organization Table') name= Models. Charfield (max_length=50, verbose_name='Instructor Name') Work_years= Models. Integerfield (default=0, verbose_name='Working years') Work_company= Models. Charfield (max_length=50, verbose_name='Employment Company') Work_position= Models. Charfield (max_length=50, verbose_name='Company Position') Points= Models. Charfield (max_length=50, verbose_name='Teaching Features') Click= Models. Integerfield (default=0, verbose_name='Number of clicks') Fav_nums= Models. Integerfield (default=0, verbose_name='Number of Favorites') Add_time= Models. Datetimefield (Default=datetime.now, verbose_name='Add Date')    classMeta:verbose_name='Instructor Table'verbose_name_plural= Verbose_name

No. 375, Django+xadmin build a standard online education platform-Create a course organization app, generate 3 tables in the models.py file, city tables, course organization tables, instructor tables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.