Re: no Polls in the admin page

238 views
Skip to first unread message

Sandeep kaur

unread,
Nov 1, 2012, 11:42:01 PM11/1/12
to django...@googlegroups.com
On Fri, Nov 2, 2012 at 12:29 AM, Mihail Mihalache
<mihalach...@yahoo.com> wrote:
> I have followed the django tutorial up to part 2 -
> https://docs.djangoproject.com/en/1.4/intro/tutorial02/ .
> Everything worked fine, until I couldn't see the Polls entry on the admin
> page. I have checked that I have done everything mentioned in the tutorial.
> I get no error whatsoever. I have no idea what's wrong.
> There is a polls entry INSTALLED_APPS.
>
Your admin.py file should have this code :
-------------------------------------------------------------------------
from mysite.polls.models import Poll
from django.contrib import admin
from mysite.polls.models import Choice


class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3

class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question']}),
('Date information', {'fields': ['pub_date']}),
]
inlines = [ChoiceInline]
list_display = ('question', 'pub_date')
list_filter = ['pub_date']
search_fields = ['question']

admin.site.register(Poll, PollAdmin)
-----------------------------------------------------------------------------

--
Sandeep Kaur
E-Mail: mkaur...@gmail.com
Blog: sandymadaan.wordpress.com

Elena Williams

unread,
Nov 2, 2012, 3:06:05 AM11/2/12
to django...@googlegroups.com
Actually the minimum requirement for the application to appear in admin is this (here in docs: https://docs.djangoproject.com/en/dev/intro/tutorial02/#make-the-poll-app-modifiable-in-the-admin ):


admin.py:

from django.contrib import admin
from mysite.polls.models import Poll, Choice

# `register()` optionally takes a second argument of a `admin.ModelAdmin` object
admin.site.register(Poll)
admin.site.register(Choice)


Though as Sandeep put in this code --  in this case you probably would like the `polls.Choice` inline, which would look like this:

admin.py: 

from django.contrib import admin
from mysite.polls.models import Poll, Choice


class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 1

class PollAdmin(admin.ModelAdmin):
        inlines = [ChoiceInline]

admin.site.register(Poll, PollAdmin)



---
Elena :)
@elequ
04022 90172




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Ryan Blunden

unread,
Dec 26, 2012, 6:43:38 PM12/26/12
to django...@googlegroups.com
Can you provide the contents of your admin.py in your polls app. If you've got the below code, then I'm not sure how that is happening.
class PollAdmin(admin.ModelAdmin):
    fields = ['pub_date', 'question']

admin.site.register(Poll, PollAdmin)

Cheers,
Ryan

On 26/12/2012, at 11:09 AM, Kelketek Rritaa <kelk...@gmail.com> wrote:

I'm having precisely the same issue with precisely the same side effects. Further, I am able to get output to my logs by adding a print statement to the admin.py file. So I know it's being executed, it just doesn't show up in the admin page. Running syncdb has not fixed it.

Has anyone found a solution to this? There obviously must be something else that needs to be done, as all the other apps continue to hum along just fine in the admin page.


On Thursday, November 1, 2012 1:59:18 PM UTC-5, Mihail Mihalache wrote:
I have followed the django tutorial up to part 2 - https://docs.djangoproject.com/en/1.4/intro/tutorial02/ .
Everything worked fine, until I couldn't see the Polls entry on the admin page. I have checked that I have done everything mentioned in the tutorial. 
I get no error whatsoever. I have no idea what's wrong.
There is a polls entry INSTALLED_APPS.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/eQx6YFul_j4J.

Kelketek Rritaa

unread,
Dec 27, 2012, 9:46:33 AM12/27/12
to django...@googlegroups.com
I'd been trying several things to see if they'd work, so I went with the absolute minimum that /should/ work:

from polls.models import Poll
from django.contrib import admin
admin.site.register(Poll)

Putting in the code you've given me does not work either.

HOWEVER, yesterday I was poking around with it quite a bit, and was able to find out the following.

1. Even though the polls app isn't showing on the index page, admin/polls/poll/ works fine.
2. Admin does register the poll program:

In [1]: from django.contrib import admin

In [2]: import polls.admin

In [3]: admin.site._registry
Out[3]: {polls.models.Poll: <polls.admin.PollAdmin at 0xaf5c88c>}

3. It should be noted that this project is an already existing one I'm trying to modify. Do you know if there's a way to 'mask' what applications end up on the admin page? If so, this may have been enabled by the upstream for my project, and I need to find a way to disable this.

Ryan Blunden

unread,
Dec 27, 2012, 2:06:17 PM12/27/12
to django...@googlegroups.com
I'm not aware of any upstream apps 'masking' the display of other apps in the admin root page but I would try to disable all other third party (non-Django contrib) apps and see if that changes the result.

To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/fTqX2fAFtY4J.

Kelketek Titikilik Rritaa

unread,
Dec 27, 2012, 2:43:43 PM12/27/12
to django...@googlegroups.com
I found the issue. The issue appears to be in a template override for
the Admin app that the upstream provider added. When this was moved
out of the way, the standard template was loaded, and polls showed up.

Ryan Blunden

unread,
Dec 27, 2012, 6:32:21 PM12/27/12
to django...@googlegroups.com
Awesome! Glad you got it solved.
Reply all
Reply to author
Forward
0 new messages