Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django admin static files need to be redirected to different path
I am sorry if I am asking this question again. But I did try to find the answer without success. My static files of the admin page seem to be in different location then it is looking for them. How can change the location of where it should look? I could move the admin static folder but that would to much hassle if I make changes, right? Thanks -
POST Request to HTTPS(SSL) url from Android/Java
I am pretty new to Java and Android. Working on Python all the time. I am trying to make an Android Apps via Android Studio BumbleBee (2021.1.1 Patch 3) that can make GET and POST request to a https(SSL) server. The server is run by Django 3.2, deploy on IIS(version 10.0) powered by Window Server 2019. GET requests are fine but POST requests are not! What i am trying to do is to make a POST request to login to the website. My idea is to send a GET request to obtain the csrftoken and csrfmiddlewaretoken for subsequent POST request. (From my understanding, Django POST requires csrfmiddlewaretoken in the POST data and csrftoken in the cookies). Everything works fine when i tried on http://localhost:8000 OR i use @csrf_exempt decoration on both HTTP and HTTPS(SSL) server. But the actual server which run by Django is HTTPS(SSL) instead of HTTP and i want to remain the csrf function. Since i keep failing on Android Studio, I tried to make POST request to https by Java(on Eclipse IDE Version: 2022-03 (4.23.0)) and it keeps returned an error of 403. I tried with SSL Socket Factory in Java but still it does not work. … -
how to show many nested childs in a queryset in efficient way, for loops dont work
I have created two models, 1st is Book and 2nd is SubBookPart (Sub Part of Book) User creates a book first then add its sub part like "Chapter 1", "Chapter 2" and so on to that book then add "Page 1", "Page 2" and so on to each chapter then add "Paragraph 1", "Paragraph 2" and so on to each Para I successfully does this My Book Look Like This BookName |- Chapter 1 |- Page 1 |- Paragraph 1 |- Paragraph 2 |- Paragraph 3 |- Page 2 |- Paragraph 1 |- Paragraph 2 |- Paragraph 3 |- Chapter 2 |- Page 1 |- Paragraph 1 |- Paragraph 2 |- Paragraph 3 |- Page 2 |- Paragraph 1 |- Paragraph 2 |- Paragraph 3 |- Page 3 |- Paragraph 1 |- Paragraph 2 |- Paragraph 3 But I dont know how to show it in frontend, because it will take very very long nested for loop, Is There and other way models.py class Book(models.Model): name = models.CharField(max_length=50) subparts = models.ManyToManyField("SubBookPart", related_name="book_subparts", blank=True) class SubBookPart(models.Model): # for only first sub part subpart_of_book = models.ForeignKey(Book, on_delete=models.CASCADE,null=True, blank=True) # for only non-first sub parts, giving reference to previous subpart subpart_of = models.ForeignKey("SubBookPart", … -
Django - a.html include b.html file which is not located in the template folder
I have two htmls a.html and b.html. a.html is located in the template folder by default. b.html is located in appname/static/images/b.html In a.html, I am trying to include b.html but it's not working, unless b.html is in the same template folder. <body> {% include 'appname/static/images/b.html' %} </body> questions: how to include b.html? how to include b.html dynamically if it's in different folder, e.g. images/username/b.html where username is different. -
nested serializer error. 'str' object has no attribute 'values'
i am currently working social media type app where i wants to get the group detail and users detail which are posted the post. the problem is occure when i used nested serializer in post serializer the group serializer is working perfectly when i write the user serialize it gives the following error packages/rest_framework/serializers.py", line 368, in _readable_fields for field in self.fields.values(): AttributeError: 'str' object has no attribute 'values' [26/May/2022 09:01:21] "GET /group/posts/3 HTTP/1.1" 500 123293 Here is my models and serialzers post model class Post(models.Model): post_data = models.FileField(upload_to='group_post', null=True) post_description = models.TextField(null=True,blank=True) post_time = models.DateTimeField(auto_now=True) post_group = models.ForeignKey(to='Group', on_delete=models.DO_NOTHING, related_name='post_group') post_user = models.ForeignKey(to=MyUser, on_delete=models.DO_NOTHING, related_name='post_user') class Meta: db_table = "group\".\"Post" post serializers class PostSerializer(serializers.ModelSerializer): post_group = GroupSerializer(read_only=True) post_user = UserSerializer(read_only=True) class Meta: model = Post fields = '__all__' user Model class MyUser(AbstractBaseUser): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField(verbose_name='Enter Email', max_length=50,unique=True) password = models.CharField(max_length=1000) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) admin = models.BooleanField(default=False) user serialzer class UserSerializer(serializers.ModelSerializer): class Meta: model = MyUser fields = '__all__' -
How can I do a redirect in Django and React?
I need to do a redirect right after pressing a button. <Button onClick={changeCalendar}>Integrate Google Calendar</Button> So I'm sending a request to a server to do the redirect const changeCalendar = async () => { let response = await fetch("http://localhost:8000/gcalendar/", { mode: "no-cors", method: "GET", headers: { Authorization: "Bearer " + String(authTokens.access), }, }); On the server side I process the request, and get a URL def change_calendar(request): flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file( CLIENT_SECRETS_FILE, scopes=SCOPES) flow.redirect_uri = 'http://localhost:3000/' authorization_url, state = flow.authorization_url( access_type='offline', include_granted_scopes='true') return redirect(authorization_url) If I print authorization_url it looks like this: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=**ID**&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar.events&state=**STATE**&access_type=offline&include_granted_scopes=true If I copy and paste the link into a Google search, it opens a Google authorization window. I need to do the same one through code. But redirect doesn't work. Even if I try to do a redirect to other links. -
create custom mixin in DRF
I want to create custom mixin in Django Rest Framework, which will return data in CSV format. This to_csv method should convert fields to CSV format class ToCSVMixin: @action(detail=False, methods=['get']) def to_csv(self,request): fields = None /* some stuff here to convert fields list to CSV */ Problem is that I'm not sure how to use to_csv method in view. fields list should be populated in MyViewSet class MyViewSet(ModelViewSet,ToCSVMixin): /*.... */ Thank you in advance -
Django - Delete FOLDER from amazon S3
I'm using django post_delete signals to delete all files or folders (folders that would be empty after files be deleted) related to a deleted object in my DB. For some reason I am not able to make the s3 delete a FOLDER, even after searching numerous guides and snippets, maybe someone here knows. I use django 3.2.7 and boto3. Here's my code: models.py from django.db import models class Album(models.Model): """ Category Model Attributes: *name: A string indicating the category name; *friendly_name: A string indicating category friendly name. Sub-classes: *Meta: Display the object's plural name. Methods: *__str__: Display the object's headline in the admin interface, it returns a nice, human-readable representation of the model; *get_friendly_name: Display the object's friendly name. """ category = models.ForeignKey('Category', null=True, blank=True, on_delete=models.SET_NULL) title = models.CharField(null=True, max_length=150) pre_desc = models.CharField(null=True, max_length=500) date = models.DateField(null=True) place = models.CharField(null=True, max_length=500) cover = models.ImageField(blank=True, null=True, upload_to="portfolio/covers/") description = models.TextField(null=True) def save(self, *args, **kwargs): """ Override the original save method to set the lineitem total and update the order total. """ album_type = self.category.name folder_type = album_type.replace(" ", "_") album_title = self.title folder_name = album_title.replace(" ", "_") for field in self._meta.fields: if field.name == 'cover': field.upload_to = f"portfolio/covers/{folder_type}/{folder_name}" super(Album, self).save() def … -
single form for the whole process or separate for each post type | django
I'm trying to make an app like reddit where you can create post for any server you want but you are only allowed to post image&video/text not both. but the problem is i don't know if i have to make a single ModelForm for the whole process and hide or show fileField and textField using Javascript ,or make a ModelForm for each type of post and change the form that is displaying using Javascript posts/forms.py: class CreatePostTextForm(ModelForm): class Meta: model = Post fields = ['title','video','image','text'] widgets ={'title':forms.TextInput({'placeholder':'تیتر'}), 'text':forms.Textarea({'placeholder':'متن'})} posts/views.py class CreatePostView(LoginRequiredMixin, View): form_class = CreatePostTextForm def dispatch(self, request, *args, **kwargs): user = User.objects.get(id=kwargs['pk']) if not user.id == request.user.id: messages.error(request, 'شما نمیتوانید باپست ایجاد کنید') return redirect('home:home') return super().dispatch(request, *args, **kwargs) def get(self, request, pk): form = self.form_class() return render(request, 'posts/create-post.html', {'form':form}) def post(self, request, pk): form = self.form_class(request.POST, request.FILES) if form.is_valid(): saved_form = form.save(commit=False) saved_form.creator = request.user saved_form.save() messages.success(request, 'پست شما باموفقیت ایجاد شد') return redirect('home:home') return render(request, 'posts/create-post.html', {'form':form}) posts/create-post.html <div class="create-post-form-wrapper col-8"> <div class="form-header"> <div class="form-types"> <button onclick="postType(0)"> <p>متن</p> <img src="{% static 'posts/svgs/file.svg' %}" alt="" /> </button> <button onclick="postType(1)"> <p>عکس</p> <img src="{% static 'posts/svgs/image.svg' %}" alt="" /> </button> <button onclick="postType(2)"> <p>فیلم</p> <img src="{% static 'posts/svgs/video.svg' %}" alt="" /> … -
How to customize learner profile in OpenEdx?
I managed to customize some templates in lms, but now I need to customize learner profile. I know how to overwrite learner_profile.scss, but I have trouble with html template. I found learner_profile.html template in location outside of lms directory: openedx/features/learner_profile/templates/learner_profile/learner_profile.html I have tried to overwrite it with: themes/my-theme/openedx/features/learner_profile/templates/learner_profile/learner_profile.html themes/my-theme/openedx/templates/features/learner_profile/learner_profile.html themes/my-theme/lms/features/learner_profile/learner_profile.html None of these paths worked. How can I do that? -
I recently updated pycharm and now having trouble with django-heroku
I'm getting this error message when I attempt to run the server: "/Users/brandonstockwell/Dropbox_Gmail/Dropbox/mindbrain/mindbrain/settings.py", line 15, in import django_heroku ModuleNotFoundError: No module named 'django_heroku' Process finished with exit code 1 Same thing happens with rollbar. Everything worked fine before I updated. -
How to make AJAX post request in Django
I want to post comment using ajax in Django. I have Message Class related to Post class, and I using PostDetailView to show content of the post and coments. I succeeded to show posted comment on the console. I'm getting error jquery.js:9664 POST http://127.0.0.1:8000/post/39 403 (Forbidden) this is my code views.py class PostDetailView(DetailView): model = Post def post(self,request,*args,**kwargs): if request.method == 'POST': postid = request.POST.get('postid') comment = request.POS.get('comment') # post = Post.objects.get(pk=postid) user = request.user Message.objects.create( user = user, post_id = postid, body = comment ) return JsonResponse({'bool':True}) html(where is corresponds to comment section) {% if request.user.is_authenticated %} <div> <form method="POST" action="" id="form_area"> {% csrf_token %} <input class="form-control mr-sm-2 comment-text" type="text" name="body" placeholder="Write Your message here..." /> <button class="btn btn-outline-success my-2 my-sm-0 save-comment" type="submit" data-post="{{object.id}}" data-url="{% url 'post-detail' object.id %}" > Comment </button> </form> </div> {% else %} script.js function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie != "") { var cookies = document.cookie.split(";"); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == name + "=") { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } var csrftoken = getCookie("csrftoken"); function csrfSafeMethod(method) { … -
View decorator @verified_email_required takes user back to original view instead of to the clicked view after verifying email, django-allauth
When a user with an unverified email clicks a link in their profile page to go to a new page ServiceSignupView, they are redirected to verify their email first. Once verified they are redirected again back to the profile view instead of the intended view: @verified_email_required def ServiceSignupView(request): return render(request, 'service_signup.html', {}) My settings.py has the login redirect view set to the profile view, except this is not login redirect, this is verifying the email and clicking the link in the email. LOGIN_REDIRECT_URL = 'profile' How can I get the view to proceed to the ServiceSignupView instead of back to the profile view after clicking the verification link in the django-allauth email? -
prevent django test runner from creating stale table
I have mariadb database that used to have CHARSET utf8 COLLATE utf8_general_ci config but now CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci. All tables have the same CHARSET and COLLATE as those of the database. When I run ./manage.py test, stacktrace looks like this: .... django.db.utils.OperationalError: (1118, 'Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.') I managed to find out what the troubling table is, and the sql query looks like the following. Note that I changed names of table and fields for security: CREATE TABLE `troubling_table` ( `id` INTEGER auto_increment NOT NULL PRIMARY KEY, `no_tax` VARCHAR(20) NOT NULL, `cd_pc` VARCHAR(7) NOT NULL, `cd_wdept` VARCHAR(12) NOT NULL, `id_write` VARCHAR(20) NULL, `cd_docu` VARCHAR(10) NULL, `dt_acct` VARCHAR(8) NULL, `st_docu` VARCHAR(3) NULL, `tp_drcr` VARCHAR(3) NULL, `cd_acct` VARCHAR(20) NULL, `amt` NUMERIC(19, 4) NULL, `cd_partner` VARCHAR(20) NULL, `nm_partner` VARCHAR(50) NULL, `tp_job` VARCHAR(40) NULL, `cls_job` VARCHAR(40) NULL, `ads_hd` VARCHAR(400) NULL, `nm_ceo` VARCHAR(40) NULL, `dt_start` VARCHAR(8) NULL, `dt_end` VARCHAR(8) NULL, `am_taxstd` NUMERIC(19, 4) NULL, `am_addtax` NUMERIC(19, 4) NULL, `tp_tax` VARCHAR(10) NULL, `no_company` VARCHAR(20) NULL, `dts_insert` VARCHAR(20) NULL, `id_insert` VARCHAR(20) NULL, `dts_update` VARCHAR(20) NULL, `id_update` VARCHAR(20) NULL, `nm_note` VARCHAR(100) NULL, `cd_bizarea` VARCHAR(12) … -
How to gettext from django.contrib.auth
I am working on translate my Django app, But there are some messages text don't appear in django.po like: This password is too common. A user with that username already exists. The password is too similar to the email address. and they from django.contrib.auth i did run django-admin makemessages -l ** Any idea how to fix this? -
Google OAuth2 integration with kiwi tcms
I have followed exact steps on the documentation provided to integrate google OAuth2. From Kiwi github page. social-auth-app-django - extra authentication backends Google sign-in details. https://python-social-auth.readthedocs.io/en/latest/backends/google.html#google-sign-in I have included relevant settings in /tcms/settings/common.py AUTHENTICATION_BACKENDS = [ "django.contrib.auth.backends.ModelBackend", "guardian.backends.ObjectPermissionBackend", "social_core.backends.google.GooglePlusAuth", ] SOCIAL_AUTH_GOOGLE_PLUS_KEY = "XXXXXXX-XXXXXXXX.apps.googleusercontent.com" SOCIAL_AUTH_GOOGLE_PLUS_SECRET = "XXXXXXXXXXXXXXXXXXXXX" With above configuration, i am able to runserver and get to localhost page. The UI page doesn't contain expected way of sign in via SSO. Am i missing something? How to get the changes in the kiwi tcms UI like https://public.tenant.kiwitcms.org/accounts/login/?next=/ Or Continue With Google section of sign in. -
creating dinamic link in views according to urls.py
I want to create a dinamic link in my view according to path in urls.py urls.py path('link_path/', views.link_view, name="link") this is how it works in a template in any.html <a href="{% url 'link' %}"> this link</a> how can i create dinamic link in views.py which will lead to my path in urls.py? def link_view(request): link = ??? print(link) i want link variable output be like this 127.0.0.1:8000/link_path -
Using mock to create a 'request' attribute for testing a class method in Django
I am new to testing and need help testing a method in Django. I have tried using Client() and RequestFactory(), but because of the method's reliance on other methods, I feel that it is easier to test the method in isolation. Here is the test: class EmailVerificationViewTest(TestCase): def setUp(self): User = get_user_model() self.view = EmailVerificationCode() self.view.time_diff = Mock(return_value=False) self.view.user_code = '0000000000' self.view.code = '0000000000' def test_library(self): self.view.check_code() The problem is that I keep getting an error whenever self.request is called: user_record = User.objects.get(pk=self.request.user.pk) AttributeError: 'EmailVerificationCode' object has no attribute 'request' OR (depending whether time_diff is set to True or False) messages.info(self.request, AttributeError: 'EmailVerificationCode' object has no attribute 'request' The class and method to be tested: (login is required through the OTPRequiredMixin) class EmailVerificationCode(OTPRequiredMixin, FormView): def check_code(self): try: if self.time_diff(): if str(self.user_code) == str(self.code): user_record = User.objects.get(pk=self.request.user.pk) user_record.is_user_verified = True user_record.save() messages.success(self.request, _('Your email has been verified - thank you' )) return redirect(reverse('account:user_profile')) else: messages.error(self.request, mark_safe(_( 'Sorry, but your code did not match.' ))) return redirect(reverse('account:verify_email_code')) else: messages.info(self.request, mark_safe(_('Sorry, but your code has expired.<br>' ))) return redirect(reverse('account:verify_email')) except (AttributeError, ObjectDoesNotExist): messages.warning(self.request, mark_safe(_('We are very sorry, but something went wrong. 'Please try to login again' ))) return redirect(reverse('two_factor:login')) My question is, how … -
Request.get blocked coming from Atom only
I am writing a django app with communcitaion to external python scripts in other software. As I am currently checking all basi requirements and their functionality, I am working with the standard django sql lite testserver. While testing, I am facing a weird firewall/ site blocking issue. A simple request.get() is working fine from windows cmd, receiving my json response. Opening the page in any browser from any computer within my company network works as well. However, when simply launching the request from atom on the local host pc, it fails with 403 - response.content.decode() showing the site is receiving a prompt due to being uncategorized and I would have to click to "continue browsing for work related purposes". As this is only happening from within atom - any ideas how to prevent this? What I tried so far: Adding headers (not change) launching a subprocess calling cmd with the command (works, but sort of failing the purpose of the script) Goal is to simply retrieve a json response from a view so I can transfer the information to my program. Thanks a lot Thomas -
create auto increment integer field in django
i want to create auto increment integer field. I want to create an ID for each user. I am a beginner and please explain completely and clearly :) I want to automatically assign an ID to each user. my Model: from django.db import models class User_account(models.Model): email = models.EmailField() fullname = models.CharField(max_length=30) username = models.CharField(max_length=20) password = models.CharField(max_length=30) marital_status = models.BooleanField(default=False) bio = models.CharField(default='' ,max_length=200) def __str__(self): return f"(@{self.username}) {self.fullname}" def save(self, *args, **kwargs): self.username = self.username.lower() self.email = self.email.lower() return super(User_account, self).save(*args, **kwargs) my View: from django.shortcuts import render from .models import User_account def profile(request, username): users = User_account.objects.all() for user in users: if username == user.username: return render(request, 'account_app/profile.html', context={"user_info":user}) def users_list(request): users = User_account.objects.all() return render(request, 'account_app/users_list.html', context={"user_info":users}) -
Not able to load images from static folder in django
I a not able to load image from static dir in Django. Below is the picture of my file structure. In settings.py S STATIC_URL = '/static/' STATICFILES_DIR = [ os.path.join(BASE_DIR,'static') When I try to load the image file from STATIC_URL, it is producing this error: it is just not loading images but the text from my home-view.html is loading file thus django is not able to locate the image files. Could you please advise why are images not loading? My complete settings.py file : """ Django settings for myproject project. Generated by 'django-admin startproject' using Django 4.0.4. For more information on this file, see https://docs.djangoproject.com/en/4.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent print("Path is : ", os.path.join(BASE_DIR, 'myproject/template')) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-(ep(j)h+$(zro2!9r3bm0fj^!84-1c9d+)$be4hgrq4_#6d^r-' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myproject' ] MIDDLEWARE … -
How to get a relation from a relation in a serializer?
I have 3 models: class Artist(Timestamps): name = models.CharField('Name', max_length=255, blank=True) ... class Festival(Timestamps): name = models.CharField(max_length=255, blank=True) ... class Event(Timestamps): artist = models.ForeignKey(Artist, on_delete=models.CASCADE, null=True) festival = models.ForeignKey(Festival, on_delete=models.CASCADE, null=True) Now I wan't all the id's from the festivals an artist is playing. I have a serializer like this: class ArtistFestivalSerializer(serializers.ModelSerializer): class Meta: model = Artist fields = ('id', 'name', 'event_set') But this only gives me the id's of the event. Any ideas how to get trough the Event to the Festival? Thanks in advance -
Django : Inheritance error- TemplateSyntaxError at / “Could not pass the remainder”
I have a website running using Django that uses the following dgango blocktag to render text within a base.html file. {% block content %} <h1>Welcome </h1> <p1> This is the site template </p1> {% endblock content %} However, to describe a page content and not the site itself, I have the following page.html which is meant to inherit the code from base.html {% extends “base.html” %} {% block content %} <h1>Greetings</h1> <p>The_page_template</p> {% endblock content %} Changing views.py from render base.html to render page.html as follows causes the error. from django.shortcuts import render def index(request): #return render(request, "base.html") // this works return render(request, 'pages/page.html') // this does not The uploaded image is a screenshot of the broken webpage. The best explanation I can offer is that there is an error in the spacing of the code or the pathing to page.html. With pathing I do notice the broken webpage does point to page.html. The following is a relevant statement from settings.py ‘DIRS’: [BASE_DIR / ‘site/templates’] 'APP_DIRS' : TRUE For the sake of completeness, the following paths are described. root/site/templates/base.html root/pages/templates/pages/page.html root/pages/views.py root/site/settings.py Any help appreciated in resolving this error - thanks -
I am new to Django and I can't understand a few errors related to os.environ.setdefault
I found a GitHub repo for reference and practice but when I'm trying to run it on my system it is giving me this error: Traceback (most recent call last): File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\homiechat\manage.py", line 22, in main() File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\homiechat\manage.py", line 9, in main os.environ.setdefault('DJANGO_SETTINGS_MODULE', config('LOCAL_SETTINGS_MODULE')) File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\env\lib\site-packages\decouple.py", line 199, in call return self.config(*args, **kwargs) File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\env\lib\site-packages\decouple.py", line 83, in call return self.get(*args, **kwargs) File "C:\Users\Nikita\Desktop\GitHub files\HomieChat-main\env\lib\site-packages\decouple.py", line 68, in get raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option)) decouple.UndefinedValueError: LOCAL_SETTINGS_MODULE not found. Declare it as envvar or define a default value. I can't understand what this error means. I installed the requirements.txt but it's the same. On searching the project for LOCAL_SETTINGS_MODULE, I found: os.environ.setdefault('DJANGO_SETTINGS_MODULE', config('LOCAL_SETTINGS_MODULE')) in settings.py, asgi.py, and wsgi.py. I need to understand what this LOCAL_SETTINGS_MODULE is and how to fix this error. -
NGINX slow static file serving
I have a web service served by nginx. I'm using protected routes and nginx X-Accel header from my web server. However these files served slowly compared to other services on the same server. For example downloading media files is around 1MB/s. Server usual upload link is around 400-500Mbps. This is the relevant nginx configuration: server { listen 80; # Set correct charset charset utf-8; sendfile on; sendfile_max_chunk 0; proxy_max_temp_file_size 0; tcp_nopush on; tcp_nodelay on; keepalive_timeout 5; types_hash_max_size 2048; server_tokens off; client_body_buffer_size 1k; client_header_buffer_size 1k; client_max_body_size 4M; large_client_header_buffers 2 1k; client_body_timeout 10; client_header_timeout 10; send_timeout 10; location /protected/media/ { internal; alias /media/; try_files $uri $uri/ =404; } } This nginx instance is running in Docker, files are mapped as volumes for this container. Eg.: the /media/ folder is mapped as a volume from host. The host folder is a local folder, so it is not a mounted network folder.