Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
HTML audio not working inside nested div containers
I am having problem playing audio in html. The audio plays well when I keep the audio tag inside a div container but it doesn't play when I put it inside another div. See the code for better understanding of problem. Note:this code is a part of a django project. Case#1:(Works) {% load staticfiles %} <html> <head> <link rel="stylesheet" href="{% static 'home.css' %}" type="text/css"> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="{% static 'home.js' %}"></script> </head> <body> <div id = "buttons"> <center> <progress id="seekbar" value="0" max="1" style="width:300px; margin:20px 5px 5px 0; background-color:red; height:5px"></progress> <audio src="{{ song.file.url }}" id="player"></audio> <button id = "prev" onclick = "prev()">PREV</button> <button id = "play" onclick = "play()">PLAY</button> <button id = "pause" onclick = "pause()">PAUSE</button> <button id = "next" onclick = "prev()">NEXT</button> </center> </div> </body> </html> song.file.url is the location to the audio file. Case#2:(Doesn't works) {% load staticfiles %} <html> <head> <link rel="stylesheet" href="{% static 'home.css' %}" type="text/css"> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="{% static 'home.js' %}"></script> </head> <body> <div id = "player"> <div id = "buttons"> <center> <progress id="seekbar" value="0" max="1" style="width:300px; margin:20px 5px 5px 0; background-color:red; height:5px"></progress> <audio src="{{ song.file.url }}" id="player"></audio> <button id = "prev" onclick = "prev()">PREV</button> <button id = "play" onclick = "play()">PLAY</button> <button … -
django CreateView not calling methods when passing form_class
I'm fairly new to python(3.5)/django(1.10), and I've run into the following problem: I am using Django's generic CreateView to create a model and respective children model. My objective is to save information about a purchase. A purchase is composed of a Bill and one or many Receipt. To accomplish this, I've created a custom Form (BillForm) with a custom field where user can input coma separated values that will be used to create receipts. Here is what I have: models.py class Bill(models.Model): """ A given bill whenever an item is purchased.""" number = models.CharField(_('Number'), max_length=20) purchase_date = models.DateTimeField(_('Purchase Date')) company = models.ForeignKey(Company, verbose_name=_('Company'), on_delete=models.DO_NOTHING) ... def _get_receipts(self): ''' returns all receipts that related to a bill ''' return Receipt.objects.filter(bill = self) receipts = property(_get_receipts) class Receipt(models.Model): """ A receipt confirming a product is in our posession """ number = models.CharField(_('Number'), max_length=20) bill = models.ForeignKey(Bill, verbose_name=_('Bill'), on_delete=models.DO_NOTHING) urls.py: url(_(r'^create_purchase/$'), views.ObjectCreateView.as_view( model=Bill, form_class=BillForm ), name="create_purchase"), forms.py: class BillForm(forms.ModelForm): ''' A form used to create a Purchase Bill. ''' receipts = MultipleReceiptsField(label=_("Receipts"), widget=forms.Textarea) def __init__(self, *args, **kwargs): ''' constructor used to filter the companies. ''' # executes super(BillForm, self).__init__(*args, **kwargs) self.fields['company'].queryset =\ Company.objects.filter(is_provider=True).filter(is_active=True) def save(self, commit=True): ''' createe receipts when saving a bll … -
Django oath2 authentication backend for mobile users
I have been working on a android project in which I am using django as my backend. I am also using django-rest-framework. Here is my flow: 1.Android users signup with their mobile numbers. Mobile number is verified using One Time Password method. 2.If the user is successfully verified, I want to create oath2 credentials (client Id and client secret) for that user and send back to user. 3.To request further, user should get Access token by providing client Id and client secret I have Implemented first one, however to implement second and third I am using django-oath2-toolkit(https://django-oauth-toolkit.readthedocs.io/en/latest/rest-framework/getting_started.html#step-1-minimal-setup). PROBLEM: I don't know if it is a correct library to use for this use case. I want to dynamically generate client Id and client secret when the verification is successful. But the DOC does not have any methods to generate dynamically. It says to manually create credentials by going to http://localhost:8000/o/applications/ Are there any libraries to use other than this for my use case ? -
Django admin custom admin widget, how to disable required?
ive added a custom widget to my admin form that just displays data and when i try save the form i get field is required on my custom widget, how can i set this to not required? Thanks forms.py class TemplateVariablesWidget(forms.Widget): template_name = 'networks/config_variables.html' def render(self, name, value, attrs=None): c_vars = ConfigVariables.objects.all() context = { 'ConfigVariables' : c_vars } return mark_safe(render_to_string(self.template_name, context)) class VariableForm(forms.ModelForm): variables = forms.CharField(widget=TemplateVariablesWidget) class Meta: model = ConfigVariables fields = "__all__" admin.py class ConfigTemplateAdmin(admin.ModelAdmin): form = VariableForm list_display = ('device_name', 'date_modified') admin.site.register(ConfigTemplates, ConfigTemplateAdmin) error: -
ImproperlyConfigured: The SECRET_KEY setting must not be empty in Apache and wsgi_mod
I'm trying to deploy Django project on Apache and wsgi_mod in Windows 10. What I did so far: 1. Added following in httpd.conf of Apache conf folder WSGIScriptAlias / "C:/Bitnami/djangostack-1.10.1-0/apps/django/django_projects/project/egeirn/wsgi.py" WSGIPythonPath "C:/Bitnami/djangostack-1.10.1-0/apps/django/django_projects/project;C:/Bitnami/djangostack-1.10.1-0/python/Lib/site-packages" <Directory "C:/Bitnami/djangostack-1.10.1-0/apps/django/django_projects/project/egeirn"> <Files wsgi.py> Require all granted </Files> </Directory> 2. Following is the content of my wsgi.py file: import os import sys from django.core.wsgi import get_wsgi_application sys.path.append('C:/Bitnami/djangostack-1.10.1-0/apps/django/django_projects/project') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "egeirn.settings") application = get_wsgi_application() When I start the Apache server, it gives the following error in logs file: [Thu Nov 03 17:47:11.328063 2016] [:error] [pid 916:tid 1236] [client ::1:63236] mod_wsgi (pid=916): Target WSGI script 'C:/Bitnami/djangostack-1.10.1-0/apps/django/django_projects/project/egeirn/wsgi.py' cannot be loaded as Python module., referer: http://localhost:82/ [Thu Nov 03 17:47:11.328063 2016] [:error] [pid 916:tid 1236] [client ::1:63236] mod_wsgi (pid=916): Exception occurred processing WSGI script 'C:/Bitnami/djangostack-1.10.1-0/apps/django/django_projects/project/egeirn/wsgi.py'., referer: http://localhost:82/ [Thu Nov 03 17:47:11.328063 2016] [:error] [pid 916:tid 1236] [client ::1:63236] Traceback (most recent call last):, referer: http://localhost:82/ [Thu Nov 03 17:47:11.328063 2016] [:error] [pid 916:tid 1236] [client ::1:63236] File "C:/Bitnami/djangostack-1.10.1-0/apps/django/django_projects/project/egeirn/wsgi.py", line 18, in <module>, referer: http://localhost:82/ [Thu Nov 03 17:47:11.328063 2016] [:error] [pid 916:tid 1236] [client ::1:63236] application = get_wsgi_application(), referer: http://localhost:82/ [Thu Nov 03 17:47:11.328063 2016] [:error] [pid 916:tid 1236] [client ::1:63236] File "C:\\Bitnami\\djangostack-1.10.1-0\\apps\\django\\django-1.10.1-py2.7.egg\\django\\core\\wsgi.py", line 13, in get_wsgi_application, referer: http://localhost:82/ [Thu Nov 03 17:47:11.328063 … -
Invert boolean field in update operations with F()
I need, through a update operation, revert a boolean value. I tried: Item.objects.filter(serial__in=license_ids).update(renewable=not F('renewable')) But it doesn't work. I made sure the fields are not set to null. -
how to get django-cas server to return to original site after successful login
I'm using django-cas(https://pypi.python.org/pypi/django-cas-server/0.7.4) as single point of authorization for my several servers. So I redirected my index page to location of cas server. After successful login, How do I redirect it back to original site? It just returns an html with login successful html. Thanks joseph -
Django Rest Framework "django.db.utils.ProgrammingError: relation "patient" does not exist"
I'm using Django Rest Framework in my project. I have written tests: class PatientTests(APITestCase): def test_create_patient(self): url = reverse('patient-list') data = {'firstname': 'ivan', 'lastname': 'ivanov'} response = self.client.post(url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(Patient.objects.count(), 1) self.assertEqual(Patient.objects.get().firstname, 'ivan') def test_get_patient(self): url = reverse('patient-detail', args=[1]) response = self.client.get(url) self.assertEqual(response.data, {'firstname': 'ivan'}) When I run the test I get the error: "django.db.utils.ProgrammingError: relation "patient" does not exist". As I understand, this error occurs if the table is not created in the test database. What must I do? Thanks -
Django all_auth and custom form
I'm using django allauth for social login/signup. Also, I've my own signup form as an alternate login/signup. Following are the fields that I'm fetching from the user in the alternate form. class Profile(models.Model): col1 = models.CharField(max_length=50, blank=True, null=True) col2 = models.CharField(max_length=50, blank=True, null=True) user = models.OneToOneField(User) So, when the user signs up, it asks for additional fields as well(col1, col2), apart from username, email and password. Following is the signup view. user = User.objects.create_user(username, user_email, user_pass) Profile.objects.create(user=user, col1=col1, col2=col2) return So, whenever the user signs up via the alternate form, the above view is called up. Now, in contrast, when the user signs up from social account FB, it does not ask for extra info, ie col1/col2. It directly signs up without asking for extra info, neither I want it to ask. I then create a row in Profile model post signup using signals. @receiver(user_signed_up) def create_profile(request, user, sociallogin=None, **kwargs): if sociallogin: if sociallogin.account.provider == 'facebook': data = sociallogin.account.extra_data col1 = data.get('col1') col2 = data.get('col2') Profile.objects.create(user=user, col1=col1, col2=col2) So, (1) my problem is when creating a user using alternate form, no record is inserted in allauth tables, which i find weird. (2) Consider, I signed up using alternate form using … -
Django Dynamic Choices for a Field Based On Another Field
I have a simple model, let's call it Person. Person has a CharField named Topic with some choices, for example: 'Food', 'Cars', 'Colors'. Person has another CharField named Favorite, which currently has no choices. I would like to populate Favorite's choices according to the selected value in Topic. Let's say I'm in the admin UI editing a Person and I set his Topic to be 'Food', so I want the values in the drop down list of Favorite to change to: 'Pizza', 'Cake', 'French Fries'. How can I do this with Django? To me the solution sounds like JavaScript but I'd rather put it as my last option. Thanks in advance. -
How to run 2 sites with Django channels on the same host?
I tried to start 2 daphne servers and 2 workers with supervisord. But sometimes requests from site #1 are on worker #2 and requests from site #2 are on worker #1. Should I use different Redis servers? Rly? Or am I missing some parameter in settings? CHANNEL_LAYERS = { 'default': { 'BACKEND': 'asgi_redis.RedisChannelLayer', 'CONFIG': { 'hosts': [('{{redis_server}}', 6379)], }, 'ROUTING': '{{app}}.routing.channel_routing', }, } -
Heroku database table primary key doubled itself overnight
I have this Django (v 1.8) app on free heroku dyno. For purpose of this post I am simplifying my app a bit, but essentially, this the model i use in my app. class PartyGuest(models.Model): name = models.CharField(max_length=100) surname = models.CharField(max_length=100) reservation_number = models.CharField(blank=True, max_length=20, null=True) def create_reservation_number(sender, instance, **kwargs): if instance.reservation_number is None: initials = instance.name[0].upper()+instance.surname[0].upper() instance.reservation_number = "{0:03d}".format(instance.id)+initials instance.save() post_save.connect( create_reservation_number, sender=PartyGuest, dispatch_uid="update_reservation_number" ) Users fill my form online, and are saved into this model, then they recieve reservation number, would be XXXYY, where XXX is the the id in database, and YY are initials of that person (e.g. for "John Doe" would be "001JD"). So two days ago last user on my website had database id number equal 33, but next user (registered yesterday) has number 66. There were no new users between 33 and 66. I have no clue what happened. One possible explanation could be that heroku database had some kind of malfunction and doubled its contents, and then deleted them. I am looking for a cause of that bug, as well as possible way to avoid it in the future. If you need more details please ask. -
ModelViewSet - Selectively hide fields?
I have an Instructor model, which has a many to many field to a Client model. (Instructor.clients) My serializer is currently: class InstructorProfileSerializer(serializers.ModelSerializer): class Meta: model = models.InstructorProfile fields = '__all__' And viewset: class InstructorProfileViewSet(viewsets.ModelViewSet): """ViewSet for the InstructorProfile class""" queryset = models.InstructorProfile.objects.all() serializer_class = serializers.InstructorProfileSerializer permission_classes = [permissions.IsAuthenticated] I'd like to prevent access to the clients field to everyone except the user which Instructor belongs to (available in the Instructor.user model field). How can I achieve this? -
How can I get ALL tweets with a certain hashtag from latest 7 days?(without 100 limit)
How can I get ALL tweets with a certain hashtag from latest 7 days?(without 100 limit) import requests from .models import Tweet ... r = requests.get('https://api.twitter.com/1.1/search/tweets.json?q=%23python&count=100', auth=auth) for tweet in r.json()['statuses']: tweet_obj = Tweet() tweet_obj.text = tweet['text'] tweet_obj.save() -
Invalid template library specified
# -*- coding: utf-8 -*- from django.shortcuts import render from django.http import JsonResponse from django.contrib.auth import get_user_model from django.conf import settings from django.core.mail import send_mail, BadHeaderError from django.http import HttpResponse, HttpResponseRedirect from django.template import loader from django.core.mail import send_mass_mail from django.contrib import messages from django.contrib.auth.decorators import user_passes_test import json import datetime from models import Competence, Question, Answer, Profession, PROFESSION_CHOICES,\ Service, CustomUser, Tag def index(request): return render(request, 'competentions_app/index.html', {}) Traceback (most recent call last): File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner response = get_response(request) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/var/www/sampleapp/competences/competentions_app/views.py", line 21, in index return render(request, 'competentions_app/index.html', {}) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/shortcuts.py", line 30, in render content = loader.render_to_string(template_name, context, request, using=using) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/loader.py", line 67, in render_to_string template = get_template(template_name, using=using) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/loader.py", line 18, in get_template engines = _engine_list(using) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/loader.py", line 72, in _engine_list return engines.all() if using is None else [engines[using]] File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/utils.py", line 89, in all return [self[alias] for alias in self] File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/utils.py", line 80, in getitem engine = engine_cls(params) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/backends/django.py", line 30, in init options['libraries'] = self.get_templatetag_libraries(libraries) File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/backends/django.py", line 48, in get_templatetag_libraries libraries = get_installed_libraries() File "/var/www/sampleapp/env/local/lib/python2.7/site-packages/django/template/backends/django.py", line … -
Why clean method in my form will not clean?
I wrote a clean method on my form and it is not actually doing the validation. class Property1Form(forms.ModelForm): class Meta: model = Property1 fields = ['unit','propertytype','is_true','date','followup_date','quantity','description'] def __init__(self, *args, **kwargs): super(Property1Form, self).__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance: self.fields['unit'].required = False self.fields['unit'].widget.attrs['disabled'] = 'disabled' def clean(self): form_data = self.cleaned_data if Property1.objects.filter(unit=form_data['unit'], propertytype=form_data['propertytype'] ).count() > 0: self._errors["propertytype"] = ["Propertytype already exists for unit"] # Will raise a error message del form_data['propertytype'] Same validation does work for me on model level but on model level I am getting 500 error ValidationError at /unit/property/new/6/http://127.0.0.1:8000/unit/property_details/6/ {'all': [u'Same property cant be assigned more then ones']} So trying to have same validation on the form side as well. -
Django setUpTestData() does not work with inheritance?
class MotherTestCase(TestCase): @classmethod def setUpTestData(cls): cls.my_value = "foo" class ChildTestCase(MotherTestCase): def test_basic(self): self.assertEqual(self.my_value, "foo") When running this test, I get a AttributeError: 'ChildTestCase' object has no attribute 'my_value' How can you explain this? I thougt I need to call super() but the Django doc doesn't say so I saw a related issue on Github but it's 1 year old and seems to be fixed. -
Authorize swagger ui with django
i'm writing a REST API with django-rest-framework and oauth2 for authentication purpose. I'm also using django-rest-swagger to document my APIs but i have a problem with the authorization in the Swagger UI. Pratically i don't understand how i may define the authorizationUrl parameter, these are the settings i'm using: SWAGGER_SETTINGS = { 'USE_SESSION_AUTH': False, 'APIS_SORTER': 'alpha', 'SECURITY_DEFINITIONS': { 'oauth2': { 'type': 'oauth2', 'description': 'Personal API Key authorization', 'name': 'Token', 'in': 'header', 'flow': 'implicit', 'authorizationUrl': 'http://localhost:8000/api/user/login' } }} The question is: How must i define a page where the user enter his username and password to see all the documentations APIs? Thanks in advance -
Get Table selection and File in same form POST
I have a django template that houses a django_table2 table, and also accepts a file: {% extends 'portal/base.html' %} {% load render_table from django_tables2 %} {% block title %}{{user.first_name }} {{ user.last_name }} Portal{% endblock %} {% block content %} <input type=button value="Back" onClick="javascript:history.go(-1);"> <h4>Currently registered vehicles:</h4> <div class='vehlist'> <form action="/loadlocndb/" method="POST"> {% csrf_token %} {% render_table veh_list %} <h4> Location database .csv file</h4> <input type="file" name="myfile"><br/> <input type="submit" value="Submit" /> </form> </div> {% endblock %} Currently the only thing passed back in POST is the selected table checkboxes. How do I also pass back the file as well. views.py @login_required def locndb(request): # This is the basic user landing Page veh_list =VehicleTable(Vehicle.objects.filter(company__user=request.user)) form = LocnDBForm() RequestConfig(request).configure(veh_list) return render(request, 'portal/locndb.html', {"veh_list": veh_list, "form": form}) @login_required def loadlocndb(request): if request.method == "POST": pks = request.POST.getlist("update") print pks selected_objects = Vehicle.objects.filter(pk__in=pks) vlist = [] for i in selected_objects: vlist.append(i) return render(request, 'portal/loadlocndb.html',{"vlist":vlist}) Even better is how would stop the user from processing without selecting at least one entry in the table and also a file. Thanks -
Improving the Django Query
I am trying to optimize the following Django view. def test_view(request, username): msgs = MyModel.objects.filter(name=username, created_at__range=[start_date, end_date]).order_by('-id') arr = [] for msg in msgs: c = TestModel.objects.get(id=msg.test_id) c.user_name = username c.last_time = msg.created_at if collection not in arr: arr.append(c) return render(request, "test.html", {'context': arr}) So I have two models. MyModel TestModel Currently I can see the following ways to improve. Use values in filter query to get only test_id and created_at. Use the mysql Distinct keyword in Django to uniquely search on test_id Unnecessary looping through the data queryset. Again searching for collection in arr seems really unnecessary and time consuming. I am relatively new to Django. So any help on how I should proceed or any links I should read would be appreciated. -
What is models class in mongodb-Django?
While working with models in django framework, from django.db import models class funtion_name(models.Model): blah1 = models.CharField() . . . So, my database is mongodb and it has some collections and each collection has some documents(database is already populated with data). Now I've to display data from this database in my django application.I've configured the DATABASES in settings.py. I don't understand what exactly is models?(I know it's a class,but what is it pointing to in mongodb database terminology) What should I do to deal with documents? -
django fetch two values but distinct on one
I have the following query. test = TestTable.objects.filter(name='John', created_at__range=[start_date, end_date]).order_by('-id') The TestTable model has a field called test_id and 'created_at'. I want to fetch all the rows with unique test_id. So the output should be ------------------------ id |test_id | created_at ------------------------ 1 | 3 | 01-12-2015 2 | 2 | 21-12-2015 3 | 1 | 01-18-2015 -
How can I have a template folder outside my Django project
I'm working on an Open Source Django app and created some design for it. Now a customer wants to use it's own, copyrighted, design. After reading the Django docs I created a separate, private, GIT repository that I want to use for the new design. I got it almost working by adding 2 items to the settings; an extra entry to look for templates in a folder "funder_custom_templates" and an extra entry to look for static files in the same location. This is how I configured TEMPLATES and STATICFILES_DIR: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(PROJECT_DIR, '..', '..', 'funder_custom_templates'), os.path.join(PROJECT_DIR, 'templates'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'fundraiser.context_processors.cart', ], }, }, ] STATICFILES_DIRS = [ os.path.join(PROJECT_DIR, '..', '..', 'funder_custom_templates','static'), os.path.join(PROJECT_DIR, 'static'), ] This works for overriding the base design located in the PROJECT_DIR/templates/base.html, when I create funder_customer_templates/base.html and for all the static files as expected. But I also want to override app specific template files like blog/templates/blog/blog_index_page.html I tried to put these files in the root of funder_custom_templates and I tried to mimic the app folders structure in funder_custom_templates but that doesn't load the app specific templates. Is there a way to solve … -
Token Authentication Django Rest Framework HTTPie
Hello I am trying to test Token Authentication i have implemented with DRF using httpie as per the tutorial in this following link The following command: http GET 127.0.0.1:8000/api/projects/ 'Authorization: Token b453919a139448c5891eadeb14bf1080a2624b03' yields the following error. usage: http [--json] [--form] [--pretty {all,colors,format,none}] [--style STYLE] [--print WHAT] [--headers] [--body] [--verbose] [--all] [--history-print WHAT] [--stream] [--output FILE] [--download] [--continue] [--session SESSION_NAME_OR_PATH | --session-read-only SESSION_NAME_OR_PATH] [--auth USER[:PASS]] [--auth-type {basic,digest}] [--proxy PROTOCOL:PROXY_URL] [--follow] [--max-redirects MAX_REDIRECTS] [--timeout SECONDS] [--check-status] [--verify VERIFY] [--ssl {ssl2.3,ssl3,tls1,tls1.1,tls1.2}] [--cert CERT] [--cert-key CERT_KEY] [--ignore-stdin] [--help] [--version] [--traceback] [--default-scheme DEFAULT_SCHEME] [--debug] [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]http: error: argument REQUEST_ITEM: "Token" is not a valid value So i decided to differ from the tutorial and made my request like this http GET 127.0.0.1:8000/api/projects/ 'Authorization:b453919a139448c5891eadeb14bf1080a2624b03' The following message was returned HTTP/1.0 401 Unauthorized Allow: GET, POST, HEAD, OPTIONS Content-Type: application/json Date: Thu, 03 Nov 2016 09:52:05 GMT Server: WSGIServer/0.1 Python/2.7.10 Vary: Accept WWW-Authenticate: Token X-Frame-Options: SAMEORIGIN { "detail": "Authentication credentials were not provided." } Any assistance offered would be great. I am running on local machine at home. -
Django app has wrong urls when configured on nginx+uwsgi with subpath
I am trying to configure nginx and uwsgi to serve django (wagtail to be exact) app on /blog subpath. Most answers to this question (like this one) suggest using: location /blog { include uwsgi_params; uwsgi_pass unix:/run/uwsgi/application.sock; uwsgi_param SCRIPT_NAME /blog; uwsgi_modifier1 30; } Unfortunately it does not work for me. Accessing /blog duplicates subpath and redirects to /blog/blog/. Wagtail then shows its 404 page as /blog/blog/ does not exist. I am not sure whether it's nginx or django problem.