I'm writing reusable app. And I want to deploy it several times.
Here is urls.py:
urlpatterns = patterns('',
(r'^carphotos/', include('webui.photos.urls', app_name='car-photos') ),
(r'^userphotos/', include('webui.photos.urls', app_name='profile-photos') ),)
and photos/urls.py:
urlpatterns = patterns('webui.photos.views',
url(r'^$'...
I know that I can pass object values through a URL pattern and use them in view functions. For instance:
(r'^edit/(?P<id>\w+)/', edit_entry),
can be utilized like:
def edit_entry(request, id):
if request.method == 'POST':
a=Entry.objects.get(pk=id)
form = EntryForm(request.POST, instance=a)
...
Hi all,
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 you get redirected to the login page with the next variable set when it's a existing page.
So when not logged in and asking for:
...
In my webapp, there are a lot of errors or other messages that just show a template that is very close to the URL. At the moment, I have half a dozen static mappers like this:
(r'^/message/foo/$', 'direct_to_template', {'template': 'message/foo.html'}),
(r'^/message/bar/$', 'direct_to_template', {'template': 'message/bar.html'}),
Is t...
I'm on Windows XP with the latest install of Python 2.6 (and the development server has been working up until last night). I have the path and Python path stuff all set up, and my dev server has worked forever. I recently replaced my django-trunk with a new pull from the Django trunk. I thought maybe there was an import error or somethin...
I need a regexp for a URL like:
/slug/#slug/slug/
I know it should be something like:
r'^(?P<slug1>[-\w]+)/#(?P<slug2>[-\w]+)/(?P<slug3>[-\w]+)/$'
But I am having problems with the character #
...
In rails, on can show the active routes with rake (http://guides.rubyonrails.org/routing.html):
$ rake routes
users GET /users {:controller=>"users", :action=>"index"}
formatted_users GET /users.:format {:controller=>"users", :action=>"index"}
POST /users {:controller=>"users", :action=>"cr...
I'm trying to use one app to satisfy multiple url paths. That is to say, I want the url /blog/ and /job/ to use the same app, but different views. There are a number of ways to do this I'm sure, but none of them seem very clean. Here's what I'm doing right now
# /urls.py
urlpatterns = patterns("",
(r"^(blog|job)/", include("mypro...
I'm writing a Django admin action to mass e-mail contacts. The action is defined as follows:
def email_selected(self,request,queryset):
rep_list = []
for each in queryset:
reps = CorporatePerson.objects.filter(company_id = Company.objects.get(name=each.name))
contact_reps = reps.filter(is_contact=True)
...
Hi Guys,
I must be suffering from a serious lack of sleep but I am stumped. I can't seem to figure out how to get the {% url %} directive to give me the right url. So let's start with the basics..
urls.py
from people.views import employee_detail
urlpatterns = patterns("",
url(r'/uid/(?P<id>[0-9]+)/$', employee_detail, {'templat...
In my urls.py I have:
(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/section/(?P<slug>[-\w]+)/$',
'paper.views.issue_section_detail',
{},
'paper_issue_section_detail'
),
and I'm trying to do this in a template:
{% url paper_issue_section_detail issue.pub_date.year,issue.pub_date.month,issue.pub_date.day,section_li...
What I'm trying to do:
# urls.py
urlpatterns = patterns('',
(r'^info/(?P<user>[-\w+])/(?P<app>[-\w+])/', include(%app%.urls)),
)
which should display specific information that given user entered for the app. And I want the URL scheme to stay this way. Is it even possible? I think namespaces would do the trick but official document...
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 help me to fully understand the subject either.
...
As in the title: how can I access the url hash/fragment (the part following the dash #) from a Django view and so, I suppose, from a Django Request object?
I've not found enough information on the documentation here available: http://docs.djangoproject.com/en/dev/ref/request-response/
P.S.
Suppose that the fragment part is sent to the ...
So, I have this Django application and I keep adding new features to provide ever more granular views of the data. To give a quick idea of the problem, here's a subset of urls.py:
# Simple enough . . .
(r'^$', 'index'),
(r'^date/(?P<year>\d{4})$', 'index'),
(r'^date/(?P<year>\d{4})-(?P<month>\d{2})$', 'index'),
(r'^date/(?P<year>\d{4})...
I am applying the 'url' template tag to all links in my current Django project.
I have my urls named like so...
url(r'^login/$', 'login', name='site_login'),
This allows me to access /login at my site's root. I have my template tag defined like so...
<a href="{% url site_login %}">
It works fine, except that Django automatically ...
Hello,
Assume I have 3 Models: City, Area, Entry.
Each city has several Areas and each area can have several entries BUT for "now", there can be will be only one active Entry and it will be shown. So in logic:
Note that each city, area, entry will be using slug variable of related model class
Format will be in such:
www.mysite.com/<...
I'm having an issue where a call to the url template tag in Django is appending the site name (I don't want it in there.)
Let's say that the site name is 'mysite'.
So for example:
<a href="{% url myapp.views.myview "myparam" %}">Link text</a>
is producing:
<a href="/mysite/foo/bar">Link text</a>
when I want it to produce:
<a hre...
Where do I put python files to be redirected to by urls.py in Django? The tutorial showed something like this:
urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
Where do I set up pages to be easily linked as something.something.page like this? I am currently just trying to drop straight .py files in random...
Django has excellent URLConf and URL reverse mapping/matching. I'm looking for a tip/trick to add arbitrary extensions to URLs generated by Django. Sometimes it's nice to see extensions that suggest your brand.
...