django-urls

django getting the absolute path of a FileField

Hello I am trying to retrieve the absolute path (starting with http://) while calling a FileField at the template. How can I achieve this ? ie: {{fl.uploadedfile}} -> returns relative path like media/uploads/ while I want http://www.blabla.com/media/uploads/ Cheers ...

Django: How can you get the current URL tagname (for pagination)?

I'm trying to do pagination with the page parameter in the URL (instead of the GET parameter). I also want my pagination to be shared code across multiple different templates. Given that, I think I need to do something like this : urls.py: url(r'^alias/page;(?P<page>[0-9]+)/(?P<id>.*)$', alias.get, name="alias"), tempaltes/alias.htm...

Django - Following a foriegn key relationship (i.e JOIN in SQL)

Busy playing with django, but one thing seems to be tripping me up is following a foreign key relationship. Now, I have a ton of experience in writing SQL, so i could prob. return the result if the ORM was not there. Basically this is the SQL query i want returned Select table1.id table1.text table1.user table2.user_name tab...

Admin, two links to different views ?

Hi guys, in django admin the views that show the register's just have a link to "edit", but what happen if a need an extra(S) links to another views? for example: i have view that show the list of registered People, the nick is linking to the Edit page (the normal way of Django), but i need another links that will show me the "arti...

TypeError when passing dictionary arguments to a view through urls.py

I'm trying to pass keyword arguments to a Django view using a dictionary, but I keep running into a TypeError when I try to access the URL (The error is: "add_business_contact() got an unexpected keyword argument 'info_models'"). The code is: urlpatterns = patterns('business.views', # ... url(r'^(?P<business_id>[\w\._-]+)/edit_c...

Django : How can I see a list of urlpatterns?

How can I see the current urlpatterns that "reverse" is looking in? I'm calling reverse in a view with an argument that I think should work, but doesn't. Any way I can check what's there and why my pattern isn't? ...

Raise 404 and continue the URL chain

I've got a URLs pattern like this: urlpatterns = ( url(r'^$', list_titles, name='list'), url(r'^(?P<tag>[a-z\-0-9]+?)/$', list_titles, name='filtered-list'), url(r'^(?P<title>\S+?)/$', show_title, name='title'), ) The filtered-list and title match the same things. If there is is a available list of things matching the tag...

Django URL.py and the index

Hi guys, i want to know, what is the best way to write in the URL.py, im asking bcz im trying to get the index in this way "www.example.com" with (r'',index) but when i try r'' all pages in the website are going to the home pages. part of my code url.py : (r'^index',homepages), (r'',homepages), Thanks :) ...

Can't use Django's get_absolute_url in dictionary of dictionaries?

I'm having some trouble using get_absolute_url in a template. It seems to work fine if I just pass in one of my store objects and say {{ store.get_absolute_url }}, but if I have to iterate through a dictionary of stores and then use the get_absolute_url function, it returns nothing. Exactly what I'm doing is below: class Store(Ethical...

How do I decipher a dynamic URL magic in Django

url(r'^([a-zA-Z0-9/_-]+):p:(?P<sku>[a-zA-Z0-9_-]+)/$', 'product_display', name='product_display'), url(r'^(?P<path>[a-zA-Z0-9/_-]+)$', 'collection_display', name='collection_display'), That's my current regex: My problem is this: I want to be able to match the product_display's regex without using :p: in the regex. I can do this by pu...

How do I form a URL in Django for what I'm doing

Desperate, please help. Will work for food :) I want to be able to have pages at the following URLs, and I want to be able to look them up by their URL (ie, If somebody goes to a certain URL, I want to be able to check for a page there). mysite.com/somepage/somesubpage/somesubsubpage/ mysite.com/somepage/somesubpage/anothersubpage/ my...

Django and Nginx try_files problem for site root page

I use such Nginx configuration for the domain: server_name_in_redirect off; listen 80; server_name ~^(www\.)?(.+)$; root /var/www/$2/htdocs; location / { try_files $uri $uri/ $uri/index.htm @django; index index.html index.htm; } location @django { fastcgi_pass 127.0.0.1:8801; fastcgi_param PATH_I...

Django admin, custom view error : invalid literal for int() with base 10

I'm trying to make a custom view in Django admin. I'm reading from this site, Simple Django Admin Preview, but I have a problem: ValueError: invalid literal for int() with base 10: '13/preview' Here is my url.py: url(r'^admin/diligencias/diligencia/(?P<object_id>\d+)/preview/$','preview'), Here is my view.py: @staff_member_require...

what may cause a Page Not Found error in flatpages?

Hello all, I just setup django's flatpages app following http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/ Everything is fine, but when i link to a flatpage, i always get: Page not found (404) Request Method: GET Request URL: http://example.com/about/ [..] The current URL, about/, didn't match any of these. what ...

detect the HOST domain name in django models

Hi folks! In my model, I want to use the domain name (HOST) I'm using in my views. In views that'd be doable, thanks to the "request" object. But how do I do this models methods? Which don't use "HttpRequest" objects? Now I'm setting a global value HOST in settings.py and using it, but that's ugly. Also, I don't really want to manag...

Django newbie - NoReverseMatch errors

Just started with Django but hit a bit of a wall - I decided to experiment with writing a simple blog engine while referring to the django-basic-apps library. In blog/urls.py, I have this entry to map to the actual post by date, e.g. blog/2009/aug/01/test-post urlpatterns = patterns('', url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<d...

Django Categories with Subcategories, and urls

Hi guys, im trying to make Categories and Subcategories, im checking this models but i have this error: Truncated incorrect DOUBLE value: 'nacionales' where the "nacionales" is the parent Category, i know that my problem maybe are in the urls.py, but the true, i dont know how set the urls for this case... my model.py: # from ... cla...

Django URL conf and view for retrieving multiple "tags" dynamically

In Django, I'm trying to write a URLconf and view that can take a theoretically unlimited number of "tags". The reason for this is to retrieve objects that have been tagged with different combinations of tags. For example, URLs like this are desireable: /topics/tag1/tag2/tag3 The above URL would retrieve "topics" that have been tagge...

Django Comment, append symbol to the url comment?

Hi guys, im using the comment system, now, i would like to re-write the segment form the url comment and append a symbol #, i want to move the page seccion to the comment list exactly to the last comment user with <a name=#{{comment.id}}?> username </a> Im using next for redirect the usen when the comment was posted: {% get_comment_for...

Django's HttpResponseRedirect seems to strip off my subdomain?

Whenever my django site calls "HttpResponseRedirect" in a view object to redirect to another url it strips off the sub-domain and goes back to the main site. I'm working off of the SVN branch of Django. Here is the example: #Request comes in as https://sub1.mydomain.com def view(request): return HttpResponseRedirect("/test_url") #T...