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.
我是一个与Django一起挣扎的前端开发者。我的基础知识差不多了,但是我已经在以下几点击中了墙。
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'.
我有一个本地运行的站点,也在dev机器上运行。在本地我已经为现有应用添加了一个额外的类模型,在相关的admin.py中注册并在设置中进行了检查。在本地,新类和相关字段显示在admin中,但是当我将其全部移动到dev时,它们不会出现。该应用程序称为“发布”。
My method was as follows:
我的方法如下:
- Created the new class in the publish > models.py file:
- 在publish> 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)
- Updated and migrated the model with South using:
- 使用以下内容更新并迁移模型:
python manage.py schemamigration publish --auto
and
和
python manage.py migrate publish
- Registered the class in the admin.py file:
- 在admin.py文件中注册了该类:
from models import Section, Tag, Post, Whitepaper from django.contrib import admin from django import forms admin.site.register(Whitepaper)
The app is listed in the settings.py file:
该应用程序列在settings.py文件中:
INSTALLED_APPS = ( ..., ..., 'publish', ..., )
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.
由于这是在托管其他几个测试区域的开发服务器上运行,重新启动整个事情是不可能的,所以我一直在“触摸”.wsgi文件。
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.
在我的本地版本中,这得到了模型和字段显示在管理员但在开发服务器上,他们无处可见。
What am I missing?
我错过了什么?
Thanks ye brainy ones.
谢谢你们聪明的人。
2 个解决方案
#1
7
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!
使用新的用户名和密码登录后,我可以看到所有新的闪亮表格!
#2
0
Are you sure touching .wsgi
file does restart your app?
您确定触摸.wsgi文件确实重启了您的应用吗?
It looks like it doesn't.
它看起来没有。
Make sure the app is restarted. Find the evidence touching .wsgi
file restarts the app maybe.
确保重新启动应用。找到触摸.wsgi文件的证据重启应用程序可能。
Since you don't provide any insight about how the dev server runs the apps, we won't be able to help you any further.
由于您未提供有关开发服务器如何运行应用程序的任何信息,因此我们无法为您提供进一步的帮助。
#1
7
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!
使用新的用户名和密码登录后,我可以看到所有新的闪亮表格!
#2
0
Are you sure touching .wsgi
file does restart your app?
您确定触摸.wsgi文件确实重启了您的应用吗?
It looks like it doesn't.
它看起来没有。
Make sure the app is restarted. Find the evidence touching .wsgi
file restarts the app maybe.
确保重新启动应用。找到触摸.wsgi文件的证据重启应用程序可能。
Since you don't provide any insight about how the dev server runs the apps, we won't be able to help you any further.
由于您未提供有关开发服务器如何运行应用程序的任何信息,因此我们无法为您提供进一步的帮助。