Tagged Questions
44
votes
7answers
27k views
Getting Django admin url for an object
Before Django 1.0 there was an easy way to get the admin url of an object, and I had written a small filter that I'd use like this: <a href="{{ object|admin_url }}" .... > ... </a>
...
19
votes
4answers
8k views
How do you use Django URL namespaces?
I'm trying to get the hang of Django URL namespaces. But I can't find any examples or documentation.
Here is what I have tried.
urls.py:
from django.conf.urls.defaults import *
urlpatterns = ...
17
votes
3answers
3k views
Anyone knows good Django URL namespaces tutorial?
I'm looking for a good tutorial for URL namespaces in Django. I find official documentation a little too sparse - it lacks good examples. I found similar question here on stack, but the answers didn't ...
15
votes
1answer
1k views
Override default get_absolute_url on User objects?
I'm trying to make a generic table for listing django_tables objects. I've got everything working, except that the get_absolute_urls() on my User objects returns:
/users/<username>/
While I ...
13
votes
1answer
1k views
My Django URLs not picking up dashes
Im trying to work out a url that will match domain.com\about-us\ & domain.com\home\
I have a url regex:
^(?P<page>\w+)/$
but it won't match the url with the - in it.
I've tried
...
13
votes
2answers
2k views
How to do reverse URL search in Django namespaced reusable application
Consider that I include namespaced reusable application:
urlpatterns = patterns('',
# ella urls
url('^ella/', include('ella.core.urls', namespace="ella")),
)
Now, the Ella applications has ...
12
votes
4answers
3k views
No module named backends.default.urls
So I've installed django-registration through easy_install. I'm following a quick start guide and I'm trying to setup my urlConf, however it says module named backends.defauls.urls is not found. What ...
12
votes
4answers
6k views
How does one put a link / url to the web-site's home page in Django?
In Django templates, is there a variable in the context (e.g. {{ BASE_URL }}, {{ ROOT_URL }}, or {{ MEDIA_URL }} that one can use to link to the "home" url of a project?
I.e. if Django is running in ...
12
votes
3answers
2k views
Django: Arbitrary number of unnamed urls.py parameters
I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have ...
11
votes
3answers
4k views
Passing variable urlname to url tag in django template
What I'd like to do (for a recent changes 'widget' - not a django widget in this case) is pass a urlname into my template as a variable, then use it like so: {% url sitechangeobject.urlname %} Where ...
11
votes
4answers
13k views
Django: get URL of current page, including parameters, in a template
Is there a way to get the current page URL and all its parameters in a Django template?
For example, a templatetag that would print full URL like /foo/bar?param=1&baz=2
11
votes
1answer
4k views
Making a Regex Django URL Token Optional
You have a URL which accepts a first_name and last_name in Django:
('^(?P<first_name>[a-zA-Z]+)/(?P<last_name>[a-zA-Z]+)/$','some_method'),
How would you include the OPTIONAL URL token ...
10
votes
2answers
2k views
How do I redirect in Django with context?
I have a view that validates and saves a form. After the form is saved, I'd like redirect back to a list_object view with a success message "form for customer xyz was successfully updated..."
...
10
votes
4answers
1k views
Django url debugger
I'm developing a django application and over time, the URLs have grown. I have a lot of them with me now and due to some change I made, one view started to malfunction. When I try to GET ...
10
votes
1answer
576 views
Django: information leakage problem when using @login_required and setting LOGIN_URL
I found a form of information leakage when using the @login_required decorator and setting the LOGIN_URL variable.
I have a site that requires a mandatory login for all content. The problem is that ...