应用程序不会显示在 Django 管理中

发布于 2024-08-16 14:51:29 字数 2127 浏览 5 评论 0原文

我已阅读所有其他线程,但我仍然不明白为什么我的应用程序没有显示在 Django 管理中。其他一切都很好。

我的应用程序位于 settings.py 中

我的根 urls.py 文件中有 admin.autodiscover

from django.conf.urls.defaults import *
from django.conf import settings

from django.views.generic.simple import direct_to_template

from django.contrib import admin

admin.autodiscover()



urlpatterns = patterns('',
url(r'^$', direct_to_template, {
    "template": "homepage.html",
}, name="home"),

url(r'^admin/invite_user/$', 'signup_codes.views.admin_invite_user', name="admin_invite_user"),
url(r'^account/signup/$', "signup_codes.views.signup", name="acct_signup"),

(r'^account/', include('account.urls')),
(r'^profiles/', include('basic_profiles.urls')),
(r'^notices/', include('notification.urls')),
(r'^announcements/', include('announcements.urls')),
(r'^tagging_utils/', include('tagging_utils.urls')),
(r'^attachments/', include('attachments.urls')),
(r'^comments/', include('threadedcomments.urls')),
#
(r'^wayfinder/', include('wayfinder.urls')),
(r'^site/', include('jsite.urls')),
(r'^kiosk/', include('kiosk.urls')),
(r'^navigator/', include('navigator.urls')),
(r'^location/', include('location.urls')),
(r'^event/', include('event.urls')),
#(r'^news_reader/', include('news_reader.urls')),
#(r'^weather_reader/', include('weather_reader.urls')),

(r'^admin/(.*)', admin.site.root),
)

if settings.SERVE_MEDIA:
urlpatterns += patterns('',
    (r'^site_media/', include('staticfiles.urls')),
)

我所有的应用程序都有一个 admin.py 文件,其中包含类似的内容

from django.contrib import admin
from event.models import Event

class EventAdmin(admin.ModelAdmin):
    list_display = (
                'short_name',
                'long_name',
                'locations',
                'categories',
                'description',
                'phone',
                'email',
                'url_source',
                'url_location',
                'external_ref',
                'show_event'
            )

admin.site.register(Event, EventAdmin)

我已经一遍又一遍地重新启动服务器;-)

我正在 Pinax 之上构建,但从我的阅读来看,它不应该改变任何东西。有什么线索可能出问题了吗?

I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.

My apps are in settings.py

I have admin.autodiscover in my root urls.py file

from django.conf.urls.defaults import *
from django.conf import settings

from django.views.generic.simple import direct_to_template

from django.contrib import admin

admin.autodiscover()



urlpatterns = patterns('',
url(r'^

All my apps have an admin.py file containing something like

from django.contrib import admin
from event.models import Event

class EventAdmin(admin.ModelAdmin):
    list_display = (
                'short_name',
                'long_name',
                'locations',
                'categories',
                'description',
                'phone',
                'email',
                'url_source',
                'url_location',
                'external_ref',
                'show_event'
            )

admin.site.register(Event, EventAdmin)

And I have restarted the server over and over ;-)

I am building on top of Pinax, but from my reading, it shouldn't change anything. Any clue what might be wrong ?

, direct_to_template, { "template": "homepage.html", }, name="home"), url(r'^admin/invite_user/

All my apps have an admin.py file containing something like


And I have restarted the server over and over ;-)

I am building on top of Pinax, but from my reading, it shouldn't change anything. Any clue what might be wrong ?

, 'signup_codes.views.admin_invite_user', name="admin_invite_user"), url(r'^account/signup/

All my apps have an admin.py file containing something like


And I have restarted the server over and over ;-)

I am building on top of Pinax, but from my reading, it shouldn't change anything. Any clue what might be wrong ?

, "signup_codes.views.signup", name="acct_signup"), (r'^account/', include('account.urls')), (r'^profiles/', include('basic_profiles.urls')), (r'^notices/', include('notification.urls')), (r'^announcements/', include('announcements.urls')), (r'^tagging_utils/', include('tagging_utils.urls')), (r'^attachments/', include('attachments.urls')), (r'^comments/', include('threadedcomments.urls')), # (r'^wayfinder/', include('wayfinder.urls')), (r'^site/', include('jsite.urls')), (r'^kiosk/', include('kiosk.urls')), (r'^navigator/', include('navigator.urls')), (r'^location/', include('location.urls')), (r'^event/', include('event.urls')), #(r'^news_reader/', include('news_reader.urls')), #(r'^weather_reader/', include('weather_reader.urls')), (r'^admin/(.*)', admin.site.root), ) if settings.SERVE_MEDIA: urlpatterns += patterns('', (r'^site_media/', include('staticfiles.urls')), )

All my apps have an admin.py file containing something like

And I have restarted the server over and over ;-)

I am building on top of Pinax, but from my reading, it shouldn't change anything. Any clue what might be wrong ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

驱逐舰岛风号 2024-08-23 14:51:29

您的应用程序位于 settings.py 的 INSTALLED_APPS 部分吗?
确保其中列出了您的应用程序。 我的部分是

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'squick.items',
'cowsite.search',
'cowsite.posts',

这样的

例如, 。我非常确定出于安全考虑,它们不会显示在管理员中,除非它们位于已安装的应用程序中。我想我也遇到了同样的问题,我无法让cowsite出现在管理员中。

Django 文档 讲述了管理页面:“默认情况下,它按字母顺序显示已在管理应用程序中注册的 INSTALLED_APPS 中的所有应用程序”

Do you have your apps in the INSTALLED_APPS section in settings.py?
Make sure it has your apps listed there. My section reads

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'squick.items',
'cowsite.search',
'cowsite.posts',

)

for instance. I'm pretty sure for security, they won't show up in the admin unless they are in installed apps. I think I had this same issue, where I couldn't get cowsite to show up in the admin.

The Django docs say about the admin page: "By default, it displays all the apps in INSTALLED_APPS that have been registered with the admin application, in alphabetical order"

苍暮颜 2024-08-23 14:51:29

巧合的是,今天早上我也遇到了同样的问题。简而言之,这对我有用(详细信息请参阅参考资料):

在 MyApp 的顶级目录(即与 models.py 等相同的目录)中,我添加了一个 python 模块 admin.py,其中包含:

from models import ThisModel, ThatModel
from django.contrib import admin

admin.site.register(ThisModel)
admin.site.register(ThatModel)

然后在 mysite 目录中我做了syncdb和runserver,ThisModel和ThatModel在管理界面中。

这对你有用吗?

最美好的祝愿

Ivan

** 参考文献

(我是一名新成员,所以我只能发布一个超链接!)

Django 教程:使民意调查应用程序可在管理员中修改

最近在 Pinax google 群组上也有一个查询,标题为,“如何将我的应用程序添加到 Pinax 项目中的管理员?”

By coincidence I had the same problem this morning. Briefly, this is what worked for me (see references for details):

In the top level directory of MyApp (ie same directory as models.py, etc.) I added a python module admin.py, containing:

from models import ThisModel, ThatModel
from django.contrib import admin

admin.site.register(ThisModel)
admin.site.register(ThatModel)

Then in mysite directory I did syncdb and runserver, and ThisModel and ThatModel were in the admin interface.

Does that work for you?

Best wishes

Ivan

** References

(I am a new member so I am allowed to post one hyperlink only!)

Django tutorial: Make the poll app modifiable in the admin

There was also a query on the Pinax google group recently titled, "How to add my app to Admin in a Pinax project?"

北陌 2024-08-23 14:51:29

您是否以超级用户身份登录管理员?如果没有,可能是权限问题。

Are you logging in to admin as a superuser? If not, it could be a permissions problem.

静待花开 2024-08-23 14:51:29

不确定您使用的是哪个版本的 django,但当前文档建议包括管理 URL。

 ('^admin/', include(admin.site.urls))

Not sure which version of django you're using but the current docs suggest including the admin urls.

 ('^admin/', include(admin.site.urls))
蓝戈者 2024-08-23 14:51:29

对于其他遇到此问题的人,我遇到了同样的问题,因为 grappelli.dashboard 位于已安装的应用程序中,但实际上并未安装在 virtualenv 中,因此请执行 pip freeze 并确保实际安装了所有要求。

For other's coming across this, I had the same issue due to grappelli.dashboard being in the installed apps but not actually installed in the virtualenv, so do a pip freeze and ensure all your requirements are actually installed.

独夜无伴 2024-08-23 14:51:29

在安装的应用程序的“settings.py”文件中添加您的应用程序名称。

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myapp',


]

add your app name in "settings.py" file installed app.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myapp',


]
娜些时光,永不杰束 2024-08-23 14:51:29

如果其他解决方案不适合您,请尝试在其他浏览器中加载您的管理仪表板。当我使用 Google Chrome 时,我的一个应用程序未显示在管理仪表板上。在尝试了其他人建议的多个答案后,我决定使用 Firefox。瞧!我终于能够在管理仪表板上看到我的应用程序了。

If the other solutions did not work for you, try to load your admin dashboard in a different browser. One of my apps was not displaying on the admin dashboard while I was using Google Chrome. After trying multiple answers others suggested, I decided to use Firefox instead. Voila! I was finally able to see my app on the admin dashboard.

咆哮 2024-08-23 14:51:29

你没有回答安东尼的问题。您是否以超级用户身份登录,或者至少以具有应用程序添加/编辑权限的用户身份登录?如果没有,你就看不到他们。

You didn't answer Antony's question. Are you logging in as a superuser, or at least with a user with add/edit rights for the applications? If not, you won't see them.

花辞树 2024-08-23 14:51:29

我遇到了同样的问题,对我有用的是将 urls.py: 中的这一行更改

url(r'^admin/', include(admin.site.urls)),

url('^admin/', include(admin.site.urls)),

(删除第一段代码中的 r
由于某种我不知道的原因,民意调查在那之后在管理员中可见。

I had the same problem, what worked for me was changing this line in urls.py:

url(r'^admin/', include(admin.site.urls)),

to

url('^admin/', include(admin.site.urls)),

(Removing the r in the first bit of code)
For some reason I am not aware of, the Polls became visible in admin after that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文