[PY] [Mx]django Add Background Course Organization page data-image upload settings

Source: Internet
Author: User
Tags add time

Analysis Next course page foreground section

    • Type of organization-currently there is no such field in the Organization library, you need to append
    • Area Xadmin can be added manually
    • The course organization relates to the organization cover diagram, that is, the image upload media settings, also need to manually add a few in the Xadmin

Add Data with Xadmin

Area added

Course Organization add

Field of the supplementary agency category in model
class CourseOrg(models.Model):    catagory = models.CharField(max_length=20, default="pxjg", choices=(("pxjg", "培训机构"), ("gr", "个人"), ("gx", "高校")),                                verbose_name="机构类别")

Full-

  class courseorg (models. Model): name = models. Charfield (max_length=20, verbose_name= "course organization") desc = models. TextField (verbose_name= "course Organization description") Catagory = models.                                Charfield (max_length=20, default= "PXJG", Choices= (("PXJG", "Training Institution"), ("Gr", "personal"), ("GX", "university"), Verbose_name= "Organization category") Click_nums = models. Integerfield (default=0, verbose_name= "course organization hits") Fav_nums = models. Integerfield (default=0, verbose_name= "Number of collectors") image = Models. ImageField (upload_to= "org/%y/%m", verbose_name= "cover map") address = models. Charfield (max_length=150, verbose_name= "agency address") City = models. ForeignKey (citydict, verbose_name= "City", On_delete=models. CASCADE) Add_time = models. Datetimefield (Default=datetime.now, verbose_name= "Add Time") class Meta:verbose_name = "course Organization" verbose_name_p Lural = Verbose_name def __str__ (self): return self.name  
makemigrations organizationmigrate organization同步玩库后手动添加 课程 和 课程机构数据

Media (image upload) settings in Settings
settings.pyMEDIA_URL = '/media/'MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

[PY] [Mx]django Add Background Course Organization page data-image upload settings

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.