I've made a Django site, but I've drank the Koolaid and I want to make an IPhone version. After putting much thought into I've come up with two options:
Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.
Find some time of middleware that reads the user-agent, and changes the templa...
Im using the appengine webapp framework (link). Is it possible to add Django middleware? I cant find any examples. Im currently trying to get the firepython middleware to work (link).
...
I'm new, and confused. I want to create a module that keeps track of the "top hit" instances of both an article and a blog model. I don't want to touch the code for the article or blog models. Is this a candidate for middleware? looking at the HttpRequest.path?
Thanks
...
I am using django-voting as a voting application for two of my models. Those both models have fields "author".
How can I restrict a user from voting on a model that has this particular user set as it's author without modifying django-voting app?
Django middleware is the first thing that comes to my mind, but I don't understand it's "pr...
Hi all,
I want to use some middleware I wrote across the whole of my site (large # of pages, so I chose not to use decorators as I wanted to use the code for all pages). Only issue is that I don't want to use the middleware for the admin code, and it seems to be active on them.
Is there any way I can configure the settings.py or urls.p...
Hi,
Somehow the values for in the Cookie change at every request.
As I'm using the auth and session middleware (which add the Vary: Cookie header). I'm not able to cache the pages.
Any hints how I can change this behaviour?
...
I've got a small snippet that I want in my sidebar. The snippet will be visible on each page, and while cheap to fetch (about 50ms on my super-slow netbook!), will change so infrequently that I'd quite like to cache it (partly because I've yet to use Django's cache framework, and I'd like to learn).
I'm not sure what the best way to go ...
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'm getting tons of false positives from Django's contrib CSRF middleware. Just from normal use of the site there will be a lot of cases where the CSRF just starts blocking requests as suspected forgery attacks.
Does anyone else have issues like this? I'm using the SVN branch of Django so have the latest version of the CSRF middleware...
I want to deploy a website in english & spanish and detect the user browser languaje & redirect to the correct locale site.
My site is www.elmalabarista.com
I install django-localeurl, but I discover that the languaje is not correctly detected.
This are my middlewares:
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.Se...
I have an app that uses django.contrib.auth but makes no use of Django's built-in permissions system. Instead, views have the @login_required decorator and then check which group the user belongs to, and follow different branches of code execution within the view depending on the group.
A user can belong to only one group.
Checking for...
Can I use a middleware to preserve several user selected choices in between page requests?
I have several values, namely vehicle year, make, model, series, style, color, and transmission. I want to have the user being able to select a choice while keeping the previously selected choice active. I do not want to use sessions for this a...
I received strange broken link report:
Subject: Broken link on googleads.g.doubleclick.net
Referrer: (url on **my** site!)
Requested URL: /pagead/ads?(...)
User agent: (...)
IP address: (some foreign country)
So I took a look at CommonMiddleware, responsible for sending those reports.
It goes like this (Django 1.1 license apply here...
I think that is the right way to ask it. I'm wondering which parts of the code execute first, second, etc.
My assumption would be, but I don't know:
Request
Middleware
View
Model
Middleware
Response
The reason I'm asking is because I want something to happen dynamicall in the Model based on a request variable and I'm trying to devic...
Let's say I have a view:
def pony_view(request, arg1, arg2):
... Make ponies, etc ...
And a middleware:
class MyMiddleware(object):
def process_request(request):
# How do I access arg1, arg2 here?
Of course arg1, and arg2 will be passed in via URL params with urls.py.
The reason I need to do this is because I want ...
Django internationalization allows me to set a language code either in settings file (site-wide) or on per-user / per-session basis.
How can I change language for a particular page?
I wrote a middleware that sets request.LANGUAGE_CODE the way I want it to be translated, but nothing seems to use this attribute to do the selected transla...
I am creating multisites platform. Anybody can make simple site, with my platform. I plan to use django multidb support. One db for one site. And i need to change db settings depending on request.get_host().
I think that i's not good idea. Prompt other decisions? How it is realised on various designers of sites?
...
I'd like to have these lines of code executed on server startup (both development and production):
from django.core import management
management.call_command('syncdb', interactive=False)
Putting it in settings.py doesn't work, as it requires the settings to be loaded already.
Putting them in a view and accessing that view externally ...
In Django there is a settings file that defines the middleware to be run on each request. This middleware setting is global. Is there a way to specify a set of middleware on a per-view basis? I want to have specific urls use a set of middleware different from the global set.
...
I'm saving an user's default language in his user profile and on login I want to set the admin's default language to it.
One possibility I was thinking of is using a middleware, but I think if I do it on process_request I will not see an user object there since this is processed AFTER the middleware, so I could only set it after the n...