Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django rest framework Token for "per device" authentication
i want to set a token for a mobile app in order for it to have access to server resources , the project doesn't contain users but only an admin panel deployed in a server , and a mobile app which doesn't require authentication ( no account , not user based) . how can i make a token for that specific mobile app using django rest framework api? -
Django website is loading slow on Heroku, and it is not because of QuerySets
Have website that is running on simple generic Class-Based Views. First I thought - the QuerySets are the issue but since all my queries are lower than 8ms, that is not the issue. Locally the website is running fast under - 200/300ms with all images and everything. When I have pushed it to Heroku it was slow. In the inspect chrome bar - it shows 1 straight line for 1-2 seconds and then loading the rest - it waits 1-2 seconds and then it loads. So I have started to break down the process and came to 1 conclusion - removed the DB and it started loading very fast like 100ms - when I have plugged in the Postgres DB - instantly went to slow mode. Have installed Django-Toolbar as well to see what is going on. Here are the results. I have even tried to put DB and app on higher tiers just to see and no difference. So what I did is as well created simple view Test - with 3 images that I see the images are not causing it and load it - takes 1-2secs to start loading as well - removing DB - loads very … -
how can i make an auto populated dropdown with AJAX in django?
im working on a search form on diffrent tables, i have two tables called 'specialte' and 'option' both assosiated with a table called 'service', what i want is when i choose a 'service' from a dropdown, another dropdown is auto populated with specialtes and options using AJAX. this is my .models : class Service(models.Model): value = models.CharField(max_length = 45, blank = False, null = False) departement = models.ForeignKey(Departement, on_delete = models.CASCADE) def __str__(self): return self.value class Option(models.Model): value = models.CharField(max_length = 45, blank = False, null = False) service = models.ForeignKey(Service, on_delete = models.CASCADE) def __str__(self): return self.value class Specialite(models.Model): value = models.CharField(max_length = 45, blank = False, null = False) service = models.ForeignKey(Service, on_delete = models.CASCADE) def __str__(self): return self.value this is my view: def personnel(request): if not request.user.is_authenticated: return redirect('authentification') else: a = Affectation.objects.all().prefetch_related() o = Option.objects.all().prefetch_related() s = Specialite.objects.all().prefetch_related() context = { 'affectation':a, 'option':o, 'specialite':s } return render(request,'personnel/personnel.html',context) this is the html code : <div class="form-group"> <div class="row"> <div class="col"> <label for="formGroupExampleInput1">Service:</label> <select name="service" id="service" class="form-control"> <option>...</option> </select> </div> <div class="col"> <label for="formGroupExampleInput1">Specialite:</label> <select name="specialite" id="specialite" class="form-control"> {% for o in option%} <option>{{ o.value }}</option> {%endfor %} {% for s in specialite%} <option>{{ s.value }}</option> {%endfor %} … -
My templates doesn't work even I connected all the links
I downloaded free templates zip files(contact form, css,fonts, img, js, readme.txt folders included) to use django templates, then pasted main templates in home.html. I also made a directory in this "good(app)-static(folder)-good(folder)-contact form,css,fonts,img,js,readme.txt(folders)" orders.After I connected all the links that might I need, but templates still doesn't work. Can you find me what's the problem? I changed all the directory paths to make proper connection for my template. part of tag in home.html near head tag <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Maundy | Comming Soon Page</title> <meta name="description" content="Free Bootstrap Theme by BootstrapMade.com"> <meta name="keywords" content="free website templates, free bootstrap themes, free template, free bootstrap, free website template"> <link href='https://fonts.googleapis.com/css?family=Lobster|Open+Sans:400,400italic,300italic,300|Raleway:300,400,600' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/animate.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/bootstrap.min.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/font-awesome.min.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'good/static/good/css/style.css' %}"> <!-- ======================================================= Theme Name: Maundy Theme URL: https://bootstrapmade.com/maundy-free-coming-soon-bootstrap-theme/ Author: BootstrapMade.com Author URL: https://bootstrapmade.com ======================================================= --> </head> <body> <div class="content"> <div class="container wow fadeInUp delay-03s"> <div class="row"> <div class="logo text-center"> <img src="{% static 'good/static/good/img/banner01.jpg' %}"/> <h2>We Are Baking Something New!! Comming Soon</h2> </div> Designed by <a href="https://bootstrapmade.com/">BootstrapMade</a> </div> </div> </div> </div> </footer> <script src="{% static 'good/static/good/js/bootstrap.min.js' %}"></script> <script src="{% static … -
Can i set an external clone of my Django db?
I have a Django App with this db: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } now, i want to configure a secondo db (clone of first) on a web path. for eaxample: http://clone_db.no-ip.com how can i do? -
Django: Trying to implement a file upload progress bar
I am trying to implement a progress bar for my file upload. However, I kept on getting 405 Method not allowed error. I am very new to Ajax and jQuery so it would be great it someone can help me out. Currently my file upload class-based view is working fine. This is my class-based view: class UploadLessonView(CreateView): model = Lesson fields = ['title', 'file'] template_name = 'store/upload_lesson.html' success_url = '/' def form_valid(self, form): form.instance.post = get_object_or_404(Post, pk=self.kwargs.get('post_id')) return super(UploadLessonView, self).form_valid(form) def get_success_url(self): return reverse_lazy('lesson_uploaded', kwargs={'post_id' : self.object.post_id}) This is my html template <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"> </script> <script src="/static/store/upload.js"></script> <div id="main"> <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form | crispy }} <button href = "{% url 'store-home' %}" class="btn btn-secondary" type="submit" >Upload File</button> </form> </div> This is my js: $(document).ready(function() { $('form').on('submit', function(event) { event.preventDefault(); var formData = new FormData($('form')[0]); var csrftoken = $("[name=csrfmiddlewaretoken]").val(); $.ajax({ xhr : function() { var xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener('progress', function(e) { if (e.lengthComputable) { console.log('Bytes Loaded: ' + e.loaded); console.log('Total Size: ' + e.total); console.log('Percentage Uploaded: ' + (e.loaded / e.total)) } }); return xhr; }, type :'post', url : '/', headers: {'X-CSRFToken': csrftoken }, data: formData, processData : false, contentType : false, success : … -
Pydub write to buffer Django and Cloudinary
I'm using pydub to slice audio. My use case is that users send long audios (.wav files) from which I only want the first 3 seconds. The .wav files come from a web client to a Django Rest Framework backend, I read (intercept the request) those files and take only the first 3 seconds. Everything works till that point with the following code: # load audio audio_data = request.data.get('sample') audio_pydub = AudioSegment.from_wav(audio_data) # Shorten audio audio_pydub_shortened = audio_pydub[:seconds_to_take] audio_pydub_shortened.duration_seconds But then I want to write the resulting file into the request data, so the request can follow it's flow, so I'm trying to do (without success): resulting_audio = audio_pydub_shortened.export(None, 'wav') request.data['sample'] = resulting_audio.read() super(request) Where resulting_audio is a TemporaryFileWrapper. The error is that the file is deleted from the request as resulting_audio.read() seems to be empty. -
HTML template doesn't see the variable passed from views
I am trying to pass a variable from views.py to my login.html template. This is my views.py from django.shortcuts import render # Create your views here. def home(request): numbers = [1, 2, 3, 4, 5] context = { 'numbers': numbers } return render(request, 'accounts/login.html', {'title': 'Login'}, context) and this is my login.html {% extends 'accounts/base.html' %} {% block content %} <h1>Welcome</h1> <h5 class="text-muted">Please log in to continue</h5> <button href="#" class="btn btn-outline-primary mt-1">Log in</button> {{ numbers }} {% endblock content %} also, this is my urls.py file inside of my application from . import views from django.urls import path urlpatterns = [ path('', views.home, name="home"), path('home/', views.home, name="home"), ] I expect the list [1, 2, 3, 4, 5] to show on login.html, when the address is localhost:8000/myappname/home -
How to fix " TypeError missing 1 required positional argument: 'on_delete' "
I am setting up my category tags for my blog, I am getting a TypeError: init() missing 1 required positional argument: 'on_delete', even though I included "on_delete=models.CASCADE". from django.db import models from django.urls import reverse from tinymce import HTMLField class CategoryTag(models.Model): title = models.CharField(max_length=150) slug = models.SlugField() parent = models.ForeignKey( 'self', on_delete=models.CASCADE, blank=True, null=True, related_name='children' ) class Meta: unique_together = ('slug', 'parent',) verbose_name_plural = "categories" def __str__(self): full_path = [self.title] k = self.parent while k is not None: full_path.append(k.title) k = k.parent return ' -> '.join(full_path[::-1]) class Post(models.Model): title = models.CharField(max_length=100) overview = models.TextField() timestamp = models.DateTimeField(auto_now_add=True) content = HTMLField() comment_count = models.IntegerField(default=0) post_img = models.ImageField() category = models.ForeignKey('CategoryTag', null=True, blank=True) featured = models.BooleanField() slug = models.SlugField(unique=True) def __str__(self): return self.title def get_cat_list(self): k = self.category breadcrumb = ["dummy"] while k is not None: breadcrumb.append(k.slug) k = k.parent for i in range(len(breadcrumb)-1): breadcrumb[i] = '/'.join(breadcrumb[-1:i-1:-1]) return breadcrumb[-1:0:-1] def get_absolute_url(self): return reverse('post-detail', kwargs={ 'id': self.id }) I've tried to bypass by using removing the other fields (blank=True, Null=True, related_name='children') and I am still receiving the same error. -
pytz.exceptions.UnknownTimeZoneError: 'Asia/kolkata'
In my project (made in Virtual Environment), when I run the server, it gives me no errors. But when I open the 127.0.0.1:8000 , it gives me an error saying: A server error occurred. Please contact the administrator. Had referred the below post to set the timezone to 'Asia/kolkata':- How to add Indian Standard Time (IST) in Django? It worked fine till yesterday and today I got an error in prompt as: File "C:\Users\Ajay\Anaconda3\lib\site-packages\pytz\__init__.py", line 181, in timezone raise UnknownTimeZoneError(zone) pytz.exceptions.UnknownTimeZoneError: 'Asia/kolkata' How to tackle this? (Using Django V2.1) -
Django: migrating one manytomany field to another manytomany field
I need to migrate some data from class A to class B class A contains a m2m field that, say, links to auth.User This is simply migrating data over, so I add those fields from class A into class B and created migration file. I then loop through all class A objects and assign those fields for each object into class B. When it gets to the m2m field, I run into TypeError: 'ManyRelatedManager' object is not iterable class A(object): something = CharField(blehbleh) something_else = CharField(blehbleh) thing_to_migrate = models.ManyToManyField('auth.User', related_name='some_name', blank=True) class_b = models.ForeignKey('class_B_path', related_name='some_name', on_delete=models.SET_NULL) # so A.class_b gets me class B class B(object): already_exist_field = CharField(blehbleh) thing_I_want_to_migrate_here = models.ManyToManyField('auth.User', related_name='some_other_name', blank=True) related_name needs to be unique, so I set a new name there. When I modify the migration script first the def def migrate_lpinvite_to_invite(apps, schema_editor): ClassA = apps.get_model('appname', 'A') for obj in ClassA.objects.all(): obj.class_B.thing_I_want_to_migrate_here = obj.thing_to_migrate obj.save() then actual runmigration operations = [ migrations.AddField( model_name='B', name='thing_I_want_to_migrate_here', field=models.ManyToManyField(blank=True, related_name='some_other_name', to=settings.AUTH_USER_MODEL), migrations.RunPython(migrate_to_B) ] And I got the error listed above. What's the correct way to migrate related fields like this? Can I somehow refer to the through table directly and don't do this kind of data migration? -
How to change website bootstrap 4 components/contents based on user input in django
I have a Django bootstrap 4 project and I need to implement the following requirements:- show personalized content for each authenticated user based on user input via the form. if the user fills up his brand name this should show up in nav-brands only for him when he's logged in. I am planning to use Django-cms for this but not sure where to start. Any inputs regarding this? -
How do i filter a many to many field?
So i have a model Called Parent. In the model i have a many to many field called partner_types. which is based on the model Partner_type. What i want to do is filter the model to check if someone is a parent or not. I tried filter sets but the problem is my partner_type is defined in the admin so i am not able to filter it. class PartnerType(models.Model): name = models.CharField(blank=False, help_text="Name of the role or function", max_length=64, verbose_name="Partner Type", ) -
Need help designing Django models (tracking changes over time)
I'd like to be able to track how much time a cluster of news articles can be seen inside and RSS feed, and how much time the news articles inside thoses clusters can be seen as well. To this end, I'm scrapping the RSS feed every 15min, I store the clusters inside a table, and I store the articles they contain inside another table. Here is a glimpse of the structure of the RSS feed ("item" would be a cluster of articles, and "news_item" an article): <channel> <title>Channel title</title> <description>Recent articls</description> <link>https:blabla</link> <atom:link href='' rel='self' type='application/rss+xml'/> <item> <title>Basic title</title> <ha:data1>50000</ha:data1> <description>basic description</description> <link>https://mylink</link> <pubDate>Mon, 29 Jul 2019 00:00:00 +0200</pubDate> <ha:data2>https:alink</ha:data2> <he:news_item> <he:news_item_title>SUB ITEM TITLE</he:news_item_title> <he:news_item_snippet>SUB ITEM SNIPPET</ht:news_item_snippet> </he:news_item> <he:news_item> <he:news_item_title>...</he:news_item_title> <he:news_item_snippet>...</he:news_item_snippet> </he:news_item> </item> As a cluster can have several articles, and knowing there is a chance that an article could be seen inside several clusters, I believe a many-to-many relationship is involved. This is how I designed my Django models for now: class Cluster(models.Model): title = models.TextField() data1 = models.CharField(max_length=100) search_link = models.URLField() first_seen = models.DateTimeField() last_seen = models.DateTimeField() #that is for keeping trace of the scrapping time class Meta: verbose_name = 'Cluster' verbose_name_plural = 'Clusters' def __str__(self): return self.title … -
Django contact form returning a gmstp error?
I may be getting this very wrong. I made a contact-us form where users can send us emails. basically, I will get the data from the form and send the emails in the view by send function. forms.py subjects = ( (1,'Bug/error reporting'), (2,'Enhancement suggestion'), (3,'Support and help'), (4,'General feedback') ) class ContactForm(forms.Form): name = forms.CharField(max_length=180) email = forms.EmailField(required=True) subject = forms.ChoiceField(choices=subjects,required=True) message = forms.CharField(widget=forms.Textarea(attrs={"rows":9, "cols":20})) views.py def emailView(request): # defining initial data for the forms user = request.user initial_data = { 'name' : user.first_name, 'email' : user.email, } if request.method == 'GET': form = ContactForm(initial=initial_data) return render(request, "email.html", {'form': form}) else: form = ContactForm(request.POST,initial=initial_data) if form.is_valid(): name = form.cleaned_data['name'] subject = form.cleaned_data['subject'] from_email = form.cleaned_data['email'] message = form.cleaned_data['message'] message_f = name + 'has the following message \n' + message email = EmailMessage(subject ,message_f ,from_email ,['myemail@email.com'], headers = {'Reply-To': from_email } ) email.send(fail_silently=False) return redirect('success') return render(request, "email.html", {'form': form}) and I get SMTPAuthenticationError but I don't want to use the email in my settings.py i want to use users emails to send it the emails to the myemail@email.com -
Django does not let me to manually type PK with postgresql
I have a model like this one. class MyModel(models.Model): id = models.IntegerField( primary_key=True, ) is_active = models.BooleanField( default=True, ) I want to put an id by myself. However django-postgresql does not allow me to do it. Here is my view: class MyView(APIView): def post(self, request, format=None): my_model = MyModel() my_model.id = 6 my_model.save() It throws exception on the .save() part. Here is the exception text: ProgrammingError at /myViews/myView relation "myDB_mymodel" does not exist LINE 1: SELECT (1) AS "a" FROM "myDB_mymodel" WHERE... -
Problem installing fixture: No JSON object could be decoded
I decided to deal with fixtures. ./manage.py dumpdata credits --indent 4 > fixtures/credit.json I made fixtures with help. Then deleted objects from the credit table. And now I try to create them again using fixtures. ./manage.py loaddata fixtures/credit.json But I get error: django.core.serializers.base.DeserializationError: Problem installing fixture '/home/m0nte-cr1st0/work_projects/startup/finbee/fixtures/credit.json': No JSON object could be decoded full traceback and json file https://dpaste.de/UcB7 -
HTML templates not updating using Django on Digital Ocean using WinSCP
I have a Django webapp, using Gunicorn and nginix on a digital ocean server. I have been updating HTML templates using WinSCP by just copying the updated HTML files from my local machine over to the digital ocean server (overwriting the old templates) and it has been working fine until now. For some reason one of my HTML templates is not updating on my website. I have even removed it completely and the page still loads fine? I have tried: sudo systemctl restart nginx sudo systemctl restart gunicorn Is there something else I'm missing here? I have double checked my urls.py and views.py 50 times trying to find the problem, but it seems to be something over my head... any help is appreciated! -
how do I get a django apps variable to the root app
I have a wait screen that will redirect you to the page specified when the page loads. I put the waitscreen in the main app so it could access the main root url conf to redirect the pages. But, the app that is calling the waitscreen can't pass the redirect variable to teh template because it is not in the same app. heres a hierarchy for better understanding mysite mysite templates mysite wait_screen.html --need to pass the redirect var up here urls.py views.py app1 views.py --this has the redirect variable in it here is my waitscreen in the mysite, it redirects in JS // Redirect var redirect_to = "/{{redirect_to}}"; -- the {{}} is the var used for redirecting window.location.replace(redirect_to); console.log(redirect_to) -- all I am getting right now is the '/' here is the views.py in app1 def wait_screen(request): redirect_to = request.GET.get("redirect_to", "") . --here is the variable context = {'redirect_to': redirect_to} --ps. are these even needed now vvv return render(request, 'mysite/mysite/wait_screen.html', context) -
In Django authentication for Corporate company via Active Directory, option available if LDAP is not installed
Developing application with Django for Corporate company and user need to authenticated based AD, what if LDAP has not installed then what could be available options to authenticate users -
For some reason django static files not working correctly
I am learning django right now and I am using templates for this. I have done everything as always (I think), but for some reason django static files not working perfectly. I tried to find a solution but nothing helped. This is the site now: How it should be: Inside "static" folder I have css, images, and so on. I have "{% load static %}" on the top of the html. I do not have any errors in the console. One of the static files: <link rel="stylesheet" href="{% static 'css/style.css' %}"> My settings.py: STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ] My folders: -
Unit gunicorn.socket could not be found
I get a 502 Bad Request error after deployment with nginx. I am using a digitalocean droplet. Everything works fine locally, so I must have missed something while bringing over the files to filezilla...? sudo tail -30 /var/log/nginx/error.log 2019/07/29 13:42:25 [crit] 1666#1666: *2 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: 138.68.234.34, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "myi.pad.dress" 2019/07/29 13:42:30 [crit] 1666#1666: *4 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: 46.114.6.201, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "myi.pad.dress" 2019/07/29 13:42:30 [crit] 1666#1666: *6 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: 46.114.6.201, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/favicon.ico", host: "myi.pad.dress", referrer: "http://myi.pad.dress/" 2019/07/29 13:50:00 [error] 1666#1666: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 46.114.6.201, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "myi.pad.dress" 2019/07/29 13:55:50 [crit] 1666#1666: *10 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: 46.114.6.201, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "myi.pad.dress" 2019/07/29 13:57:18 [crit] 1666#1666: *12 connect() … -
Using AJAX/Django to Fill Customer Address
I have an 'Order' form where the user selects a Customer (from a foreignkey dropdown). There is a text field for Customer Address in the same form which I would like to auto-populate when the user selects Customer based on my Customer model which contains both customer name and customer address. My understanding is that this would require some AJAX, but I am completely inexperienced with AJAX and I'm hoping someone could show me an example of how to do this as I will have many similar cases through my program. MODELS.PY class Customers(models.Model): c_name = models.CharField(max_length=100) c_address = models.CharField(max_length=100) class Orders(models.Model): reference = models.IntegerField() c_name = models.ForeignKey(Customers) #dropdown the user selects from ship_to = models.CharField(max_length=1000) #this is the field I want to populate automatically ... FORMS.PY class CreateOrderForm(forms.ModelForm): class Meta: model = Orders fields = ('reference', 'c_name', 'ship_to', 'vessel', 'booking_no', 'POL', 'DOL', 'COO', 'POE', 'ETA', 'pickup_no', 'terms', 'sales_contact', 'trucking_co', 'loading_loc', 'inspector', 'total_cases', 'total_fob', 'freight_forwarder', 'commodity', 'is_airshipment', 'credit') VIEWS.PY def add_order(request): if request.method == "POST": form = CreateOrderForm(request.POST) if form.is_valid(): reference_id = form.cleaned_data.get('reference') form.save() return redirect('add_manifest', kwargs={'reference_id': reference_id}) else: form = CreateOrderForm() objectlist = Customers.objects.all() context = { 'form': form, 'objectlist': objectlist, } return render(request, 'add_order.html', context) when customer is … -
Django 1.11.2 error: django.db.utils.ProgrammingError: relation "eventtransactions" does not exist
I'm writing a Django Query to load data from a database. When I do it, I get an error that says: django.db.utils.ProgrammingError: relation "eventtransactions" does not exist LINE 1: ...sactions"."eventtransactions_id") AS "count" FROM "eventtran... I would like to create a loop that will count the number of event transactions for each membership type per day and store it in a dictionary where the key is the membertype and the value is the number of event transactions for that membertype on that day. I've tried modifying what is being counted but am having some trouble with it. I've tried counting by membertype and by custnum but am still getting the same ProgrammingError. fitness model: class EventTransactions(models.Model): eventtransactions = models.BigAutoField(primary_key=True) eventtransactions_id = models.IntegerField() profitcenter_id = models.IntegerField() customer_gender = models.TextField() customer_firstname = models.TextField() customer_lastname = models.TextField() actualdatetime = models.DateTimeField(blank=True, null=True) custnum = models.BigIntegerField(blank=True, null=True) birthdate = models.DateField(blank=True, null=True) membertype = models.TextField(blank=True, null=True) eventname = models.TextField(blank=True, null=True) class Meta: managed = False db_table = 'eventtransactions' import_swipe_counts.py import psycopg2 import redis import datetime import json from optparse import make_option from django.core.management.base import BaseCommand, CommandError from urec.settings import REDIS_HOST, REDIS_DB from django.db.models import Count from django.db.models.functions import TruncDay from fitness.models import EventTransactions # the inverse mapping … -
Django LogoutView does not emit user_logged_out signal
I have an app that does not receive the user_logged_out signal that, in theory, should have been sent by LogoutView. urls.py: ... path('accounts/logout/', auth_views.LogoutView.as_view(template_name='registration/logout.html'), name='logout'), ... myapp/signals.py from django.contrib.auth import user_logged_out from django.dispatch import receiver @receiver(user_logged_out) def extra_logout(sender, request, user, **kwargs): # does some stuff myapp/apps.py from django.apps import AppConfig class MyappConfig(AppConfig): name = 'myapp' def ready(self): import myapp.signals return super().ready() Note that myapp is loaded, everything else works. The django session is destroyed when calling accounts/logout/, but my receiver never gets the signal. What am I doing wrong? Django 2.2.3, Python 3.7.3 on mac.