FAQ Database Discussion Community


Is Django has something like “database middleware”?

python,django,database,middleware,django-middleware
Django has middleware to achieve do somthing when request and response. Is Django has "database middleware" to achieve do somthing when write data and read data. For example,some old database does not support to utf8mb4 , so it can't support all of emoji. If Django has "database middleware" I will...

Django: provide global method to all (class-based) views?

python,django,django-middleware,class-based-views
I need a button, included in the header of every page in my Django application, to trigger some global method, to toggle a "mode" setting in the session. There are two modes: 'preview' and 'publish'. One solution I've come up with: duplicate a post() method in every (class-based) view, to...

Please help me decipher a traceback for “ValueError: invalid literal for int()” in my models

django,django-models,django-middleware
I am trying to create a list of ProductPart objects where ProductPart.part matches the value of an instance of Variety.variety_name. Here is a demonstration of my problem. > v = Variety.objects.get(id=2) > p = ProductPart.objects.get(id=1) > v.variety_name 'Non Pareil (Inshell)' > p.part <Variety: Non Pareil (Inshell)> > a = ProductPart.objects.values().filter(part=v.variety_name)...

How to add/change django template folder on per-request basis?

django,django-templates,django-middleware
We've just started the complete redesign of our project's HTML pages (responsive layout and stuff) and all we need to change is templates and static (css and some js). Views ain't gonna change at all. I want to create all the new templates in another folder next to existing old...

Why is my middleware not setting request attributes on logout?

python,django,django-middleware
I have a piece of code that sets a request attribute when the user is visiting via my android subdomain (shown below as part of home.devices.py. This is then picked up in base.html and used to include my android-navbar.html. This works fine on all of my pages except for logout.html....