class Section(models.Model): id = models.AutoField(primary_key=True) parent = models.ForeignKey('self', default=None,blank=True, null=True) name = models.CharField(max_length=100, unique=True) visible = models.BooleanField(db_index = True,default=True) class Blog(models.Model): id = models.AutoField(primary_key=True) section_id = models.ForeignKey(Section, default=None,blank=True, null=True) description = models.TextField(blank=True) created = models.DateTimeField(auto_now_add=True)
ADMIN
from myproject.blog.models import Blog,Section from django.contrib import admin admin.site.register(Blog) admin.site.register(Section)
При попытке сохранить в админке получаю
Please correct the error below.
This field is required.
на полях parent и section_id