Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7550625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:15:40+00:00 2026-05-30T10:15:40+00:00

I am developing a website using Django as the backend, and I want to

  • 0

I am developing a website using Django as the backend, and I want to allow the customer to add new pages using the admin interface – so he enters a page title, an page alias that is used for nicer urls, and chooses whether he wants static content or an article based structure.

My approach is the following: I have created an app called sitemanager that consists of the page model described above, and a context processor that adds the pages to the context of my templates (for menus, etc.) and this works fine.

Of course, I also need to hook it into my url-file, but here is where the trouble begins: I can, thanks to the pythonic structure of Django, retrieve the Page model within urls.py, and generate my url pattern accordingly, and it does show, but Django seems to cache that file (which makes sense usually), so changes will take place only after a server restart. This obviously is not acceptable.

My first idea would be somehow bringing the admin application to resetting the url cache if new pages are added, or deleted, or aliases are modified (and only then, because caching generally is a good thing), but I have no idea how to start there.

Or maybe there is also a simpler solution that I am not seeing at the moment?

The relevant part of my urls.py looks basically like this:

from sitemanager.models import Page
static_pages = Page.objects.filter(static=True)
article_pages = Page.objects.filter(static=False)
for page in static_pages:
    pattern = r'^/'+page.alias+'/$'
    urlpatterns += patterns('',
        url(pattern, 'views.static_page',
            { 'active': page }
        )
    )
# Pretty much the same for the article pages,
# but with includes of another app

I hope I didn’t make too many mistakes while stripping that code in my head!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:15:41+00:00Added an answer on May 30, 2026 at 10:15 am

    You can use named groups in the urls to pass data to views and it won’t require any dynamic updating in the urls. The named part containing page.alias will be simply passed as a keyword argument to your view function. You can use it to get the actual Page object.

    # urls.py
    urlpatterns += patterns('',
       (r'^(?P<page_alias>.+?)/$', 'views.static_page'),
    )
    
    # views.py
    def static_page(request, page_alias):    # page_alias holds the part of the url
        try:
            active = Page.objects.get(page_alias=page_alias)
        except Page.DoesNotExist:
            raise Http404("Page does not exist")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Django for developing a website and I want to allow my
I'm developing a website using the Django framework, and I need to retrieve Jabber
I am developing a website using Google App Engine and Django 1.0 (app-engine-patch) A
I've been developing a simple website using asp.net MVC and I'm starting to add
I'm developing a website. I'm using a single-page web-app style, so all of the
I am developing a small testing website using Django 1.2 in Aptana Studio build
I'm developing a website using php, i want to know how can i protect
I am developing a website using asp.net c# and I want to put a
I am developing a website using Asp.Net MVC framework. We need to add general
I'm developing a website by using C# 4.0. I need to add RadioButtonList TextField

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.