Hi,

I'm trying to put a site together for a local charity. I'd like them
to be able to add new pages to the primary and secondary navigation
from the admin site and, importantly, I want them to be able to
specify what secondary pages belong to which primary pages.

I'm trying to do this with object list and object detail views - where
the list would serve up primary navigation pages and the detail their
sub-pages.

I'm trying to set up URLs to reflect this hierarchical structure but I
just can't get my head round it and I can't find anything in the
documentation that covers what I'm trying to do - which makes me think
I'm trying to do the wrong thing.

My models include:

class Category(models.Model):
    title = models.CharField(max_length=250, help_text='Maximum 250
characters')
    slug = models.SlugField(unique=True, help_text = 'Suggested slug
automatically generated from title. Must be unique')
    description = models.TextField()
    sort_index = models.IntegerField(unique=True,
help_text='Determines the order in which pages appear in the site
navigation (lowest to highest)')

This generates the primary navigation pages. The solution I came up
with for letting someone choose what primary navigation category an
entry appeared under was to include:

    navigation_parent = models.ForeignKey(Category)
...
    def get_absolute_url(self):
        return '/%s/%s/' %  (self.navigation_parent, self.slug)

in the entry model.

I want my URLconf to be able to get the right page by catching the
category and the entry slug. I thought something like:

info_dict = { 'queryset': Entry.objects.all(), 'extra_context':
{ 'top_nav': Category.objects.order_by('sort_index') }, }
...
    (r'^(?P<parent>[-\w]+)/(?P<slug>[-\w]+)/$', 'object_detail',
info_dict),

would work, but it doesn't. Ultimately, I also want to build sub-
navigation by listing all entries that share a navigation parent in
the page.

Please let me know if I'm going about this the wrong way, or if I
haven't included enough detail or am unclear, and I will update
accordingly.

Thanks

-- 
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