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

  • Home
  • SEARCH
  • 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 9163369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:25:51+00:00 2026-06-17T14:25:51+00:00

I have an online documentation Django app that has a base URI: /path/to/docs/<DOMAIN>/ This

  • 0

I have an online documentation Django app that has a base URI:

/path/to/docs/<DOMAIN>/

This allows you to see a list of docs within that DOMAIN. It uses the GCBV ListView. You can request the DetailView of a DOCNAME by using the following:

/path/to/docs/<DOMAIN>/<SLUG>/

where SLUG is pretty self explanatory and returns one record as a good slug should. There are child pages to these, with their own templates, along the lines of:

/path/to/docs/<DOMAIN>/<SLUG>/foo/
/path/to/docs/<DOMAIN>/<SLUG>/bar/
/path/to/docs/<DOMAIN>/<SLUG>/baz/

This is simple in the case of unversioned docs. However, in another DOMAIN (lets call it “federated”) I do have different versions of the DOCNAMEs available:

/path/to/docs/<DOMAIN>/<SLUG>/<VERSION>/

and

/path/to/docs/<DOMAIN>/<SLUG>/<VERSION>/foo/
/path/to/docs/<DOMAIN>/<SLUG>/<VERSION>/bar/
/path/to/docs/<DOMAIN>/<SLUG>/<VERSION>//baz/

In this case, if a user requests:

/path/to/docs/<DOMAIN>/<SLUG>/

I don’t want the user to be presented with a DetailView – I want them to be presented with a ListView of each of the VERSIONs that have documentation available:

Fantastic docs - Version 1 (/path/to/docs/federated/fantastic/1/)
Fantastic docs - Version 2 (/path/to/docs/federated/fantastic/2/)
Fantastic docs - Version 3 (/path/to/docs/federated/fantastic/3/)

I have done some pretty extensive reading on GCBV and subclassed many of them before in different apps, but I have the suspicion that I can’t have a single entry in urls.py to handle both these types of queries (Detail and ListView). Indeed, Django docs warns about mixing GCBV, especially w.r.t. get_context_data().

What I can do internal to my Mixin is look at the DOMAIN name, and on that basis, fork the request off to either a ListView (for versioned docs) or a DetailView (for non-versioned docs). I have searched all over the Django docs, and don’t see any examples of this. Can anyone help me out?

Note:
One thought does occur to me: In urls.py I could actually hard-code the DOMAIN name in the pattern. So instead of using the kwarg <domain>:

urlpatterns = patterns('',
    url(r'^(?P<domain>[\w-]+)/(?P<slug>[\w-]+)/(?P<version>\d{1})/$', MyMixin.as_view(
            queryset=Docs.objects.all()
        ),
    )),
) 

and using the domain kwarg as a logic determiner (to an if/else) in the view, I could do something like:

urlpatterns = patterns('',
    url(r'^federated/(?P<slug>[\w-]+)/(?P<version>\d{1})/$', MyListViewMixin.as_view(
            queryset=Docs.objects.all()
        ),
    )),
    url(r'^nonfederated/(?P<slug>[\w-]+)/$', MyDetailViewMixin.as_view(
            queryset=Docs.objects.all()
        ),
    )),
)

However, I don’t know how many documents DOMAINs are going to be versioned, and how many won’t. I need to be as generic as possible (excuse the pun). Thanks in advance.

  • 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-06-17T14:25:52+00:00Added an answer on June 17, 2026 at 2:25 pm

    Instead of mixing ListView and DetailView into one view (which would conceptually be a mess and difficult to maintain), I suggest designing all your views as if they were versioned and treating the unversioned ones as those with version 1 (or a similar unspecified version number).

    In the unfederated websites, the URL /path/to/docs/<DOMAIN>/<SLUG>/ would behave the same as visiting /path/to/docs/<DOMAIN>/1/<SLUG>/.

    In the federated websites, the URL /path/to/docs/<DOMAIN>/<SLUG>/ would present a list of the available versions (as a ListView).

    You can implement the above behaviour with a view that does the following:

    • Check how many versions there are available for this domain
    • If there is only one, redirect to /path/to/docs/<DOMAIN>/<LATEST_VERSION>/<SLUG>/.
    • If there are multiple, display a list of the available versions and let the user choose which one to visit.

    The unfederated websites would simply be websites that only have one version of the docs. If this changes in the future then you can easily turn them into versioned docs as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find an online documentation for SQLite2. The project I have
I have been looking online to find documentation for the function in QTP and
I have looked online and i havent been able to fix a problem that
I have searched online for a solution, but have yet to find one that
The online documentation for hgsubversion sucks, IMO (I hate to say that). I've been
I have skimmed the online documentation, read the wiki entry, the posts and the
This is my very first attempt at including ads in my app. I have
This seems super basic, but I'm having trouble finding documentation online to explain it.
django nonrel's documentation states: you have to manually write code for merging the results
I have a SQL Server 2008 database that contains DateTimeOffset objects. As per this

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.