Django CSRF check failing with an Ajax POST request

I could use some help complying with Django's CSRF protection mechanism via my AJAX post. I've followed the directions here: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ I've copied the...

Django admin MySQL slow INNER JOIN

I have a simple model with 3 ForeignKey fields. class Car(models.Model): wheel = models.ForeignKey('Wheel', related_name='wheels') created = models.DateTimeField(auto_now_add=True) ...

uploading files with urllib to a FileField model in Django

I have a django file model that has a models.FileField field and a form that is used to upload files to the server: class UploadFile(model.Model): filename =...

Error: "dictionary update sequence element #0 has length 1; 2 is required" on Django 1.4

I have an error message on Django 1.4: dictionary update sequence element #0 has length 1; 2 is required It happened when I tried using a template tag like: {% for v in values %}: dictionary...

OperationalError, no such column. Django

I am very new to django and was able to finish the tutorial on djangoproject.com without any errors. I am now going through the Django REST framework tutorial found at...

Django error reporting emails: env vars leak info

Django's builtin capability of emailing admins upon errors (see https://docs.djangoproject.com/en/dev/howto/error-reporting/) is quite handy. However, these traceback emails include a full dump of...

django admin custom list view

I want to customize django admin.. For additing I did this : class SomeAdmin(admin.ModelAdmin): """ Customized admin template and corresponding views for adding media. ...

The current URL, app/, didn't match any of these

I'm a newbie in Django and just started looking at it before a day by installing Django 1.10 on my local. I've followed all the instructions of this link...

AssertionError: `HyperlinkedIdentityField` requires the request in the serializer context

I want to create a many-to-many relationship where one person can be in many clubs and one club can have many persons. I added the models.py and serializers.py for the following logic but when I...

How to add an url field to a serializer with Django Rest Framework

I am following the tutorial on Django Rest Framework - Tutorial 3 Class based views. How to add an url field (pointing to the current snippet) to a serializer? serializers.py from rest_framework...

TemplateDoesNotExist at / base/index.html when deploying to heroku

I've been working on this issue for days and I would really love some real help here! :) I'm brand new to Python, Django, and stackoverflow, so please let me know if more information or a...

How to retrieve data from one to many relations in django?

I am making my personal website using django 1.10 Here is models of skill app: from __future__ import unicode_literals from django.db import models # Create your models here. class...

Django admin login returns Forbidden 403 CSRF verification failed. Request aborted

Pretty new to Django. Working through a second project following the Polls tutorial on Django website. Previous effort went well, albeit simple. This time around encountering problems accessing...

Django-Filter Form Displaying All Filters?

I've just started working with Django Filter. When I test, the filter.form shows filters for all fields and I can't get it to show only the desired filters. Here's the filter: class...

How can I redirect from view In Django

This is a view written for my posts app in Django. The problem is that after filling the update form and submitting it happens successfully. But it creates confusion for the user because the same...

django.urls.exceptions.NoReverseMatch: Reverse for 'sign_up' not found. 'sign_up' is not a valid view function or pattern name

Django version 1.11.5, views.py class SignupPage(CreateView): form_class = forms.UserSignupForm success_url = reverse_lazy('login') template_name =...

Django restrict data that can be given to model field

I have the following model in django: class Cast(TimeStampedModel): user = models.ForeignKey(User, unique=True) count = models.PositiveIntegerField(default=1) kind =...

I keep getting RelatedObjectDoesNotExist at /admin/login/. How do I successfully create user profiles in Django via a one to one relationship?

I'm trying to extend the built-in user and add some more information to it. I have two apps in my django project- general and user_details. Inside my user_details app, in the models.py file, I...

Django: TemplateDoesNotExist at /accounts/login/

I'm following this tutorial from Mozilla.org, *Setting up your authentication views* And I'm having problems in this part: *The next step is to create a registration directory on the search path...

Django forms: how to show only objects associated with user in dropdown

I am a vet hospital, with class Pet and class Records. Each pet can have many records, i.e. everytime it visits the hospital it gets a new record. At the moment, my form shows all the pets ever...

ModuleNotFoundError: No module named 'Blog'

Made a new app called Blog and now not able to import it. created basic apps called products, pages. Now adding one more app called Blog into the project. Not able to solve migrate issues and...

React Django REST framework session is not persisting/working

I'm working on a project with Django Rest Framework as back-end and React as front-end. When I set a session variable initially in some function/view and later when I try to access the different...

How to pass Audio file from model to Template in Django?

I've just started out with Django and have tried making an audio player application website. I (admin) want to be able to upload audio files that visitors can listen to. I've created a model for...

override django oscar search app to return only merchant specific products?

I am using Django oscar(2.0.2), where I have made foreign key relation of merchant ids with product table AbstractProduct with data, (https://prnt.sc/s1ssxx) so that I can fetch merchant-specific...

Django: TypeError: int() argument must be a string, a bytes-like object or a number, not 'ObjectId'

Im getting this type error when trying to return a JsonResponse. In the code python_serializer is an object that has a instance variable named data containing the results of the...

Understanding JWT and confirm simplejwt expire in testcase

I'm just trying to understand djangorestframework-simplejwt expiration and want to know what is returned when the token expires. To explore this a wrote a simple testcase in my django project, but...

Django and Stripe, Module 'stripe' has no 'Customer' member

so I'm trying to create a customer in stripe using django, according to the documentation in stripe, the code stripe.Customer.create should work, but it just appears this error, can someone tell...

Django: Resolving "Reverse for 'password_reset_complete' not found."

I am attempting to do a password reset using Django using custom html templates. I am able to request an password reset by email (using the EMAIL_BACKEND =...

django model select_related or prefetch_related child model

Newbie here, I have two models which are below class ReceipeMaster(models.Model): receipe_type = models.CharField(max_length=50, choices=TYPE_OPTIONS, default=TYPE_OPTIONS[0]) item =...

Prefetch query with relational conditions - Django

I'm trying to make a request that prefetch all the data to reduce the amount of requests to my database. I'm using the prefetch_related() method and the Prefetch object class to tell what to load...