Hello,

The built in admin system for django names it's URL's by application
name then model name. So if you have an application called "polls" and
in that application you have a model called "poll" then the admin URL
to edit those models would be admin/polls/poll

amdin/polls will show all the models that you have set up in admin.py
in your polls application.

Hope that explains it!




On Dec 6, 3:50 pm, bigshift <hugesh...@gmail.com> wrote:
> Hello I'm just discovering Django and it was exactly the tool I was
> looking for. This is great !
>
> Following the tutorial, I have an anomaly in my "pool"
> administration :
> the page that it supposed to be athttp://localhost:8000/admin/polls/
> is athttp://localhost:8000/admin/polls/poll/
>
> Maybe I made something wrong in my model, but I don't find any
> mistake :
>
> here's my models.py :
> ---------------------------------
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>         question = models.CharField(max_length=200)
>         pub_date = models.DateTimeField('date published')
>         def was_published_today(self):
>                 return self.pub_date.date() == datetime.date.today()
>         was_published_today.short_description = 'Published today?'
>         def __unicode__(self):
>                 return self.question
>
> class Choice(models.Model):
>         poll = models.ForeignKey(Poll)
>         choice = models.CharField(max_length=200)
>         votes = models.IntegerField()
>         def __unicode__(self):
>                 return self.choice
> --------------------------------------------------------------------------- 
> -------------------------------
>
> Here's my admin.py :
> -------------------------------
> from myproject.polls.models import Poll
> from myproject.polls.models import Choice
>
> from django.contrib import admin
>
> class ChoiceInline(admin.TabularInline):
>         model = Choice
>         extra = 3
>
> class PollAdmin(admin.ModelAdmin):
>         fieldsets = [
>                 (None,               {'fields': ['question']}),
>                 ('Date information', {'fields': ['pub_date'], 'classes':
> ['collapse']}),
>         ]
>         inlines = [ChoiceInline]
>         list_display = ('question', 'pub_date', 'was_published_today')
>         list_filter = ['pub_date']
>         search_fields = ['question']
>         date_hierarchy = 'pub_date'
>
> admin.site.register(Poll, PollAdmin)
> --------------------------------------------------------------------------- 
> ------------------------------
>
> I'm sure nothing happends without a reason but why ?
>
> Thanks a lot,
>
> bigshift

--

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


Reply via email to