django-urls

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 of title, without creating any new lines. What I mean by this is, in an ideal scenario: #A regex constant OP_REGEX = r'THIS IS OPTIONAL<title>[a-z]' #...

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 could create this URL, it doesn't match with the rest of the site layout, so I'm looking for another way to do this. Is there a way to override ...

Django URL configuration

Hello, I have a purchase page, it can take an optional argument as a gift, if it is a gift, the view passes a gift form to the template and if not, a regular purchase form. my old regular url, which redirects to two seperate views: (r'^(?P<item>[-\w]+)/purchase/$', 'purchase_view'), (r'^(?P<item>[-\w]+)/purchase/gift$', 'gift_view'), ...

URL is changing, output - not! (django)

Hi! I'm new to django, so quetions may be a bit stupid... I've deploy my project on VDS with nginx+fastcgi. On dev server everything was OK, but on VDS every URL outputs the main page (pattern '^$'), even those, which not described in urls.py and may out 404. What is the problem? ...

View referenced by two urls and url tag

I am using url tag in my template for a view, that is used by two different urls. I am getting the wrong url in one place. Is there any way to force django to retrieve different url? Why it doesn't notify my, that such conflict occured and it doesn't know what to do (since python zen says, that is should refuse temptation to guess). Cod...

Django URLs - How to pass a list of items via clean URLs?

Hi all, I need to implement a structure similar to this: example.com/folder1/folder2/folder3/../view (there can be other things at the end instead of "view") The depth of this structure is not known, and there can be a folder buried deep inside the tree. It is essential to get this exact URL pattern, i.e. I cannot just go for example.c...

Django url.py Different view functions with the same regex name pattern

I'm filtering a few categories (cat1, cat2, cat3) to be rendered by different views then all the rest by other view functions. It is getting unwieldy to keep adding category slugs to the urlpatterns each time one is added. Can I factor that part out of the regex some how? urlpatterns = patterns('catalog.category_views', (r'^(?P<ca...

Django function that passes variables to other functions

I have the following 4 lines of code that I keep reusing in my django views. I would like a function that passes the final value (All the objects of a logged in user) to my other functions and how to call that. As a fix, I have to keep using this lines in all my functions. sessionkey = request.session.session_key session = Session.objec...

Django filtering links and long words at once

Is there a method one can filter output string in two ways at once: divide long words into parts (but not like in truncate where the truncated part is not visible, but it should be separated with let's say empty space) change text links into clickable links Let's say we have string like this : "IamareallylongwordandsoIneedToBeSplit ...

Django admin fails when using includes in urlpatterns

I am trying to refactor out my application a little bit to keep it from getting too unwieldily. So I started to move some of the urlpatterns out to sub files as the documentation proposes. Besides that fact that it just doesn't seem to be working (the items are not being rerouted) but when I go to the admin, it says that 'urlpatterns h...

Error in Django set up

How can I set up Django in Window Xp and Ubuntu OS I finished the step for connection with Database and some problem with connect to admin.. I do it from reading ebook and do it..So there is any easy steps for me.. Please share all idea. ...

Extending Django-tagging, adding extra field to each tag?

heya, We're coding together a Django app to handle reviews of newspaper articles. Each newspaper article model will an arbitrary number of tags associated with it. Also, each tag will have an optional ranking (0 to 10). I was thinking of using django-tagging to do this (http://code.google.com/p/django-tagging/), but I'm not sure of th...

Django: Finding part of a view's URL using {% url %}

I'm having trouble getting only a part of an URL with the {% url %} tag. The URL setup contains this: url("^delete/(?P<uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$", deleteView, name = "delete"), which means to delete an item by its UUID (the view takes a parameter "uuid" as you can see). As I don't wa...

django urlconf or .htaccess trouble

Hello I am running my django project from subfolder of a website. Lets say the address where my project is meant to open from is. http://example.com/myproject/ the myproject folder is root folder for my user account. In that folder i have fcgi script that starts my project. The .htaccess file in the folder contains this: RewriteEngi...

Django url tag multiple parameters

I have two similar codes. The first one works as expected. urlpatterns = patterns('', (r'^(?P<n1>\d)/test/', test), (r'', test2), {% url testapp.views.test n1=5 %} But adding the second parameter makes the result return empty string. urlpatterns = patterns('', (...

django cross-site reverse a url

I have a similar question than django cross-site reverse. But i think I can't apply the same solution. I'm creating an app that lets the users create their own site. After completing the signup form the user should be redirected to his site's new post form. Something along this lines: new_post_url = 'http://%s.domain:9292/mana...

Django: reverse lookup URL of feeds?

I am having trouble doing a reverse URL lookup for Django-generated feeds. I have the following setup in urls.py: feeds = { 'latest': LatestEntries, } urlpatterns = patterns('', # ... # enable feeds (RSS) url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}, name='feeds_vie...

problem in decoupling urls.py , while following a tutorial of django

http://docs.djangoproject.com/en/dev/intro/tutorial03/ I was at the step Decoupling the URLconfs where the tutorial illustrates how to decouple urls.py. On doing exactly what it says, i get the following error- error at /polls/1/ nothing to repeat Request Method: GET Request URL: http://localhost:8000/polls/1/ Exception Type: error ...

Can a WordPress blog pull content from Django pages?

Say you have a WordPress theme you like, but want to make use of a bunch of Django code that's already written. Is there a good and easy, and performant way, of sucking in HTML that is output from Django and displaying it inline in a WordPress posting, or page without using browser frames? Any good examples of this? ...

Pass a captured named regular expression to URL dictionary in generic view

I am working with a generic view in Django. I want to capture a named group parameter in the URL and pass the value to the URL pattern dictionary. For example, in the URLConf below, I want to capture the parent_slug value in the URL and pass it to the queryset dictionary value like so: urlpatterns = patterns('django.views.generic.list...