Conditional Django Middleware (or how to exclude the Admin System)

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...

How to define two fields "unique" as couple

Is there a way to define a couple of fields as unique in Django? I have a table of volumes (of journals) and I don't want more then one volume number for the same journal. class...

scoped_session(sessionmaker()) or plain sessionmaker() in sqlalchemy?

I am using SQlAlchemy in my web project. What should I use - scoped_session(sessionmaker()) or plain sessionmaker() - and why? Or should I use something else? ## model.py from sqlalchemy import...

Django startswith on fields

let's say that I have an Address model with a postcode field. I can lookup addresses with postcode starting with "123" with this line: Address.objects.filter(postcode__startswith="123") Now, I...

Can Wordpress be replaced by a Framework like Django or Ruby on Rails?

I consider myself a well trained WordPress template developer, and i recently started to read books and documents about web app frameworks, particularly Django and Ruby on Rails. I didn't know any...

Django REST Framework different depth for POST/PUT?

I am using Django REST Framework to create an API for my web app. I have a class 'Comment', that has depth=2 set in the Meta class. This works great when GETing the Comments. When I try to send a...

How to Create a form from a json-schema?

How to create form from JSON Schema? I am writing code in JavaScript and jquery. With this template part like Form I am creating this with haml and adding this in js file. For backend I am using...

How to filter objects for count annotation in Django?

Consider simple Django models Event and Participant: class Event(models.Model): title = models.CharField(max_length=100) class Participant(models.Model): event = models.ForeignKey(Event,...

Django runserver error: unsupported operand type(s) for +=: 'NoneType' and 'str'

I'm running a local dev project made with Django. But I cannot have the dev server to start: (Gaia_database_env)FakeComputer:gaia_database_proj FakeUser$ python manage.py runserver Traceback (most...

How to aggregate (min/max etc.) over Django JSONField data?

I'm using Django 1.9 with its built-in JSONField and Postgres 9.4. In my model's attrs json field I store objects with some values, including numbers. And I need to aggregate over them to find...

How to check (in template) if user belongs to a group

How to check in template whether user belongs to some group? It is possible in a view which is generating the template but what if I want to check this in base.html which is an extending template...

Why choice field displays keys instead of values in django queryset?

I have a Choice Field in my models.py models.py STATUS = ( ('closed_issue', 'Closed Issue'), ('open_ssue', 'Open Issue'), ('pending', 'Pending'), ) class Issue(models.Model): name...

best way to send files to GCS with Django

what is the best way to send files to Google cloud storage with django. this moment I'm getting the file with a post method file = request.FILES['image'] but when I try to send to GCS from...

Does django hits the database when you request for an object's attribute from a cached query?

I'm having trouble to understand how to properly use the Caches Framework. lets say I have this code: class Book(models.Model): title = models.CharField() author =...

error http status code must be an integer,

I'm trying to serialize my views, and I get this error about http status code must be an integer, I don't see where is the data that must be integer and is passed as string. I will thankful for...

Django form FileField error 'This Field is required'

I am receiving a This field is required error using a form view that django is generating. I have a Scan model that looks like: class Scan(models.Model): device = models.ForeignKey(Device,...

PostgreSQL with Django: should I store static JSON in a separate MongoDB database?

Context I'm making, a Django web application that depends on scrapped API data. The workflow: A) I retrieve data from external API B) Insert structured, processed data that I need in my PostgreSQL...

Django permission_classes for access to route is not callable

I am trying to change the permissions to specific routes. Some routes I want to be open, other routes I want the user to be authenticated. My code is the following: from rest_framework.decorators...

Model class django.contrib.sessions.models.Session doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

when I try to log-in Django admin panel using my superuser id & pass a runtime-error appears"Model class django.contrib.sessions.models.Session doesn't declare an explicit app_label and isn't in...

Django Channels equivalent to reverse()

In regular Django, I know I can use reverse to reverse a url. Is there equivalent functionality in django-channels for reversing a websocket url. If I have the following routing application =...

Django, Docker, Python - Unable to install Pillow on python-alpine

I have a dockerized django app that I want to put in production. But ever since I added an Imagefield Pillow is required and I struggle to install Pillow in the Docker container. As far as I...

My application container is not able to my mysql container

After all of web searching and coming up of no answer to this, I thought of asking this question on this platform. I had an application container which i try to connect with mine database...

Error with inlined profile form save in django admin

I really confised, because problem sounds trivial, but I didn't googled anything related to this. I found one very simular question...

Stuck in Watching for file changes with StatReloader

I made my project fine and when I run my server through a normal shell it works but I am trying to run my project through git bash. All the commands seem to work fine but when I do python...

Django Rest Framework: Prevent duplicate objects when using CreateModelMixin

I have a Viewset where a user can create reviews for a specific product and list their all the reviews they have created for all products: class ProductReviewViewset(CreateModelMixin,...

'Authentication Unsuccessful' When Trying To Send Email Through Django

I've been trying to send emails using my Outlook email through Django but have been getting a variety of error messages, including (535, b'5.7.3 Authentication unsuccessful...

Django Admin Foreign Key Error on Djongo database engine

I'm using djongo package for a database backend engine in order to connect to MongoDB and define my models on it. settings.py: DATABASES = { # 'default': { # 'ENGINE':...

How to check logs of nexjs project deployed in google app engine standard environment?

I have created nextjs project with Isomorphic admin theme Now I am going to deploy this project to google app engine. I read this discussion and structured my app based on this repo This is my...

Django - How to store emojis in postgres DB properly?

I'm running the latest version of Django on postgres. I'm trying to store emojis in my postgres DB in a way that a React Native app can properly render it. Below I have the initial emojis...

Why I am getting "Not Implemented Error: Database objects do not implement truth value testing or bool()." while running makemigration cmd in django

I am trying to connect Django with MongoDB using Djongo. I have changed the Database parameter but I am getting this error Not Implemented Error: Database objects do not implement truth value...