Django:在model.py中添加的新类未在管理网站中显示 [英] Django: New class added in model.py not showing in admin site

查看:85
本文介绍了Django:在model.py中添加的新类未在管理网站中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是与Django并肩奋斗的前端开发人员。我的基础知识已经大大降低了,但在接下来的时间里我遇到了麻烦。

I'm a front-end dev struggling along with Django. I have the basics pretty much down but I've hit at wall at the following point.

我有一个本地运行的站点,也运行在开发机器上。在本地,我为现有的应用程序添加了一个额外的类模型,并在相关的admin.py中进行了注册,并在设置中进行了检查。新课程和相关字段在本地显示在admin中,但是当我将所有这些移至dev时,它们都不会出现。该应用程序称为发布。

I have a site running locally and also on a dev machine. Locally I've added an extra class model to an already existing app, registered it in the relevant admin.py and checked it in the settings. Locally the new class and relevant fields appear in admin but when I move this all to dev they're not appearing. The app is called 'publish'.

我的方法如下:


  1. 在发布> models.py文件中创建新类:





    class Whitepaper(models.Model):
        title = models.CharField(max_length=200)
        slug = models.SlugField(max_length=100, blank=True)
        pub_date = models.DateField('date published')
        section = models.ForeignKey('Section', related_name='whitepapers', blank=True, null=True)
        description = models.CharField(max_length=1000)
        docfile = models.FileField(upload_to="whitepapers/%Y/%m/%d", null=True, blank=True)




  1. 使用South更新并迁移了模型,



python manage.py schemamigration publish --auto

python manage.py migrate publish




  1. 在admin.py f中注册了课程ile:





    from models import Section, Tag, Post, Whitepaper
    from django.contrib import admin
    from django import forms

    admin.site.register(Whitepaper)

该应用程序在settings.py文件中列出:

The app is listed in the settings.py file:



    INSTALLED_APPS = (
        ...,
        ...,
        'publish',
        ...,

)

由于它是在托管其他一些测试区域的开发服务器上运行的,因此无法重新启动整个操作,因此我一直在接触 .wsgi文件。

As this is running on a dev server that's hosting a few other testing areas, restarting the whole thing is out of the question so I've been 'touching' the .wsgi file.

在我的本地版本中,该模型和字段显示在管理员中,但在开发服务器上却看不见它们。

On my local version this got the model and fields showing up in the admin but on the dev server they are nowhere to be seen.

我想念什么?

谢谢你们那些聪明的人。

Thanks ye brainy ones.

推荐答案

我解决了这个问题。原来我用来进入管理员的登录名没有超级用户权限。所以我做了一个新的:

I figured out the problem. Turns out the login I was using to get into the admin didn't have superuser privileges. So I made a new one with:

python manage.py createsuperuser

使用新的用户名和密码登录后,我可以看到所有新的闪亮表!

After logging in with the new username and password I could see all my new shiny tables!

这篇关于Django:在model.py中添加的新类未在管理网站中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆