Administrator interface after change of model



  • After changing the model, the adminc stopped showing the model fields. I mean, they appear on the general list, and when a specific model is open, it's just an empty window of adminca with the "suck" buttons, "storage" etc. Changes in the model are quite simple, too: deleted the field TextFieldadded the field ForeignKey♪ Migratory, admin.py The reference to the old field has also been deleted.

    The model code and its corresponding model in the adminke are given below.

    class DocumentModel(models.Model):
        title = models.CharField(max_length=100, db_index=True)
        url_address = models.CharField(max_length=255, blank=True, null=True, db_index=True)
        text_document = models.ForeignKey(DocumentTextModel, blank=True, null=True, verbose_name=u'Контент', db_index=True)
        #text_doc = models.TextField(blank=True, null=True, verbose_name=u'Контент')
        visible_left = models.BooleanField(verbose_name=u'Левый столбец', db_index=True)
        visible_right = models.BooleanField(default=True, verbose_name=u'Правый столбец', db_index=True)
        visible_middle = models.BooleanField(default=True, verbose_name=u'Центр главной страницы', db_index=True)
        changedate = models.DateTimeField(auto_now=True, verbose_name=u'Дата изменения', db_index=True)
    

    class DocumentAdminModel(admin.ModelAdmin):
    ordering = ['changedate']
    list_display = ('title', 'changedate', )
    list_filter = ('changedate')
    # resize CharField in Form
    formfield_overrides = {
    # Django enforces maximum field length of 14 onto 'title' field when user is editing in the change form
    models.CharField: {'widget': forms.TextInput(attrs={'size':'300'})},
    }
    # search in model
    search_fields = ['title', ]

    I'm also making a violinchet of hell:
    Пустой интерфейс



  • You forgot to list model fields in the attribute. fields:

    class DocumentAdminModel(admin.ModelAdmin):
        fields = ('title', 'url_address' ..)
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2