添加按钮不显示在Django管理员中

时间:2018-04-04 12:29:58

标签: python django

我正在尝试从django教程中添加相关对象的文档https://docs.djangoproject.com/en/1.11/intro/tutorial07

但是没有显示添加按钮

我也检查了这个答案,但没有帮助Add button not showing up in Django tutorial 02

这是我的admin.py

  loadData() {   
  var url = 'assets/data/skills.json';
  if (this.platform.is('cordova') && this.platform.is('android')) {
          url = "/android_asset/www/" + url;
      }
    return new Promise(resolve => {
      this.http.get(url)
        .subscribe((data) => {
          resolve(data);
        }, err => {
          console.log(err);
        });
    });
  }

这是我的models.py

   from __future__ import unicode_literals

   from django.contrib import admin
   from home.models import *

   # Register your models here.

   class ChoiceInline(admin.StackedInline):
       model = Choice
       extra = 3
   class QuestionAdmin(admin.ModelAdmin):
       fieldsets = [
                    (None,{'fields': ['question_text']}),
                    ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
                   ]
       inlines = [ChoiceInline]

   admin.site.register(Question, QuestionAdmin)

This is showing in my admin page

python使用的是python 2.7

1 个答案:

答案 0 :(得分:1)

您还需要注册模型选择。

onClickMe(id)
{
  let decimal = this.date.getMonth()+1;
  this.router.navigate(['/RestaurantView/'+this.nembPerson+'/'+this.timereservation+'/'+this.date.getDate()+'/'+decimal+'/'+this.date.getFullYear()+'/'+id]) ;
}