django-urls

django url scheme in apache and dev server

I have a a django application which is being served from apache/mod_wsgi under www.mysite.com/mysite suppose I redirect url "myapp" -> myapp/urls.py so to visit it from apache I will visit www.mysite.com/mysite/myapp/page1 to visit it from dev server I will need to visit www.mysite.com/myapp/page1 it also means absolute URLs wil be di...

Django Filtering Problem

I'm trying to set up a filter query in one of my views...basically my code looks as below: def inventory(request): vehicle = Vehicle.objects.all().exclude(status__status='Incoming').order_by('common_vehicle__series__model__manufacturer__manufacturer', 'common_vehicle__series__model__model', 'common_vehicle__year') year_count =...

url template tag in django template

guys: I was trying to use the url template tag in django, but no lucky, I defined my urls.py like this urlpatterns = patterns('', url(r'^analyse/$', views.home, name="home"), url(r'^analyse/index.html', views.index, name="index"), url(r'...

Reverse Django generic view, post_save_redirect; error 'included urlconf doesnt have any patterns'

I did see the other question titled 'how to use django reverse a generic view' and 'django named urls, generic views' however my question is a little different and I do not believe it is a dupe. Code: from django.views.generic import list_detail, create_update from django.core.urlresolvers import reverse from django.conf.urls.defaults ...

how can add resource data (CommonUIString.---) to a class

hello. would someone in here be so kind to explain to me how I can add resources to a selected class when I have that/those specific resource(s) in the project already?? An example would have been that of CodePlex.SharePointInstaller, where we have for many of the conrol classes thier respective resources (sometimes double?). many thank...

How to customize the URL of Date-based generic views?

Here is my URL pattern: news_info_month_dict = { 'queryset': Entry.published.filter(is_published=True), 'date_field': 'pub_date', 'month_format': '%m', } and (r'^(?P<category>[-\w]+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+).html$', 'object_detail', news_info_month_dict, 'news_detail'), But t...

Django's list_details views saving queryset to memory (not updating)?

I have a custom model manager that looks like this: class MyManager(models.Manager) def get_query_set(self): '''Only get items that are 'approved' and have a `pub_date` that is in the past. Ignore the rest.''' queryset = super(MyManager, self).get_query_set() queryset = queryset.filter(status__in=('a...

Dynamic SEO-friendly URLs

I'd like to deploy dynamic URL's for my app in two ways: when viewing available vehicle, I get a link like: http://www.url.com/2006-Acura-MDX-Technology-Package I also have a filter page, so here, the URL will change according to the filters selected like: http://www.url.com/2007-Nissan or http://www.url.com/2007-Nissan-Maxima and so o...

Pass session data onto URL

I have some information that is set in the sessions, and I was wondering if it's possible to pass this info onto the URL for the view that uses this session data. I want this to be working in such a way that if the user bookmarks the page from that view, the session data is used to pass the variables onto the view. How can I do this? I...

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 = patterns('', (r'^foo/', include('sub_urls', namespace='foo', app_name='foo')), (r'^bar/', include('sub_urls', namespace='bar', app_name=...

Django: What is the difference b/w HttpResponse vs HttpResponseRedirect vs render_to_response

The above mentioned things are giving me almost the same results was wondering whats the main difference in them. ...

Django DRY URLs for Model access

Reader's Digest version: How do I get data (either single row if specified or full table) from a model by taking a URL argument of the model's name without hardcoding the URLconfs to match each model? For more details, read on: I'm making an app that has three models, and I want to make a simple view that takes a name of a model, and sp...

Django Dynamic menu design question

Hi, I want to create dynamic menus according to user permissions. As was already discussed here and by the the documentation itself, I know that I can achieve this in the templates using the following snippet: {% if perms.polls.can_vote %} <li> <a href="/polls/vote">Vote</a> </li> {% endif %} But the problem is that f...

Django redirect to an swf

Hi, I'm trying to redirect to a swf file because I need to embedd that in a fb:swf which wants its absolute path. When I handle the swf in url's somehow it doesn't work. In url.py (r'^flash/','lastproject.yofacebook.flashtest.flash'), In flahstest.flash def flash(request): return render_to_response('as3.swf') I want to open the ...

problem serving static files to sub directories

In the development environment, static files are served properly as long as the url pattern is limited to one directory. Sub directories lose the css. For example the css processes for the template attached to the following url: //localhost:8000/create/ however this: //localhost:8000/edit/2/ will not provide the css even if i...

{% url admin:index %} generating wrong urls

Hi All, My django site is served up with the following in Apache's config: WSGIScriptAlias /studio /django/studio/bin/django.wsgi My urls.py looks like: urlpatterns += patterns( 'django.contrib', (r'^admin/', include(admin.site.urls)), (r'^accounts/login/$', 'auth.views.login'), (r'^accounts/logout/$', 'auth.views.lo...

Problem with django's url template tag (and reverse() function)

I have the following view function in activities.views: def activity_thumbnail(request, id): pass I'm trying to get the URL for that view in one of my templates. When I try the following: {% url activities.views.activity_thumbnail latest_activity.id %} I get the following error: Caught an exception while rendering: Reverse ...

Implementing a site prefix across all apps.

I'm in the middle of developing an app on Google's App Engine, and one of the features is auth via Facebook Connect. I've got everything set up and working up to a certain level, but in order to test it against my dev machine, I've created a reverse proxy on one of my public facing servers that proxies through to the dev machine. It all...

Django, Truncated incorrect DOUBLE value:

Hi guys, i have this error: Truncated incorrect DOUBLE value: 'asinox' this error come from my SEO url: http://127.0.0.1:8000/user/asinox/2010/dec/30/1/este-pantalon-lo-compre-en-plaza-lama-una-aperidad/ "asinox" is the username (usuario), and routing the URL in this way: (r'^(?P<usuario>[-\w]+)/(?P<year>\d{4})/(?P<month>\w{3})/(?...

Decoupling django apps 2 - how to get object information from a slug in the URL

I am trying to de-couple two apps: Locations - app containing details about some location (town, country, place etc) Directory - app containing details of places of interest (shop, railway station, pub, etc) - all categorised. Both locations.Location and directory.Item contain lat/lng coords and I can find items within a certain dist...