django-middleware

Browser delay with changing content of the page in django admin (caching, python/django)

馋奶兔 提交于 2019-12-06 09:29:11
I have a bit weird problem witch caching on my project in django. I can edit my page-content in django-admin. When i do that and refresh site - nothing is happening. I have to wait few minutes for changes. Funny thing is that, when i change browser (or computer) - i dont have to wait - the changes are on. Is it the problem of django, browser or what? Is it possible to set setting.py to get changes immediately? By the way, i have already figured out that when i turn the "django.middleware.cache.FetchFromCacheMiddleware" off - the problem disapears, but i dont want to turn cache off... Any ideas

Tons of false positives from Django's CSRF middleware?

烈酒焚心 提交于 2019-12-06 06:26:20
问题 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. How could I diagnose these issues? Update: I see these false positives on my production and dev sites. They happen sporadically. My site uses sub-domains and

How to implement Https(SSL Middleware) in Django

て烟熏妆下的殇ゞ 提交于 2019-12-06 05:55:20
I am a newbie in Django and web development. I want to implement Exactly this Question , but in django. I have searched many blogs and questions, nowhere was i able to find,exactly how to implement this. The SSL Middleware Django , is something i couldnt grasp very well. If that is the solution, can anyone please tell me how to implement it? Is the question clear ? or do i need to add a few things, please comment i will make the necessary changes.Any help will be highly appreciated.Thanks in advance. P.S: I have added the ssl certificate on the server. So that is taken care of. You just need

Django: Error: ImproperlyConfigured Module does not define a “ ” class

最后都变了- 提交于 2019-12-06 05:06:23
问题 ImproperlyConfigured: Middleware module "report" does not define a "ReportMiddleware" class But I had defined this, but probably defined in wrong place, so where should I place this class file? 回答1: You should put it within the module in the package as specified in the MIDDLEWARE_CLASSES setting. 回答2: Today I had the same error. It was due to confusing (at least for me) naming scheme. If you specify your middleware like so: 'yourapp.SomeMiddleware' in your settings.py and put your

Editing response content in Django middleware

给你一囗甜甜゛ 提交于 2019-12-06 03:34:35
I have Django 1.10 project and the following user-defined middleware class RequestLogMiddleWare(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): response = self.get_response(request) response.data['detail'] = 'I have been edited' return response and a REST-endpoint view: def r_mobile_call_log(request): return Response({'success': True, 'detail': 'Before having been edited'}, status=status.HTTP_200_OK) So I would expect the final response on client-side to be: {'success': 'True', 'detail': 'I have been edited'} However, what I see is: {

'WSGIRequest' object has no attribute 'session' while upgrading from django 1.3 to 1.9

荒凉一梦 提交于 2019-12-05 11:38:42
问题 Similar to this question 'WSGIRequest' object has no attribute 'session' But my MIDDLEWARE classes are in the correct order. INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.messages', 'django.contrib.staticfiles', 'membership', 'treebeard', 'haystack', 'reversion', ] MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.security.SecurityMiddleware', 'django

Django ImportError: No module named middleware

我们两清 提交于 2019-12-05 05:36:14
I am using Django version 1.8 and python 2.7. I am getting the following error after running my project. Traceback (most recent call last): File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 63, in __call__ return self.application(environ, start_response) File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 170, in __call__ self.load_middleware() File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 50, in

Django: Error: ImproperlyConfigured Module does not define a “ ” class

馋奶兔 提交于 2019-12-04 10:24:11
ImproperlyConfigured: Middleware module "report" does not define a "ReportMiddleware" class But I had defined this, but probably defined in wrong place, so where should I place this class file? You should put it within the module in the package as specified in the MIDDLEWARE_CLASSES setting. Today I had the same error. It was due to confusing (at least for me) naming scheme. If you specify your middleware like so: 'yourapp.SomeMiddleware' in your settings.py and put your SomeMiddleware class definition in SomeMiddleware.py in your application directiory your project will break. In this case

Django Error Reporting - How to know which user triggered the error?

…衆ロ難τιáo~ 提交于 2019-12-04 03:02:04
Is there a way I can customize Django error reporting so when it emails me it lets me know which user triggered the error? I'm in Django 1.2 if it matters. Much Thanks in advance! If you don't want to use sentry you can use this simple middleware to attache the user-infos to the error mail: # source: https://gist.github.com/646372 class ExceptionUserInfoMiddleware(object): """ Adds user details to request context on receiving an exception, so that they show up in the error emails. Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on top if possible). This allows it to catch

Detect the language & django locale-url

北慕城南 提交于 2019-12-03 06:10:00
问题 I want to deploy a website in english & spanish and detect the user browser language & redirect to the correct locale site. My site is www.elmalabarista.com I install django-localeurl, but I discover that the language is not correctly detected. This are my middlewares: MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'multilingual.middleware.DefaultLanguageMiddleware', 'middleware.feedburner.FeedburnerMiddleware', 'lib