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