hello,
I don't know if it's possible but I'd like to add few parameters at the end of the URL using middleware. Can it be done without redirect after modyfing requested URL?
ie.
user clicks: .../some_link
and middleware rewrites it to: .../some_link?par1=1&par2=2
Other way is to modify reponse and replace every HTML link but it's not ...
I have two different kinds of objects that I'd like to live under the same URL. One group of objects needs to be passed to the view function 'foo' and another group needs to be passed to 'bar'.
I'm currently doing this with a big long list of hardcoded URLs, like so...
urlpatterns = patterns('project.views',
(r'^a/$', 'foo'),
(...
For debugging purposes, I'd like a quick way (e.g. in manage.py shell) of looking up which view that will be called as a result of a specific URL being requested.
I know this is what django.core.urlresolvers.resolve does, but when having a decorator on the view function it will return that decorator.
Example:
>>>django.core.urlresolvers...
This might be an isolated problem, but figured I'd ask in case someone has thoughts on a graceful approach to address it.
Here's the setup:
--------
views.py
--------
from django.http import HttpResponse
import shortcuts
def mood_dispatcher(request):
mood = magic_function_to_guess_my_mood(request)
return HttpResponse('Please go to...
Hi, I want march a django-URL with just 2 alternatives /module/in/ or /module/out/
Actually Im using
url(r'^(?P<status>\w+[in|out])/$',
'by_status',
name='module_by-status'),
But matches with other patterns like /module/i/, /module/n/, /module/ou/; etc.
Any hint is apreciated :)
...
Hi!
I have a Django Application.
I want to have all my models to be separated in files and lay in the specific directory, for instance:
/usr/project/models/myModel.py
Is it any possible?
Just importing through from myModel import * doesn't work, unfortunately.
Is there any specific way to do this?
...
I want have have multiple filters on the data. like first i want to filter by date field and then by type field and then by some other field .... as many times as possible. i must pass on the field and value in the url and it must apply the filter and pass the data to the next filter.
...
I'm trying to add slugs to the url in my django app, much like SO does.
Currently, I have pages that work just fine with a url like this:
http://example.com/foo/123/
I'd like to add 'slugified' urls like so:
http://example.com/foo/123/foo-name-here
I can get it to work just fine, by simply modifying the urlconf and adding a throwa...
How can I reverse a url but with a different template name? I specifically have to use urlresolvers.reverse
To be more specific:
I have one view but two urls from which it could be accessed
(r'^url/$', 'view1', {'template1':'template1.html'}, 'access-url1'),
(r'^url_dynamic/$', 'view1', {'template1':'template_dynamic.html'}, 'url-dyna...
Howdy
Im still fairly new to Django, so please explain things with that in
mind.
I'm trying to create three websites using 2 subdomains and 1 domain:
for the blog, blog.mysite.com
for the forums, forums.mysite.com
for the custom web app, mysite.com
When building the custom web app, I used contrib.auth to make use of
the built-in dja...
I've got two applications located on two seperate computers on one in the urls.py file I have a line like the following:
(r'^cast/$', 'mySite.simulate.views.cast')
And that url will work for both mySite.com/cast/ and MySite.com/cast. But on the other server I have a similar url written out like:
(r'^login/$', 'mySite.myUser.views.lo...
My models:
Story:
categories = models.ManyToManyField(Category)
Category: name | slug
My urls:
(r'^(?P<cat_slug>.*)/$', 'news.views.archive_category'),
And in views, I use:
def archive_category(request, cat_slug):
entry = News.objects.get( categories__slug=cat_slug )
return render_to_response('news_archive_category.html...
A site in Vietnamese, it is virtually no different to English. However, there is a problem that is slug. When I type characters such as "ư", "ơ", "á",... Django is not identified. Solution here is to replace characters that do not sign into.
Eg:
ư -> u
ơ -> o
á -> a
One from "những-viên-kẹo" will become "nhung-vien-keo".
However,...
I have an web address:
http://www.example.com/org/companyA
I want to be able to pass CompanyA to a view using regular expressions.
This is what I have:
(r'^org/?P<company_name>\w+/$',"orgman.views.orgman")
and it doesn't match.
Ideally all URL's that look like example.com/org/X would pass x to the view.
Thanks in advance!
...
In django, when a URL is matched, the match group is passed as a second parameter to the view function, the first being a HttpRequest object. For example, with a URL patter like this
'/foo/(\d{2})/', 'app.views.handler'
the handler routine will have
def handler(request, value):
where value will contain a two digit number (as a stri...
Hate coming up with titles. I need something that'll actually capture the following:
site.com/500/ (a number as the first param)
site.com/500/ABC/ (a number and a 3 letter code)
site.com/500/ABC/DEF/ (a number and 2x 3 letter codes)
What I have been messing with:
^(\d+/)?(\w{3}/)?(\w{3}/)?$
That sort of works but includ...
I was just pondering if make two named urls the same produces any problems. I tried it and it works.
So for example, I have a view that is able to do paging:
def info(request, page_num = 1)
and I would like to call it both ways, as:
/info
/info/page/1
so I made urls like:
url(r'^info/$', 'views.info', name='info'),
url(r'^info/(?P...
Let's say I have a site where all urls are username specific.
For example /username1/points/list is a list of that user's points.
How do I grab the /username1/ portion of the url from all urls and add it as a kwarg for all views?
Alternatively, it would be great to grab the /username1/ portion and append that to the request as req...
I'm new to Django and programming in general. I'm trying to make a simple site that allows players of a sport sign up for leagues that have been created by the admin. In my models.py, I created two models:
from django.db import models
from django.forms import ModelForm
class League(models.Model):
league_name = models.CharField(max_...
Hi, I just started Django and Python, so Im still new to this..
This is my urls.py:
url(r'(?P<slug>[-\w]+)/$','person_detail'),
url(r'(?P<slug>[-\w]+)/delete/$','person_delete'),
The problem is that when I try to do to the url: slug/delete/ it's looking for that whole part slug/delete/ as the slug. When i remove the $ in the 1st url i...