Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django - Disable authenticator for Swagger
So I have a Django app with Swagger, but I also added a custom authenticator to every endpoint automatically with REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'cheers.utils.authenticator.CognitoAuthentication', ), } How do I turn this off for swagger? The reason I'm not sure is because Swagger is added to URLs it's not a view How do I disable automatic authentication for swagger? Also I guess a side question would be how to disable this URL when debug is False -
Django dict(request.POST.lists()) returns twice(normal, empty)
Views.py @login_required(login_url="/users/login") def tresults(request): ids = dict(request.POST.lists()) print(ids) data = ids['selected'] msg = data.pop(0) HTML <form id = "{{ msg }}" action="tresults" method="POST"> <input type="hidden" name="selected" value="{{ msg }}"> <div class="table-responsive"> <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>GuildName</th> <th>GuildID</th> <th>Check</th> </tr> </thead> <tbody> {% for guild in guilds %} <tr> <td>{{ guild.name }}</td> <td>{{ guild.id }}</td> <td> {% csrf_token %} <input type="checkbox" name="selected" value="{{ guild.id }}"/> </td> </tr> {% endfor %} </tbody> </table> </div> </form> <a class="dropdown-item" href="#" onclick="document.forms['{{ msg }}'].submit();">Send</a> and I getting from print(ids) {'selected': ['61660a3afe554cfd1b4fe98f', '880716169986859039'], 'dataTable_length': ['10'], 'csrfmiddlewaretoken': ['OE9lhwbkU1KlKrDHiip1G6Yd5i9oOPS1bA0s2DapHY6RDbXc7UHc4KPd5jOlCLNm']} [13/Oct/2021 07:55:57] "POST /posts/post/tresults HTTP/1.1" 302 0 {} Internal Server Error: /posts/post/tresults I tried with various way like request.POST.dict() <- returns with only one value request.POST.copy() and dict(ids.iterlists()) or dict(ids) <- not working I don't know why two dict printed and last one is empty. I want to fix this -
Celery - What pool should I use for windows heavy cpu process and redis backend for status tracking?
I am running python 3.9, Windows 10, celery 4.3, redis as the backend, and aws sqs as the broker (I wasn't intending on using the backend, but it became more and more apparent to me that due to the library's restrictions on windows that'd I'd be better off using it if I could get it to work, otherwise I would've just used redis as the broker and backend). To give you some context, I have a webpage that a user interacts with to allow them to do a resource intensive task. If the user has a task running and decides to resend the task, I need it to kill the task, and use the new information sent by the user to create the new task. The problem for me arrives after this line of thinking: Me: "Hmmm, the prefork pool is used for heavy cpu background tasks... I want to use that..." Me: Goes and configures settings.py, updates the celery library, sets the environment variable to allow windows to run prefork pool - os.environ.setdefault('FORKED_BY_MULTIPROCESSING', '1'), sets a few other configuration settings, etc, runs the worker and it works. Me: "Hey, hey. It works... Oh, I still can't revoke a task … -
How to do predictions in django using restframe work
I am doing a machine learning project where I need to display the predictions on a webpage. The webpage is build using Django. I have predictions function and the weights of the model but how to integrate the predictions function, model, and weights in the Django code and do predictions. -
Celery task name is different in two workers
I have the following directory structure for a celery project: my_app ├── __init__.py ├── my_tasks.py I run the worker with exactly the same command celery -A my_app.my_tasks.post_request worker -l DEBUG in 2 nodes but got two different task names, one is absolute path: [tasks] . celery.accumulate . celery.backend_cleanup . celery.xxx . ... . my_app.my_tasks.post_request The other one is more like a relative path: [tasks] . celery.accumulate . celery.backend_cleanup . celery.xxx . ... . post_request How does celery generate the name of the task? I have read the section names of the official documentation but am still not able to find why the names are different in the two workers. -
Django why getting this error unsupported operand type(s) for -: 'NoneType' and 'int'
I am trying to implement load more button so I am writing this view for load json data but I am not understanding why I am getting this error. unsupported operand type(s) for -: 'NoneType' and 'int' here is my view: class PostJsonListView(View): def get(self, *args, **kwargs): print(kwargs) upper = kwargs.get('num_posts') lower = upper - 3 posts = list(Blog.objects.values()[lower:upper]) posts_size = len(Blog.objects.all()) max_size = True if upper >= posts_size else False return JsonResponse({'data': posts, 'max': max_size}, safe=False) -
Factoryboy can not generate database-dependent field
I use django-cities-light to store the user locations. However I need to import a huge dataset of countries & cities to the database. How can I create a factory that would automatically populate these fields during the tests? When not testing, the factory works properly by Country.objects.all(). But when testing, the database is empty and can not find any countries: IndexError: Cannot choose from an empty sequence. What should be the right approach for such cases? If you have a better solution to the use of LazyAttributes below, let me know the better approach. class UserProfileFactory(DjangoModelFactory): class Meta: model = UserProfile # ... birth_country = FuzzyChoice(Country.objects.all()) or None birth_region = factory.LazyAttribute( lambda o: o.birth_country.region_set.order_by("?").first() ) birth_subregion = factory.LazyAttribute( lambda o: o.birth_region.subregion_set.order_by("?").first() ) birth_city = factory.LazyAttribute( lambda o: o.birth_region.city_set.order_by("?").first() ) -
Django - How to filter and return data by groups
I have a model which I want to return group by an attribute of the object itself. Let's suppose the model is the next one: class User(): username = models.CharField(max_length=50, unique=True) group = models.CharField(max_length=20) Later in the view, I would be getting by group all the users: group1 = User.objects.filter(group='1') group2 = User.objects.filter(group='2') group3 = User.objects.filter(group='3') But that would return for each group the next structure: [{"username":"user1", "group":"1"}] [{"username":"user2", "group":"2"}] [{"username":"user3", "group":"3"}] How can I obtain the next structure (where the group is the root) directly from the filter or how can I combine the groups to achieve that: [ "1": [{"username":"user1","group":"1"}], "2": [{"username":"user2","group":"2"}], "3": [{"username":"user3","group":"3"}] ] -
upload image from next.js to django to store in aws s3
I set up functionality for s3, I can easily upload images from Django admin interface. I have "createProduct" page and I want to create a product by sending form data from next.js. Django stores the URL s3 bucket in DB and retrieves the image from s3 when needed. I set view image and cropping it functionality and it works as well. For this I have a separate component: <div className="form-group"> <label htmlFor="image">Image</label> <FileLoader onFileUpload={image => setValue('image', image._id)} /> </div> I need to create an endpoint. Admin, first uploads the image, image gets saved to s3, then admin gets the url of the image, and passes it to the form data, so form data will be sent to the createProduct endpoint. @api_view(['POST']) @permission_classes([IsAdminUser]) def createProduct(request): user=request.user print("user in post",user) print("request.data",request.data) name=request.data['name'] price=request.data['price'] brand=request.data['brand'] countInStock=request.data['countInStock'] category=request.data['category'] description=request.data['description'] // Here i need to send the imag url I guess image=request.FILES.get('image') print("image",image) product=Product.objects.create(user=user, name=name, price=price,brand=brand, countInStock=countInStock,category=category,description=description, image=image) product.save() serializer=ProductSerializer(product, many=False) return Response(serializer.data) -
Django Custom User Model and SuperUser
I am trying to create an app which a web3 user can use their wallet to sign in BUT I want the superuser to still use a username/password. (my future plan is to create a custom backend to do the web3 auth flow) I was close with this as I was able to create a first admin that could use the username/password but realized it was failing on the next createsuperuser with this: django.db.utils.IntegrityError: UNIQUE constraint failed: users_web3user.public_address So I tried for now just adding a random integer to satisfy that just to see if it would work but the same issue constantly shows up. Would this be the proper way to go about this and to seperate my users from my superusers? Also, my debugger is never called even though I have set in my settings.py where user is my app: AUTH_USER_MODEL = 'users.Web3User' models.py: class Web3UserManager(BaseUserManager): def create_user(self, public_address): if not public_address: raise ValueError('Users must have a public_address') user = self.model( public_address=public_address, nonce=secrets.token_urlsafe(32) ) user.save(using=self._db) return user def create_superuser(self, username, password=None): import ipdb; ipdb.sset_trace() public_address=secrets.randbelow(299) print(public_address) user = self.create_user( username=username, password=password, public_address=public_address ) user.is_admin = True user.save(using=self._db) return user class Web3User(AbstractUser): public_address = models.CharField(max_length=64, unique=True) nonce = models.CharField(max_length=64) -
graphene code run before django data migrations
I wrote a piece of code that generates graphene input object type dynamically from the database. when I try to run ./manage.py migrate that code runs before the migration and caused django.db.utils.ProgrammingError I have the same issue in run the Pytest too. how can I prevent this code from running before the data migrations -
django - I can't use the Q filter model with 2 related databases
I have the 2 following models related with 2 different databases at models.py: class AnalogicalValues(models.Model): id = models.BigAutoField(primary_key=True) date = models.DateField() description = models.ForeignKey(ExpensesDescription, models.DO_NOTHING) continent_id = models.ForeignKey( 'WorldContinent', db_column='continent_id', on_delete=models.DO_NOTHING ) (...)hide code(...) city_id = models.ForeignKey( 'WorldCity', db_column='city_id', verbose_name='City', on_delete=models.DO_NOTHING ) value = models.FloatField() comments = models.CharField(max_length=255, blank=True, null=True) user_id = models.ForeignKey(User, db_column='user_id', on_delete=models.DO_NOTHING) class Meta: managed = False db_table = 'analogical_values' ordering = ('-date', '-id') class WorldCity(models.Model): id = models.AutoField(primary_key=True, unique=True) name = models.CharField(max_length=255, verbose_name='City') continent = models.ForeignKey(WorldContinent, models.DO_NOTHING) country = models.ForeignKey(WorldCountry, models.DO_NOTHING) subcountry = models.ForeignKey(WorldSubcountry, models.DO_NOTHING) last_update_db = models.DateTimeField() class Meta: managed = False db_table = 'cities' ordering = ('name',) verbose_name_plural = 'List of World Cities' verbose_name = 'World City' def __str__(self): return self.name The relationship between them are city_id from AnalogicalValues and id from WorldCity and each model is mapped of respective database at routers.py. The description field on AnalogicalValues is a foreignkey of other table in same database as analogical_values and it's working fine. class WorldRouter: route_app_labels = {'myapp'} route_model_list = {'WorldCity'} def db_for_read(self, model, **hints): if ( model._meta.app_label in self.route_app_labels and model._meta.object_name in self.route_model_list ): return 'world_db' return None def db_for_write(self, model, **hints): if ( model._meta.app_label in self.route_app_labels and model._meta.object_name in self.route_model_list ): return … -
Number of Items per month works in CreateView, but not in TemplateView
My goal: get Count of items per month displayed in my template, i.e.: May 2021 - 5, June 2021 - 10, Sep 2021 - 3, Oct 2021 - 2, etc What I've done. I first created a test-project and my Index view inherited from CreateView (needed that for a form). Everything worked fine. However, in my main project my IndexView is inherited from django's TemplateView, and with the same code it shows like this: Sep 2021 - 1, Sep 2021 - 1, Oct 2021 - 1, Oct 2021 - 1, Oct 2021 - 1... you get the point. So, for some reason, it sees every item as a separate date without trying to aggregate them. So the difference-maker has to be the inheritance from different views in django, however, in my main project, I cannot make my index view inherit from CreateView. Also, I'm still new to Django and would really appreciate all the help I can get. It took me a lot of effort to figure it out up until this point. Here's my working code (in the test-project): models.py class Movie(models.Model): title = models.CharField('Movie name', max_length=100) gross = models.IntegerField('Gross', help_text='Worldwide, in dollars.') release_date = models.DateField('Date of release', blank=True, … -
Subprocess in views.py django app didn't work?
I'm trying to call a script in views.py like this from subprocess import Popen p1 = Popen('python3 {}'.format(path), shell=True, stdout=PIPE, stderr=PIPE) answer = p1.communicate(timeout=5) print('answer', answer) And i have result answer (b'', b'') but when i call from terminal python3 /tmp/tmp9nqnbve3 i get correct output and even if I call the same code from outside of django, I also get the correct result -
userpost() got an unexpected keyword argument 'instance'
I am practicing a little CRUD project in django. here is the views.py of crudproject from django.contrib import messages from django.shortcuts import get_object_or_404, redirect, render from .models import userpost from .forms import customerform #creating postdate def create(request): form= customerform() if request.method=='POST': Form=customerform(request.POST) if Form.is_valid(): Form.save() Form={} context ={'form':form} return render(request,'create.html',context) #reading the post def read(request): user_data=userpost.objects.all() context ={ 'user_data':user_data} return render(request,'read.html',context) #Updating the post def update(request,pk): get_user_data=get_object_or_404(userpost,pk=pk) form= userpost(instance=get_user_data) if request.method=='POST': form=userpost(request.POST,isinstance=get_user_data) if form.is_valid(): form.save() messages.success(request,'User data has been Updated') return redirect('read') context={'form':form} return render(request,'update.html',context) #deleting the post def delete(request,pk): get_user=get_object_or_404(userpost,pk=pk) get_user.delete() messages.error(request,'User deleted') return redirect('/') urls.py of crud project from django.urls import path from .import views urlpatterns = [ path('new/',views.create,name='create'), path('update<int:pk>/',views.update,name='update'), path('delete/<int:pk>/',views.delete,name='delete'), path('',views.read,name='read') ] but the server says TypeError at /update8/ userpost() got an unexpected keyword argument 'instance' Request Method: GET Request URL: http://localhost:8000/update8/ Django Version: 3.2.8 Exception Type: TypeError Exception Value: userpost() got an unexpected keyword argument 'instance' Exception Location: C:\Users\ITS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\base.py, line 503, in __init__ please help me to figure this out.it would be so much helpful if you give me a little explaination. Thanks in advance -
TypeError: argument of type 'PosixPath' is not iterable, old solution didn't worked
I am learning django and I'm getting this error and even when I go to admin the CSS is also not loading. the things I have added on models.py are also not showing on admin. Please Some one help me to get out of this problem. I tried searching google and youtube. Error `Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/Users/subas/opt/anaconda3/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/Users/subas/opt/anaconda3/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/subas/opt/anaconda3/lib/python3.8/site-packages/django/core/management/base.py", line 336, in run_from_argv connections.close_all() File "/Users/subas/opt/anaconda3/lib/python3.8/site-packages/django/db/utils.py", line 224, in close_all connection.close() File "/Users/subas/opt/anaconda3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 248, in close if not self.is_in_memory_db(): File "/Users/subas/opt/anaconda3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 367, in is_in_memory_db return self.creation.is_in_memory_db(self.settings_dict['NAME']) File "/Users/subas/opt/anaconda3/lib/python3.8/site-packages/django/db/backends/sqlite3/creation.py", line 12, in is_in_memory_db return database_name == ':memory:' or 'mode=memory' in database_name TypeError: argument of type 'PosixPath' is not iterable` Model.py from django.db import models class Category(models.Model): name = models.CharField(max_length=255, db_index=True) slug = models.SlugField(max_length=255, unique=True) class Meta: verbose_name_plural = 'categories' def get_absolute_url(self): return reverse('store:category-list', args=[self.slug]) def __str__(self): return self.name class Product(models.Model): category = models.ForeignKey(Category, related_name='product', on_delete=models.CASCADE) created_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='Product_creator') title = models.CharField(max_length= 255) brand = models.CharField(max_length=255, default='Non-branded') description = models.TextField(blank=True) image = models.ImageField(upload_to='images/') slug = models.SlugField(max_length = 255) price … -
django Google maps ipa
I'm creating a website with django frame work. and I want when a user order something a little frime shows up and the user can enter the delivery address within the map in the frame How can I do that ? ? -
Django app on Azure incorrectly loading static files from an Azure Blob
This Django app is deployed on Azure as an App Service its static and media files are stored in an Azure storage account - blob. The project used to work well in the past, but something has changed and now the problem is as following. Relevant part of the app settings file: STATIC_URL = 'https://myappstorage.blob.core.windows.net/static/' MEDIA_URL = 'https://myappstorage.blob.core.windows.net/media/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # any static paths you want to publish STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] so one would expect that for example a favicon, which is in the root directory of the storage could be found on https://myappstorage.blob.core.windows.net/static/favicon and it is indeed! But all static files that the app on azure tries to load it tries to load from https://myappstorage.myappstorage.blob.core.windows.net/static/ (note the duplication of myappstorage), same for media files. This results in no static files being applied to the page as they are being loaded from the wrong url. When I run the app locally, it works fine. I destroyed it and recreated it, no success. Now I have two copies running, one deployed through FTP and startup command and on using Github action. Still the same problem. I have also tried little hack-ish workarounds in the setting file, … -
How to execute mulitple commands in single line linux (openshift / docker )
I'm looking for a way to run django server and celery in single line. The services (django and celery) are deployed in openshift as two separate pods with same image and currently i'm running django service (pod) using python manage.py runserver and celery (pod) using celery -A myapp worker --loglevel=info --concurrency=20 instead of running separate pods for each, i want to execute the runserver command and celery worker command together. How to do that. I know && ; || is used for such scenarios. but those doesn't work. for example : cd ./app && python manage.py runserver #this works cd ./app && python manage.py runserver && celery -A myapp worker --loglevel=info --concurrency=20 #this will cd to app, execute runserver command. but celery command doesn't get executed. -
Django 404 with existing database entry
I'm quite new to django and currently working on my first unguided project. I've run into a problem which seems very unreasonable to me and can't tackle it myself. Basically, I do get url pattern match, however get also 404 error that page is not found. I have tested it with various entries and the result is always the same - 404. companies/urls.py from . import views from django.conf.urls import url urlpatterns = [ url(r'^company/(?P<pk>)', views.CompanyDetailView.as_view(), name='company-detail') ] Main/urls.py rom django.contrib import admin from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), path('companies/', include('companies.urls')) ] and here's the error message: *"Page not found (404) No company found matching the query Request Method: GET Request URL: http://127.0.0.1:8080/companies/company/F/ Raised by: companies.views.CompanyDetailView Using the URLconf defined in main.urls, Django tried these URL patterns, in this order: admin/ companies/ ^company/(?P) [name='company-detail'] The current path, companies/company/F/, matched the last one. You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page."* Just to add, I can access the record from admin with url http://127.0.0.1:8080/admin/companies/company/F/change/ Really lost here and question my sanity. -
Django PythonAnywhere (2003, "Can't connect to MySQL server (timed out)")
I'm trying to setup a Django project and I can't seem to connect to MySQL database made in PythonAnywhere. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'username$dbname', 'USER': 'username', 'PASSWORD': 'password', 'HOST': 'username.mysql.pythonanywhere-services.com', } } I cant enter the database in the PythonAnywhere Bash with my user, host, name and password, but when i try to do it in django it appears as follows: django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'username.mysql.pythonanywhere-services.com' (timed out)") -
how to manage MySQL and MongoDB at the same time with django
I have an affiliate site where the data for products is arbitrary such as length of clothes and using MySQL will not be flexible and a good option there. I want something dynamic such as MongoDB. I know about "djongo" but it converts every query to Mongo. I found this How to Hybrid Mysql and MongoDB in Django and it gave me hope that I may be able to use mongo for the products and keep the rest such as Auth, User management etc in MySQL. If you know anything then please let me know. Is it even possible? Can I use PyMongo to access mongoDB database and query data easily between both databases such as using relations(i.e Foreginkey, OneToOne etc) The reason I provided none of my code is that I only want to know the concept. -
Is the implementation of my add to cart / remove from cart secure?
I am building an ecom website and in order to implement an add_to_cart function I've done the following. Clicking the add to cart button calls the javascript add_to_cart function that I wrote: <button type="button" onclick = "add_to_cart({{ product.pk }})">Add to Cart</button> This is the function: function add_to_cart(product_pk) { let url = '/add-to-cart/' + product_pk.toString() $.ajax({ type: 'GET', url: url, processData: false, contentType: false }) } the urls for this look like this: path('add-to-cart/<str:product_pk>', views.add_to_cart, name='add_to_cart') and finally my view looks like this: def add_to_cart(request, product_pk): cart = request.session['cart'] cart.append(product_pk) request.session['cart'] = cart context = {'length_of_cart': len(cart)} return HttpResponse(content = dumps(context), content_type='application/json') tldr: Click button, button calls js, js makes get request to url, url triggers view, logic in view adds product to cart. I feel like this is pretty "hacky". Are there any security issues involved with what I've done here? -
Modifiying django defaultrouter URL
So I want the URL /users/ to retrieve not a list of users but only the current user username. What I did for achieving this is adding the list method and overwriting it, like this: def list(self, request, *args, **kwargs): """ Override list method so it only returns current user username. """ data = {"username": request.user.username} return Response(data, status=status.HTTP_200_OK) But I feel like it's not the correct solution because list it's supposed to retrieve all the users. There is a way in which I could change the Django default router behaviour? So the URL /users/ executes a different method, not list(). urls.py from django.urls import include, path from rest_framework.routers import DefaultRouter from users.views import UserViewSet router = DefaultRouter() router.register(r'users', UserViewSet, basename='users') urlpatterns = [ path('', include(router.urls)) ] Or maybe doing this is just fine and I should let it be how it is right now. -
Google Cloud Storage doesn't upload to the correct media and static directory in the bucket
I have created an app in Django and want to use Google Cloud Storage to keep my statics and media files. However, when running python manage.py collectstatic It uploads all the statics to the google cloud bucket root instead of the directory "static" in the bucket. This is my core/settings/local.py from .base import * # noqa ALLOWED_HOSTS = ["*"] DEBUG = True INSTALLED_APPS += ["django_extensions", ] DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage" STATICFILES_STORAGE = "storages.backends.gcloud.GoogleCloudStorage" GS_BUCKET_NAME = "name-bucket" and here is my core/settings/base.py import os from pathlib import Path import dj_database_url from decouple import config # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent.parent ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "whitenoise.runserver_nostatic", "django.contrib.staticfiles", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] STATIC_FILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = "/static/" STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") STATICFILES_FINDER = [ "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder", ] STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" MEDIA_URL = "/media/" MEDIA_ROOT = BASE_DIR / "media" How can I get to upload my statics to a folder called "static" in my bucket instead in the root?