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 6678031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:11:41+00:00 2026-05-26T04:11:41+00:00

WIth class-based views having become MUCH better in Django, I am running into a

  • 0

WIth class-based views having become MUCH better in Django, I am running into a “best practices” problem when implementing a class based view. It basically comes down to the URL template tag.

Given a urls.py like this:

urlpatterns = patterns('some_app.views', 
    url(r'^$', 'index', name='some_app_index')
)

That tag can take either a path to a view:

{% url some_app.views.index %}

or the name of a url:

{% url some_app_index %}

Now, with a class-based url conf, one ends up with a url like this:

from some_app.views import Index

urlpatterns = patterns('', 
    url(r'^$', Index.as_view(), name='some_app_index')
)

Which means that using {% url some_app.views.index %} no longer works but {% url some_app_index %} still does. (And {% url some_app.views.Index.as_view %} doesn’t seem to be a solution).


So, my question is, what is best practice for refering to URL confs from a template?

To this point, I beleived that using the path.to.view method was better, since it was cleanly namespaced. However, with class-based views looking better and better, is using the url name a better way to go? In that case, namespacing is completely dependent on the name attribute being setup by the app developer in a way that separates the url name from other apps…

Thoughts? I couldn’t find a “do it this way” in the Django documentation but if anyone has written about this, I’d love to read it.

  • 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-26T04:11:42+00:00Added an answer on May 26, 2026 at 4:11 am

    I always use names.

    Besides the problem you mention with paths, you would also have a problem if you have two URLs pointing to the same view.

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

Sidebar

Related Questions

I've begun diving into Django again and I'm having trouble finding the parallel to
I created a view based app. In a view Controller class I created a
Assume some domain and view objects (that have no common base class) public class
i have a class based on TInterfacedObject. i add it to TTreeNode's Data property.
I'm working on a class-based php web app. I have some places where objects
I'm working on a Javascript class based on the Prototype library. This class needs
Is there a way to create an instance of a class based on the
I used the xsd.exe tool to generate a class based on my xml schema.
I'm trying to write a named scope that will order my 'Products' class based
I created a WebService using the .NET 2.0 framework, a class based on an

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.