Category "django"

Why does Django use `Meta` inner class in models?

If I want to describe some information such as ordering, if the model is proxy or abstract, which fields must be unique together, then I need to put this inform

Django Rest Framework gives 302 in Unit tests when force_login() on detail view?

I'm using Django Rest Framework to serve an API. I've got a couple tests which work great. To do a post the user needs to be logged in and I also do some checks

Need help setting value for "is_staff" and "is_superuser" for Django LDAP authenticated users

I new to both Django and LDAP. I am creating a Django application with LDAP authentication as the login system. I am able to connect to the LDAP server and auth

Django - Hide labels in inline

How to hide labels in Django inlines?

why does for loop not working in django template

this is my views : rooms = [ {'id': 1, 'name': 'room-1'}, {'id': 2, 'name': 'room-2'}, {'id': 3, 'name': 'room-3'}, {'id': 4, 'name': 'room-4'},

How can to get data from related model in Django Rest Framework?

I have next models class User(AbstractUser): ip_address = models.CharField(max_length=15) class Statistic(models.Model): user = models.ForeignKey(User

Queryset is Containing some items but all() method returns empty array

I have this code: print(f"DEBUG 1: {queryset}") transaction_items = queryset.all() queryset.update(status=TRANSACTION_STATUS_COMPLETED, processing_method=PROCES

Django Unable to login

Login and Log out is only working for admin panel , not for user panel , after loging in from user end , its not getting reflected in the home screen . The defa

Advise on orm modelling in django

I am building a webapp in which users place orders with nested information. I am after some advice on best practice so I can do some more research. The idea is

Django manage.py runserver graceful reloading

I am working on a Django project, which integrates a webcam and OpenCV. For the webcam access, I use following code. The webcam can be released if I use Ctrl +

How to set Authorization header in Django?

I want to set the bearer token in the authorization header. why? Because I am using rest_framework_simplejwt in my Django project. I want to implement authoriza

Django throws AttributeError: 'str' object has no attribute '_meta' when I register my Model

Im novice and I didnt find solution for this problem. Im writing code for a blog. I have a model Post where I want to create field author which is ForeighKey to

css and other assets not loading for my django webapp

CSS, JS, fonts, images and other assets are not being loaded into my django app index.html. All the assets for the app are present inside the application app in

How do I prevent a 500 CORS error when attempting to create and download a csv file containing a large data set using python's StreamingHttpResponse?

The function runs and works perfectly fine for a small data set, but for a large data set, the following error is produced: (URL is hidden in the red) A 500

Failed running 'collectstatic' exited with exit code when deploying Django to Azure Web Service -

I am trying to deploy a Django app to Azure App Services. It runs on the server now, but without the style.css. When I run it on localhost, everything shows cor

Django forms User form not summited

I need help with my code. I have read through the code several times and I didn't see anything wrong with it. The user is expected to submit a job application a

django-ckeditor modal form does not change data on POST

I have a django project using django-ckeditor. I use HTMX to create a bootstrap modal to show my edit form. It renders correctly (I did add the ckeditor.js fil

Configuring CSRF tokens with apollo client and graphene-django

I am having trouble properly setting up csrf tokens in the authlink header. const authLink = setContext((_, { headers }) => { const token = localStorage.

Django. How to make ModelChoiceField work with SingleObjectMixin, FormView, and inlineformset_factory?

This shouldn't be hard How to show in a Django Model Form just the related records from Model.B for the user to choose. Ginven that it is provided the Model.A a

How to add two fields of django model and save the sum in another field?

class example(models.Model): var1 = models.IntegerField(default=0) var2 = models.IntegerField(default=0) var3 = models.IntegerField(default=0)