Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
NoReverseMatch at /display_maintenance 'example' is not a registered namespace
I keep staring at this and no joy. My urls.py file. All of the files are displaying except 'display_maintenance.html' from django.contrib import admin from django.urls import path, include from example import urls as example_urls from example import views as example_views urlpatterns = [ path('admin/', admin.site.urls), path('', example_views.home, name="home"), path('add_location', example_views.add_location, name='add_location'), path('add_device', example_views.add_device, name='add_device'), path('add_maintenance', example_views.add_maintenance, name='add_maintenance'), path('display_maintenance', example_views.display_maintenance, name='display_maintenance'), path('device_list', example_views.device_list, name='device_list'), path('search_device', example_views.search_device, name='search_device') ] Here's the views.py where the error is hanging on the return render: def display_maintenance(request): maintenance = Maintenance.objects.all() context = {"maintenance": maintenance} for item in maintenance: item.devices = Devices.objects.filter(maintenance=item) return render(request, 'example/display_maintenance.html', context) And finally, the html file. I'm baffled: def display_maintenance(request): maintenance = Maintenance.objects.all() context = {"maintenance": maintenance} for item in maintenance: item.devices = Devices.objects.filter(maintenance=item) return render(request, 'example/display_maintenance.html', context) -
What method to choose for designing the study on Amazon Mechanical Turk?
I would like to choose a method for psychological study design, which I want to implement in Amazon Mechanical Turk. The experiment requires dragging and dropping images and some specific randomization, so I can't use platforms like Qualtrics or SurveyMonkey (I think I can't). So I want to create my own experiment and put it on a server. I would use Django and PsychoPy package, but I'm afraid Django is overcomplicated for such a project (I want to have just a csv or a json file with participants' data as output). The second idea is just a javascript, but I feel more comfortable in python. What is your advice? Maybe there is a better option? Thanks for answers. -
Why am I not being able to save my addresses?
Hi I'm trying to develop an e-commerce website with django. I want to use ajax to handle my checkout form. When I added Ajax, after filling out the form and clicking the submit button, I am seeing that my form and data is not getting saved by going into my admin. It's also not being redirected to return HttpResponseRedirect(reverse(str(redirect))+"address_added=True"), rather it's being redirected to http://127.0.0.1:8000/checkout/?csrfmiddlewaretoken=u6hDPBVuOZbDmoHvRFWb2PvfK1YamCIKGSaDkKdVTviWvJODgY5lM6rKppoW1oeP&address=123+Main+Street&address2=&state=MA&country=USA&zipcode=55525&phone=%28877%29+314-0742&billing=on.Can anyone please help me out with what's actually wrong? My accounts.views.py: from django.shortcuts import render, HttpResponseRedirect, Http404 from django.contrib.auth import logout, login, authenticate from django.contrib import messages from .forms import LoginForm, RegistrationForm, UserAddressForm from django.urls import reverse def add_user_address(request): try: redirect = request.GET.get("redirect") except: redirect = None if request.method == "POST": form = UserAddressForm(request.POST) if form.is_valid(): new_address = form.save(commit=False) new_address.user = request.user new_address.save() if redirect is not None: return HttpResponseRedirect(reverse(str(redirect))+"address_added=True") else: raise Http404 My urls.py: path('ajax/add_user_address/', accounts_views.add_user_address, name='ajax_add_user_address') My checkout.html: <div class="content-section"> <form method="POST" action='{% url "ajax_add_user_address" %}?redirect=checkout'> {% csrf_token %} <fieldset class="form-group"> {{ address_form|crispy }} <input type="submit" class="btn btn-dark" value="Place Order"/> </fieldset> </form> </div> My orders.views.py: from accounts.forms import UserAddressForm from accounts.models import UserAddress @login_required() def checkout(request): try: the_id = request.session['cart_id'] cart = Cart.objects.get(id=the_id) except: the_id = None return redirect(reverse("myshop-home")) try: new_order = Order.objects.get(cart=cart) … -
How to use Django's include without a string literal?
I just started up with django. Following this tutorial, I ended up with the following urls.py: from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', admin.site.urls), ] This links to polls.urls.py which has its own router. The part I don't like is the string literal 'polls.urls' which is, well... a string literal. I would like to somehow reference the file directly using some of python's power, and have AT LEAST my IDE protect me. What happens if I want to move that polls.urls.py file, or rename it, or rename polls? Should I trust my IDE to catch a reference from a string literal? This is almost like doing this monstrosity, and is very hard for me to accept as the best practice. It just seems odd to me. Is there a way to use something less prone to errors than string literals in django's routers? -
Hardcode Initial Data to Redux store in Django/React app
I have a React-Redux app which currently makes an API call to my Django backend to receive data to be displayed on a dashboard. The problem I am having is with data size and load times. Currently, the entire JSON packet is around 6MB and the total request time is around 1.5-2 minutes. I noticed that when I hardcode the "initial data" to the same data packet within my Redux Reducer, the load time is instantaneous. My question is- is there any existing methods that exist that would allow me to either periodically update this "Initial Data" from the backend. Or are any other recommended methods to speed this data transfer up? Unfortunately I cannot use pagination, as I need the entire data packet for the React app to work efficiently. Thanks for your time! -
Can Django do an UPDATE INNER JOIN, meaning update one model from another based on a matching field, for example ID
Is is possible in Django to do a so called UPDATE INNER JOIN, meaning update one table from another based on a matching field, like ID for example. To give more context, in PostgreSQL you would achieve this with a query such as: UPDATE users SET name = R.name, FROM renamed_users R WHERE users.id = renamed_users.id; Ref: https://www.postgresqltutorial.com/postgresql-update/ -
Django - Importing Movie dataset to the models
My goal is to upload my movie poster dataset to my django website. Each model created must have a poster image, a title, some main actors, a director and a release date. Any Idea on how this can be accomplished? Please let me know if I'm not specific enough. Thanks in advance! -
Reverse for 'yourchoice' not found. 'yourchoice' is not a valid view function or pattern name
I'm very new. I've created an application on a webproject with django. I'm facing the following error Reverse for 'yourchoice' not found. 'yourchoice' is not a valid view function or pattern name. But I have the function in the views.py. This is the part of views.py def yourchoice(request, courseId): course = get_object_or_404(AllCourses, pk=courseId) try: selected_ct = course.details_set.get(pk=request.post('[choice]')) except (KeyError, AllCourses.DoesNotExist): raise render(request, 'technicalCourse/details.html', { 'choice': choice, 'error': 'Enter a valid option' }) else: selected_ct.choice = True selected_ct.save() return render(request, 'technicalCourse/details.html', {'courseObj': course}) This is the part of html.I'm getting error in the form tag. <form action="{% url 'technicalCourse:yourchoice' courseId.id %}" method="post"> {% csrf_token %} {% for choice in courseObj.details_set.all %} <input type="radio" name="choice" id="choice{{forloop.counter}}" value="{{courseId}}"> <label for="choice{{forloop.counter}}">{{ choice.ct }}</label><br> {% endfor %} <input type="submit" value="submit"> </form> I've also added this in the urls.py with necessary imports app_name="technicalCourse" urlpatterns = [ path('<int:courseId>/',views.details,name='details_page'), path('', views.course,name='Home_page'), path('<int:courseId>/yourchoice/', views.yourchoice,name='your_choice'), ] How to resolve this. Thanks in Advance -
Django: Help understanding a signal-function
Good evening, I know, I asked a similar Question just a while ago, but I still got problems in understanding the more detailled functions of a signal. So I'm hoping someone can help me out with this one!? As an example I have a class in my "models.py" like this one: class ExampleModel(models.Model): name = models.CharField(max_length=255, null=False, blank=False) value1 = models.IntegerField() value2 = models.IntegerField() value_of_1_and_2 = models.IntegerField() def __str__(self): return self.name I would like to have my field "value_of_1_and_2" filled automatically with the sum of the other two fields before saving... Is this possible? I tried some things and got stuck with a "pre_save" like this: @receiver(pre_save, sender=ExameplModel) def save(self, *args, **kwargs): ... Thanks for all of your help and a nice evening to all of you! -
Package Django on closed system (no pip)
I'm developing a web app in Django and React, but I just tried installing the Django backend on the server (Linux) to test the API, and the server doesn't have access to pip but does have python 3 installed. The firewall blocks access to the pip repository; and unfortunately, I can't change that. So I'm going to have to package the app with all the dependencies together, but I've never really had to do that before, so I need to know the following info: Is it as simple as copying the site-packages folder from my dev system to a folder like bin/site-packages? If so, do I need to do something different in my Django settings to use the alternate package locations? Do I have to package python3.7 in the bin folder as well? I looked at a few other apps that have packages included, but they weren't specifically Django and the setup was really confusing, but it looks possible. I just don't know where to start. Any info you can provide would be greatly appreciated. Thank you in advance. -
Include Django snippets using both apostrophe and quotation marks
I include a snippet on my app like this: {% include "snippets/title.html" with title='Homepage' and subtitle='Welcome to my site' %} I'd like to pass in the subtitle string It's great to have you here "friend", which uses both apostrophes and quotation marks. The problem is that I cannot use triple brackets """ inside my include statement, which means I have to use either a apostrophe ' or quotation mark " to wrap my string. How can I do this? the below examples all do not work {% include "snippets/title.html" with title='Homepage' and subtitle='It's great to have you here "friend"' %} {% include "snippets/title.html" with title='Homepage' and subtitle="It's great to have you here "friend"" %} {% include "snippets/title.html" with title='Homepage' and subtitle="""It's great to have you here "friend"""" %} I would prefer a solution that does not require me to escape punctuation inside my string. -
Get user information in django templates and and checking weather its = to authors name
I'm not able to query the username and couldn't compare to the author . it worked for one case which is posted below...please I need urgent help .stuck on a project . thanks in advance ``` {% if user.is_authenticated %} {% if user.get_username == blog.author %} <a href="{% url 'update' pk=blog.pk %}"><i class="fas fa-pen fa-2x fa-spin"></i></a> {% endif %} {% if user.is_superuser %} <a href="{% url 'update' pk=blog.pk %}"><i class="fas fa-pen fa-2x fa-spin"></i></a>/ <a href="{% url 'delete' pk=blog.pk %}"><i class="fas fa-trash-alt fa-2x fa-spin"></i></a> {% endif %} {% endif %} *my view * @login_required(login_url='login') def update_post(request, pk): post = get_object_or_404(Post, pk=pk) if request.method == 'POST': form = EditPost(request.POST, request.FILES, instance=post) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.last_edited = timezone.now() post.save() return redirect('blog', pk=post.pk) else: form = EditPost(instance=post) context = {'form': form} return render(request, 'blog/edit_post.html', context) my model class Post(models.Model): author = models.ForeignKey('auth.User', on_delete=models.CASCADE) title = models.CharField(max_length=200, null=True) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) pub_date = models.DateTimeField(blank=True, null=True) last_edited = models.DateTimeField(null=True, blank=True) def __str__(self): return f'{self.title} by author {self.author}' but it worked for {% for comment in blog.comments.all %} <cite>{{ comment.author }}</cite> <time class="comment__time">{{ comment.created_date }}</time> {% if user.is_authenticated and request.user.username == comment.author %} <a class="reply" href="{% url 'remove' pk=comment.pk … -
Why do I get a No Reverse Match error in this case?
So, this is what's going on: I am able to get a blog post in my Django 2.1 app by its primary key. However, by demand of the marketing team, I was asked to put a slug on the URL, so instead of /blog/1, I should get /blog/my-blog-post-title. Thus, while still using the pk value to get the blog post, I just need to get the url to work the way I intend to. URL: path('<slug:slug>/', blog_views.blog_single, name='blog-single') In the HTML, I always refer to this page as: href="{% url 'blog-single' pk=blogPost.id slug=blogPost.get_slug %}" , so that I get both the pk and the slug, which is gotten by the get_slug() method declared on the Blog model. The view is here: def blog_single(request, pk, slug): context = {} context['blogPost'] = blogPost.objects.get(id=pk) ... return render(request, 'blog/blog-single.html', context) Still, in any page that refers to blog-single in the href, I get the following error: Reverse for 'blog-single' with keyword arguments '{'pk': 2, 'slug': 'my-blog-post-title'}' not found. 1 pattern(s) tried: ['blog\\/(?P<slug>[-a-zA-Z0-9_]+)\\/$'] I have tried so many different answers I found on the Internet, and read the answer on this post extensively, but I just can't get my head around what's not working: What … -
Secret Key not found when Django Unit Tests are executed
Whenever I'm running my Django-Tests via the unittests.py file in the main folder the SECRET KEY in .env is not found. What is the correct way to set up the regular Unittests-File for a series of Django-Tests? I wrote my settings.py in a way it's able to write a new key if no other key is found: ---settings.py--- try: print("Current key: " + os.environ['SECRET_KEY']) SECRET_KEY = os.environ['SECRET_KEY'] except KeyError as kerr: logging.error("Can't find Secret Key in settings.py") path_env = os.path.join(BASE_DIR, '.env') utils.generate_secret_key(path_env) dotenv.read_dotenv(path_env) SECRET_KEY = os.environ['SECRET_KEY'] This has worked, but as on every run of the unittests another new key is created, which is not intended. So far I'm running the unittests with a default script which works fine, except for the issue with the key: ---unittests.py--- import DjangoProject.tests_client suite = unittest.TestSuite() loader = unittest.TestLoader() suite.addTest(loader.loadTestsFromModule(DjangoProject.tests_client)) The implemented Test is not a too huge surprise: from django.test import TestCase import django django.setup() class TestBase(TestCase): def setUp(self): #Stuff def tearDown(self): self.removeData() def test_Clienttest(self): #Stuff The Unittests-Classes inherit as required from from django.test.TestCase and do what they are supposed to: Running the Unittest-Script with these settings will result in an error as it can't find the SECRET KEY (I did some debugging … -
How can I manage in django that user can see only his department
Can you please tell me that in Django, i have created model with departments. and how can i manage that with views functions , User can see only his department products. For ex. There are 3 departments (Sales, IT, Finance) Ulvi has access IT and he can see only products of IT deparment. Do have to manage this with models or functions? Regards, Ulvi -
how can filter data depending on another model in Django admin
models.py class Destination(models.Model): title = models.CharField(max_length=200,db_index=True, null=True) class City(models.Model): destination = models.ForeignKey(Destination, related_name='des_city', on_delete=models.CASCADE, null=True) title = models.CharField(max_length=200, db_index=True, null=True) class Program(models.Model): destination = models.ForeignKey(Destination, related_name='des_programs', on_delete=models.CASCADE, null=True) city = models.ForeignKey(City, related_name='cit_programs', on_delete=models.CASCADE, null=True) title = models.CharField(max_length=300, db_index=True, null=True) admin.py class ProgramAdmin(admin.ModelAdmin): model = Program admin.site.register(Destination) admin.site.register(Program, ProgramAdmin) admin.site.register(City) if it possible in admin area in program model we select first the destination as country and then city belong to only one destination example destination E gypt then drop-down menu in city with all cities belong to egypt like Hurghada, Sharm Elshikh et. -
Why isn't my Django CharField in the User model being saved?
I assigned a CharField named "description" as a Field to the built-in User Model,and when I change the profile ther is a CharacterField named Description, but when I fill in any content and click on "Done", the Description of the profile remains empty. This is what a part of my code in my users/forms.py file looks like: from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Profile class UserUpdateForm(forms.ModelForm): email = forms.EmailField() description = forms.CharField(required=False, max_length=100) class Meta: model = User fields = ['username', 'email', 'description'] This is what a part of my users/views.py file looks like: from django.shortcuts import render, redirect from django.contrib import messages from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm from django.contrib.auth.decorators import login_required def Profile(request): return render(request, 'users/profile.html') @login_required def ProfileUpdate(request): if request.method == "POST": u_form = UserUpdateForm(request.POST, instance=request.user) p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if u_form.is_valid() and p_form.is_valid(): u_form.save() p_form.save() messages.success(request, f"Your account has been updated") return redirect("/profile") else: u_form = UserUpdateForm(instance=request.user) p_form = ProfileUpdateForm(instance=request.user.profile) context = { 'u_form': u_form, 'p_form': p_form, } return render(request, 'users/profileupdate.html', context) My urls.py file looks like this: from django.urls import include, path from users import views as user_views urlpatterns = [ ..., path('profile/', user_views.Profile, name="profile"), … -
Django - Nginx giving 404 error with Daphne
I deployed a Django application to a VPS, everything seems to work except for the Django Channels part of the app. I'm trying to establish a connection from a template to my websocket consumer, but i keep getting the following error: (index):10 WebSocket connection to 'ws://mydomain/receiver' failed: Error during WebSocket handshake: Unexpected response code: 404. Can anyone help me find what's wrong with my deployment? Here is how i deployed the app: /etc/nginx/sites-available/myproject server { listen 80; server_name 54.39.20.155; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /WaitingRoomVenv/WaitingRoom/WaitingRoom/static; } location / { include proxy_params; proxy_pass http://unix:/WaitingRoomVenv/WaitingRoomEnv.sock; } } /etc/systemd/system/gunicorn.service [Unit] Description=gunicorn daemon After=network.target [Service] User=root Group=www-data WorkingDirectory=/WaitingRoomVenv/WaitingRoom ExecStart=/WaitingRoomVenv/WaitingRoomEnv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/WaitingRoomVenv/WaitingRoomEnv.sock WR.wsgi:application [Install] WantedBy=multi-user.target And here is the Daphne service: [Unit] Description=daphne service to run Channels on WaitingRoom After=network.target After=nginx.service [Service] Type=simple RuntimeDirectory=daphne PIDFile=/run/daphne/pid User=root Group=www-data WorkingDirectory=/WaitingRoomVenv/WaitingRoom ExecStart=/WaitingRoomVenv/WaitingRoomEnv/bin/daphne -u /tmp/daphne.sock WR.asgi:application ExecStop=/WaitingRoomVenv/WaitingRoomEnv/bin/kill -s TERM $MAINPID [Install] WantedBy=multi-user.target -
How to make a tab for few models in Django Admin panel?
So I have three models: ArtDrawn, ArtWritten, ArtOther, every has different fields. I'd like to customize Django Admin panel so I can click on "Art" instead of specific model, then from an option list pick one of those three and then it'll let me add this object. How can I achieve this? -
Optimal query writing to target selective M2M fields in a model, like Queryset.values( ) does for non M2M ones
so I happen to need help in writing optimal query to target specific M2M fields for my model named Property and finally append all properties details in a json format. Things to note: 1) Property model has M2M fields review, and room_types that I want to target. 2) Inside those M2M connected models, I also want to target specific sub-fields, namely rating field in review, and room_type sub-field in room_types. 3) Property model also has many other non M2M/ f_key fields out of which I need to target name and address. I want output in this form, with each property being represented as a dictionary inside a list. [ { "name": "Property 1", "address": "Address of Property 1", "room_types__room_type": ["Private", "Two Sharing", "Four Sharing"], "reviews__rating": [5.0, 4.0, 3.5] }, { "name": "Property 2", "address": "Address of Property 2", "room_types__room_type": ["Private", "Two Sharing", "Four Sharing"], "reviews__rating": [4.5, 4.0, 4.2] }, ] models look like this: class Property(models.Model): name = models.CharField(max_length=100) address = models.TextField() room_types = models.ManyToManyField(RoomTypes) reviews = models.ManyToManyField(PropertyReviews) class PropertyReviews(models.Model): user = models.ForeignKey(UserProfile, on_delete=models.CASCADE) timestamp = models.DateTimeField(auto_now_add=True) rating = models.DecimalField(max_digits=2, decimal_places=1, choices=...) review = models.TextField() class RoomTypes(models.Model): room_type = models.CharField(max_length=25) query I tried looks as follows properties = Property.objects.prefetch_related('room_types', 'reviews').values('name', … -
Reverse for 'product' with no arguments not found. 1 pattern(s) tried: ['product/(?P<slug>[-a-zA-Z0-9_]+)$']
I want to pick up the particular item and display it on a product page- but I am getting the above error- urls.py- path('product/<slug:slug>', ItemDetailView.as_view(), name='product') models.py- class Item(models.Model): title = models.CharField(max_length=100) price = models.FloatField() discount_price = models.FloatField(blank=True, null=True) category = models.CharField(choices=CATEGORY_CHOICES, max_length=2) label = models.CharField(choices=LABEL_CHOICES, max_length=1) slug = models.SlugField() description = models.TextField() def __str__(self): return self.title def get_absolute_url(self): print('hi this is slug', self.slug) return reverse("core:product", kwargs={ 'slug': self.slug }) I actually even tried to print the slug-but it is not getting printed home-page.html- <a href="{{item.get_absolute_url}}" class="dark-grey-text">{{item.title}} what i am doing wrong? -
Django - Apache2 can't load media files from media folder
I installed an linux server with apache where I want to run my Django app. So I set everything up and when I started the app everything was shown to me except for the pictures. I couldn't find a error inside my site.conf <VirtualHost *:80> ServerName MYHOST ErrorLog ${APACHE_LOG_DIR}/mysite-error.log CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/mysite WSGIProcessGroup mysite WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py Alias /robots.txt /var/www/mysite/static/robots.txt Alias /favicon.ico /var/www/mysite/static/favicon.ico Alias /static/ /var/www/mysite/static/ Alias /static/ /var/www/mysite/media/ <Directory /var/www/mysite/mysite> <Files wsgi.py> Require all granted </Files> </Directory> <Directory /var/www/mysite/static> Require all granted </Directory> <Directory /var/www/mysite/media> Require all granted </Directory> </VirtualHost> or inside my settings.py STATIC_URL = '/static/' STATIC_ROOT = '/var/www/mysite/static' MEDIA_ROOT = '/var/www/mysite/media' MEDIA_URL = '/media/' What I did was setting debug = True and inside linux console I run python3 manage.py collectstatic after reloading apache the website was shown with all its css and js but for every image request I get an error 404. Inside my templates/base.html I call {% load static %}. I tried to replace it with {% load staticfiles from static %} but that crashed my entire app (err 500) I use Django version 3.x and apache2 -
How to Implement Dependent/Chained Dropdown Lis between two foreignkey instances in admin page in Django?
I have the following Models : class Country(models.Model): title = models.CharField(max_length=40) class City(models.Model): title = models.CharField(max_length=40) country = models.ForeignKey(Country, on_delete=models.CASCADE) class Case(models.Model): title = models.CharField(max_length=40) country = models.ForeignKey(Country, on_delete=models.CASCADE) city = models.ForeignKey(City, on_delete=models.CASCADE) In the Django admin of the Case page, I want to implement the chained dropdown select between country and city. If the user choose USA from the country list, the city list will show only cities of USA. From other questions here, I see that i have to use 'list_select_related'. but that doesn't work with me. Is there any simple way to implement that ? -
Django REST, How to display every 5 element in a response?
Now the serializer displays all the data from the CoinCosts model in response (price,timestamp), but only every 5 element is needed, how to do it? Thanks My code now: serializers.py class CoinCostsSerializer(serializers.ModelSerializer): class Meta: fields = ('price', 'timestamp') model = CoinCosts class CoinSerializer(serializers.ModelSerializer): class Meta: fields = ('symbol', 'crr', 'costs') model = Coins costs = CoinCostsSerializer(source='filtered_coincosts', many=True) views.py class DateTimeGteFilter(filters.IsoDateTimeFilter): def filter(self, qs, value): if value != None: return qs.prefetch_related(Prefetch('coincosts_set', to_attr='filtered_coincosts', queryset=CoinCosts.objects.filter(timestamp__gte=value) ) ) else: return qs class CoinCostFilterSet(filters.FilterSet): timestamp = DateTimeGteFilter() class Meta: model = Coins fields = { 'symbol': ['exact'], } -
Django + Elastic Beanstalk, 500 Response codes in access_log but nothing in error_log
I have an application setup on Elastic Beanstalk (with an auto-scaling load balancer) using Django. The configuration also uses apache httpd and mod_wsgi. The app functions correctly but I am seeing an occasional error that for the life of me I cannot debug. This is due to the error itself not appearing in the error_log at any point. A sample from the access log, (IP addresses omitted): [15/Apr/2020:01:13:21 +0000] "GET /reroute/(All)_Lawyers/ HTTP/1.1" 500 27 "-" "" [15/Apr/2020:01:13:22 +0000] "GET /reroute/Chiropractors_Dc/ HTTP/1.1" 302 - "https://www.bing.com/" "Mozilla/5.0 (Linux; Android 4.4.3; KFSOWI) AppleWebKit/537.36 (KHTML, like Gecko) Silk/80.5.3 like Chrome/80.0.3987.162 Safari/537.36" The top request shows an error request, the bottom a typical request. The main thing I notice here is the absence of a user-agent in the 500 request. Combing through the access_log, every single request of this type is missing the user-agent. I have no specific functionality setup to deter bots/spiders or the like. These 500 errors happen randomly and have been doing so for the last few months. There have been no reports of these occurring with the end user, which leads me to believe two possibilities: An incorrect host not specified in Django's ALLOWED_HOSTS setting is being used by someone. Somehow, …