Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to copy a Django SQlite database to a Docker container?
I'm new to Docker. I am trying to dockerize a Django app. My project contains a Wagtail app and I'm using the auto generated Dockerfile by Wagtail. FROM python:3.8.6-slim-buster RUN useradd wagtail EXPOSE 8000 ENV PYTHONUNBUFFERED=1 \ PORT=8000 RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \ build-essential \ libpq-dev \ libmariadbclient-dev \ libjpeg62-turbo-dev \ zlib1g-dev \ libwebp-dev \ nano \ vim \ && rm -rf /var/lib/apt/lists/* RUN pip install "gunicorn==20.0.4" COPY requirements.txt / RUN pip install -r /requirements.txt WORKDIR /app RUN chown wagtail:wagtail /app COPY --chown=wagtail:wagtail . . USER wagtail RUN python manage.py collectstatic --noinput --clear CMD set -xe; python manage.py migrate --noinput; gunicorn mysite.wsgi:application It's working well but my sqlite Database is empty and I'd like to run my container with the wagtail pages that I will create locally. How can I change the Dockerfile for that endeavor? -
Can't figure out why I'm getting `Reverse for 'app_list' with keyword arguments '{'app_label': ''}' not found` in a django project
The project has 2 apps - accounts (very basic custom users) and portal. myproject/myproject/urls.py: from django.contrib import admin from django import urls from portal import admin as user_admin from portal import views urlpatterns = [ urls.path(r'admin/', admin.site.urls), urls.path(r'portal/mymodel/', views.testview), urls.path('', user_admin.user_site.urls), ] myproject/portal/templates/portal/mymodel/testview.html: {% extends "admin/change_list.html" %} {% block after_field_sets %}{{ block.super }} <h2> hello world </h2> {% endblock %} myproject/portal/templates/portal/views.py: from django.shortcuts import render def testview(request): return render( request, 'portal/mymodel/testview.html', {'app_label': 'portal'} ) and the stacktrace: Traceback (most recent call last): File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/wsgiref/handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/contrib/staticfiles/handlers.py", line 76, in __call__ return self.application(environ, start_response) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 133, in __call__ response = self.get_response(request) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 130, in get_response response = self._middleware_chain(request) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 49, in inner response = response_for_exception(request, exc) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 114, in response_for_exception response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info()) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/utils/deprecation.py", line 117, in __call__ response = response or self.get_response(request) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 49, in inner response = response_for_exception(request, exc) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 114, in response_for_exception response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info()) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Users/Me:D/myproject/venv/lib/python3.9/site-packages/django/utils/deprecation.py", line 117, in __call__ response = response or … -
Source specified in Javascript not showing up in Django template
Maybe this is a really dumb question, but I'm learning Javascript and Django and can't figure it out. I've spent a few hours on this and maybe it's a syntax error or something else. I want to specify the source of an image in javascript and then display the image in Django HTML template. It's not working, even with simple images Here is my javascript: $(document).ready(function() { var image = document.getElementById("image").src('https://res.cloudinary.com/.../{{ object.id}}'); } Here is my image info: <img src="#" id="image" class="mx-auto" width="250px" onerror='this.onerror = null; this.src="https://res.cloudinary.com/.../image.jpg"'/> What am I doing wrong? It's definitely not working - the image is not showing up even when it exists. I either get the default image or no image. -
When and what data should be cached?
I want to know when should I cache data? Should I cache ListViews? or DetailViews? What kind of data do I need to cache and does the amount of data matter? When to cache? When not to cache? I want to know when should I decide to cache data? P.s: I don't want to know how to cache, what I want to know is when to cache. -
How to check if redis connection is available when server starts running in django rest framework and return the error response if not connected
I'm doing multiple API calls but in each API call I'm checking if redis connection is available. showing only one of the API calls below. def check_redis_conn(): redis_exists = RedisCache.is_redis_available() if redis_exists is True: set_Data = RedisCache.set_data("message", "This is redis Test") return True else: return redis_exists def hello_vortex(request): is_redis_connected = check_redis_conn() if is_redis_connected is True: data = {'Description': 'This is the sample API call', 'version': 1.0} return JsonResponse{data,safe=False} else: return is_redis_connected RedisCache class: @classmethod def set_connect(cls): try: redis_instance = redis.StrictRedis( host='127.0.0.1', port=6379, ) @classmethod def get_conn(cls): try: cls.redis_instance = cls.set_connect() return cls.redis_instance except Exception as e: return JsonResponse{'message':'Error while connecting', safe=False} @classmethod def is_redis_available(cls): try: isConn = cls.get_conn() isConn.ping() return True except Exception as e: return JsonResponse{'message':'Error while connecting', safe=False} How can I check the redis connection only once when the server starts and return the Json Response on the server if the connection is not available. -
Tweet won't embed in django
Here's my html for my Django Twitter project. I am trying to embed tweets in Django <html lang="en"> <h1>Tweets</h1> <form action="" method="post"> {% csrf_token %} {{ form }} <button type="submit">Submit</button> </form> <body> {% if tweets %} <p>{{tweets}}<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></p> {% endif %} </body> </html> Here's my views.py: import tweepy from tweepy.auth import OAuthHandler from .models import Tweet from .models import Dates from django.core.paginator import Paginator, EmptyPage, InvalidPage from django.shortcuts import render from django.db import models, transaction from django.db.models import Q import os import tweepy as tw from .forms import TweetIDForm from django import template import requests consumer_key = 'dddddd' consumer_secret = 'cccccc' access_token = 'dddddd' access_token_secret = 'ccccc' def clean_tweet_id(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = TweetIDForm(request.POST) print(form) # check whether it's valid: if form.is_valid(): # process the data in form.cleaned_data as required tweet_id = form.cleaned_data.get("tweet_id") #act = form.cleaned_data.get("action") auth = tw.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tw.API(auth, wait_on_rate_limit=True) twtjson = requests.get('https://publish.twitter.com/oembed?url=' + tweet_id + '&omit_script=true') tweets = twtjson.json() tweet = tweets.get('html') return render(request, 'tweet/tweet-list.html', {'form': form, 'tweet_id':tweet_id, 'tweets': tweet}) My code … -
django html set class as query set items
I have a query set that wants each string/item display in a class name for example : queryset = classes.all() what I tired: <div class="queryset"><h4>student1</h4></div> what I got: <div class="<QuerySet [<classTag: English>, <classTag: Math>, <classTag: CS>]>"><h4>student1</h4></div> what I want: <div class="English Math CS"><h4>student1</h4></div> -
Having solme logical error in my RegisterClass View?
My models.py Here I am have registered_students in as many to many field to Registered Names to store all the students that have registered for the class class RegisteredNames(models.Model): name = models.CharField(max_length=100, unique=True) class LiveClass_details(models.Model): chapter_details = models.TextField(default='') mentor_id = models.ForeignKey(Mentor, max_length=30, on_delete=models.CASCADE) no_of_students_registered = models.IntegerField(default=0) registered_students = models.ManyToManyField(RegisteredNames, null=True, blank=True) no_of_students_attended = models.IntegerField(default=0) This model is for registering a student class RegisteredClass(models.Model): class_details = models.ForeignKey(LiveClass_details, on_delete=models.CASCADE) user = models.ForeignKey(User, on_delete=models.CASCADE) my views.py @api_view(['GET', 'DELETE']) @permission_classes((IsAuthenticated, )) def RegisterClassId(request, id): print(request.method) if request.method == 'GET': print("in get method") if not models.RegisteredClass.objects.filter(class_details=models.LiveClass_details.objects.get(id=id), user=request.user).exists(): print("in get method") registered_class = models.RegisteredClass.objects.create(class_details=models.LiveClass_details.objects.get(id=id), user=request.user) registered_class.save() registered_live_class = models.LiveClass_details.objects.get(id=id) registered_live_class.no_of_students_registered += 1 registered_live_class.no_of_students_attended += 1 # registered_live_class.save() print(request.user.username) registered_name = models.RegisteredNames(name=request.user.username) print('registered name : ', registered_name) registered_name.save() registered_live_class.registered_students.add(registered_name) registered_live_class.save() else: print("already registered") return Response(status=status.HTTP_201_CREATED) elif request.method == 'DELETE': print("in delete method") registered_class = models.RegisteredClass.objects.get(class_details=models.LiveClass_details.objects.get(id=id), user=request.user) print("registere_class : ", registered_class) registered_class.delete() registered_class.save() registered_live_class = models.LiveClass_details.objects.get(id=id) if(registered_live_class.no_of_students_registered != 0): registered_live_class.no_of_students_registered -= 1 registered_live_class.no_of_students_attended -= 1 registered_live_class.save() print('error here') registered_name = models.RegisteredNames.objects.get(name=request.user.username) print('error after registered name') print(registered_name) registered_name.delete() return Response(status=status.HTTP_204_NO_CONTENT) Here in this view i am getting error in Adding as well as deleting registered_names from my liveclass_api model , In delete request it is returning error like RegisteredNames … -
Display data that no model exists in a serializer - Python - Django - Django Rest Framework
I have a "Model-Viewset-Serializer" and I need my Serializer to display additional fields that don't exist in the model. Model: class MyModel(models.Model): id = models.UUIDField(primary_key=True, unique=True, default=uuid.uuid4, editable=False, null=False) type = models.CharField(max_length=100, null=False, blank=False) name = models.CharField(max_length=100, null=False, blank=False) Viewset: class MyViewSet( mixins.ListModelMixin, mixins.CreateModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet ): permission_classes = [permissions.AllowAny] queryset = MyModel.objects.all() serializer_class = MySerializer def list(self, request, *args, **kwargs): queryset = MyModel.objects.filter(organization_id=request.user.my_connection_id) page = self.paginate_queryset(queryset) serializer = MySerializer(page, many=True) return self.get_paginated_response(serializer.data) Serializer: class MySerializer(ModelSerializer): class Meta: model = MyModel fields = ('id', 'type', 'name', 'description', 'array') I need to add the following object to the preview Value: [ {'status': 'ok', 'value': '1'}, {'status': 'pending', 'value': '5'}, {'status': 'approval', 'value': '3'}, {'status': 'rejected', 'value': '4'} ] description: 'text description' -
Python No such Device or Address in Heroku
How to avoid the error when I'm using "os.getlogin" in python django. If I use os.getlogin in my local machine works fine and the file that I downloaded save directly in Desktop but in Heroku app I got the error [Errno 6] No such device or address. Any work around to save the file directly to user Desktop? I'm using Heroku for my app. Thank You! import os def report_detail(request): username = os.getlogin() ....................... some codes ...................... wb.save(f"/Users/{username}/Desktop/Report.xlsx") -
Django question: regarding Foreign Keys on two separate tables
Clear here to view diagram Hello, based on a diagram on left: class Course(models.Model): ... ... ... class Lesson(models.Model): course = models.ForeignKey(Course, on_delete=models.CASCADE) ... ... class Question(models.Model): question_text = models.CharField(max_length=500) grade = models.IntegerField(default=20) # Foreign KEY TO LESSON lesson_id = models.ForeingKey(Course, on_delete_models.CASCADE) ---> HOW???? How should I assign the 'lesson_id' in Question model to Lesson model when the common for both is Course model? Really need help on this I'm new to Programming. Thanks so much in advance -
Can you help me to fix this bug?
I am testing djangorestframework and there is an error. Can anybody help me? python version: 3.9.1 django version: 2.2.13 -
docker + nginx http requests not working in browsers
I have a AWS EC2 instance running Linux with docker containers running gunicorn/django and an nginx reverse proxy. I don't want it to redirect to https at the moment. When I try to reach the url by typing out http://url.com in the browser it seems to automatically change to https://url.com and gives me ERR_CONNECTION_REFUSED. The request doesn't show up at all in the nginx access_log. But when I try to reach it with curl I get a normal response and it does show up in the nginx access_log. I have ascertained that the django security middleware is not the cause as the HSTS options are disabled. I've tried clearing the browser cache and deleting the domain from the chrome security policies. nginx config: upstream django_server { server app:8001 fail_timeout=0; } server { listen 80; server_name url.com www.url.com; client_max_body_size 4G; charset utf-8; keepalive_timeout 5; location /static/ { root /usr/share/nginx/sdev/; expires 30d; } location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; if (!-f $request_filename) { proxy_pass http://django_server; break; } } } What am I overlooking? -
How do I filter model objects by most recently created in Django?
I am working on a website in Django and I have a model 'Question'. The Question model has a field 'date_created' which is a DateTimeField. from django.db import models from django.utils import timezone class Question(models.Model: ... date_created = models.DateTimeField(default=timezone.now) In my view, I want to be able to get all the questions that have been asked in the last 10 days. Something like this: Question.objects.filter(???) >> <All the questions that have been asked in the last 10 days> What do I replace '???' with? Thanks in advance. -
The proper way to store JWT tokens in redis for authentication purpose
What is the proper way to store JWT tokens in Redis? The token is signed and self-contained and relatively long string, but what we need is only for authentication. So, is it better to store as JWT using a hash or signature? Any ideas? thanks! Token UserID 1. JWT TOKEN User ID 2. JWT Signature User ID 3. MD5(JWT) User ID -
How to modify nav-pills to limit the number of pages to display
I am trying to implement a pagination system to one page using nav-pills. Since these nav-pills are created dynamically, there will be times when there are only 1, and others when there are 100 (or more). I am using bootstrap 4 & Django The visual impact is tremendous when there are a large number of nav-pills. Attached photo to give you an idea: The code: <ul class="nav nav-pills" id="evidence-formset-tab" role="tablist"> {% for evidence_form in evidence_formset %} {% with index=forloop.counter|stringformat:'s' %} {% with id='evidence-form-'|add:index|add:'-tab' href='#evidence-form-'|add:index aria_controls='evidence-form-'|add:index %} <li class="nav-item"> {% if not current_tab and forloop.first or current_tab == index %} <a class="nav-link active" id="{{ id }}" data-toggle="pill" href="{{ href }}" role="tab" aria-controls="{{ aria_controls }}" aria-selected="true">{{ forloop.counter }}</a> {% else %} <a class="nav-link" id="{{ id }}" data-toggle="pill" href="{{ href }}" role="tab" aria-controls="{{ aria_controls }}" aria-selected="false">{{ forloop.counter }}</a> {% endif %} </li> {% endwith %} {% endwith %} {% endfor %} </ul> </div> I would like to get a result similar to the following: Previous 1 2 3 4 5 Next That is, if the user clicks next, the following 5 pills will load: Previous 6 7 8 9 10 Next And if the user clicks on Previous we will go back to … -
Load Django Objects Quicker
so I'm working on a Django news aggregator project. A main aspect of the project involves me fetching reddit and twitter posts through their respective APIs, saving the post data to a post model, then loading those model objects onto the page. This is what I would prefer to do over fetching the data and displaying it directly through the response objects. Right now, I have two separate timelines of reddit posts, and twitters posts, adjacent to each other on the page. Last time I loaded the page, it took a really long time. This is what the page looks like btw: I was hoping someone could explain to me how I can get my page to load faster, and also how to integrate timeline/newsfeed functionality well. Lets say I have over 1500 post objects in my database, I don't want to load all 1500 on the page at one time. I'd like to load like the first 100, then if someone scrolls down the page enough, the next 100 become loaded, etc. Is there an easy/efficient way to go about this? Thanks -
How to manipulate data and display it through Django?
Background I have created an small app that can add projects, and show it in the index page, all those projects can be access individualy to its own "profile proJect page" clicking on the project name. Inside the project's profile page, it can be seeing data as ProjectName, ResponsableName, Description and all related data per page. Problem Now that have the app, I would like manipulate the data from the django models and display the analysis into another HTML page, is there any library you could recommend or it is posible to do it only with Django ? Where should I start ? I'm available to response any upcomming questions. -
Django Heroku app throws 404 when deployed
I have a django app that I have deployed to heroku, and it works perfectly fine locally (with whitenoise and django-on-heroku taken out because of some issue locally where I cant properly pip install them. This shouldnt matter though because I have properly included them in requirements.txt). When I push it to heroku, however, I see that it successfully has been pushed but all I see when I access the home page is my custom 404 not found page. I can access the admin page via /admin as well. My settings.py: from pathlib import Path import dj_database_url import django_on_heroku # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-3*)__%2yd!4cy=cb*jv$u#$*9x1j17d7$qiv#-o=-1o@nv-3yf' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False # Check allowed hosts!!! ALLOWED_HOSTS = ['fierce-atoll-95882.herokuapp.com', '127.0.0.1', 'localhost', '*'] # Application definition INSTALLED_APPS = [ 'mysite.apps.MysiteConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'market_predict.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': … -
Django NoReverseMatch error but the url pattern works
Just finished adding a feature to my site that allows users to create sub blog posts(build logs). Everything was working fine but my url structure was poor so I am re doing it. Doing so has created an error error: Where I am confused is if I enter /post/29/build-log/2 as the url the page works. But when I go to the post page which lists the build logs it does not work The '(2,)' it is refering to is the id of the first build log views def DetailPostView(request, pk): model = Post post = Post.objects.get(pk=pk) form = CommentForm comments = Comment.objects.filter(post=post)#.order_by('-create') buildlogs = BuildLog.objects.filter(post_id=post) if request.method == 'POST': # A comment was posted comment_form = CommentForm(data=request.POST) if comment_form.is_valid(): new_comment = comment_form.save(commit=False) new_comment.author = request.user new_comment.post = post new_comment.save() context = { 'post':post, 'form':form, 'comments':comments, 'buildlogs':buildlogs } return render(request, 'blog/post_detail.html', context) def BuildLogDisplay(request, pk, pkz): model = BuildLog post = BuildLog.objects.all().filter(post_id=pk) log = BuildLog.objects.get(pk=pkz) context = { 'post':post, 'log':log } return render(request, 'blog/buildlog.html', context) urls path('post/<int:pk>/', views.DetailPostView, name='post-detail'), path('post/<int:pk>/build-log/<int:pkz>', views.BuildLogDisplay, name='build-log-view'), spent a few hours on it but cant figure it out -
Django templates folder structure good practices
Lets say I have a couple of apps, that are totally separate, and I want to keep the templates folder on a project level. My folder structure would look like this: project_name - first_app - second_app - ... - x_app - project_name - static - templates - __init__.py - manage.py Now, the first question is: If I want to keep template folder on a project level, should I create sub-directories for each app, like so: -templates -first_app -second_app or should I just have templates from all aps mixed together in templates folder? And the same question goes for static folder. If I want to keep it on a project level, should I create sub-directory for each app, and should each of the apps directories have their own /css /images /js? And the last question I have, is, if I as I said have a couple of apps, that are totally separate, and want to create a welcome page for the project, that would just be a simple menu with anchor tags to all the apps, where should I render the view for it? I don't feel like it belongs to any specific app, but creating a whole new app just … -
Share django transaction accross threads
I've a problem where one API implemented in a django (3.2) web app has to fetch different prices from multiple APIs and store those prices in the database (Postgres 13) before returning to the client. I'd like to put the inserts in the same transaction, so if something unexpected happens, nothing will be inserted. I am now going forward by first calling all apis, each one inside a green thread (gevent) and after all of them return, I bulk insert the results. But turns out I got really curious if I it is possible for different threads ( green or not) to share the same transaction. I saw that psycopg2 can execute in a non blocking way. The issue now is everytime I start thread in django the new thread is inside a new transaction. I will dig into the django db backend source to understand what is happening, but maybe someone can clear this out. Tldr; is possible to different threads execute queries inside the same transaction? -
Dango API "request count" now showing in Azure App Insights > Performance with opencensus
running into an issue where my Django python API application is not logging all metrics to Azure App Insights using opencensus. But for example, we are getting CPU/memory logging: I would expect the performance > request count to look similar to this (on a different application framework): The performance counters section looks pretty straight forward. My code looks like this: from opencensus.ext.azure import metrics_exporter def main(): INSTRUMENTATION_KEY = os.getenv("INSTRUMENTATION_KEY", "xxx") exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey='+INSTRUMENTATION_KEY) -
How to call OneToOneField reverese relationship in template (django)?
I have these models in my models.py User Model class User(AbstractBaseUser, PermissionsMixin): """Custom user model""" email = models.EmailField(max_length=255, unique=True) first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) UserInfo Model class UserInfo(models.Model): """User's Info""" user = models.OneToOneField(User, related_name="parent_user", on_delete=models.CASCADE) image = models.ImageField(upload_to=user_image_file_path) age = models.IntegerField() bio = models.CharField(max_length=400) My-template In my template i am passing some filtered User Profiles(let's say filtering by age, if age > 25 ) now i need to show the name of the user(first_name) as well but i don't know how to call a OneToOnefield reversely. Help is really appreciated :). {% for p in profiles %} <div class="profile-container" style="position: relative"> <div class ="left-div"> <div class="mySlides fade"> <img src="media/{{p.image}}" style="width:100%" id="user-media-img"> <div class="text">User First Name is : {{`What to type here?`}} </div> </div> </div> <div class="right-div"> <div class="details"> <h1>BIO</h1> <p>{{p.bio}}</p> <h1>Age:</h1><p>{{p.age}}</p> </div> </div> {% endfor %} Thanks :) -
Celery tasks aren't running in django
I'm just starting out with celery, hoping to build out something better, but I can't even get the test to work. Is there something I'm doing wrong here? I'm using Docker, and I'm running both beat and worker settings.py # Celery settings BROKER_URL = 'redis://redis:6379' CELERY_RESULT_BACKEND = 'redis://redis:6379' CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_TIMEZONE = 'UTC' core/celery.py from __future__ import absolute_import import os from celery import Celery from django.conf import settings # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') app = Celery('core') # Using a string here means the worker will not have to # pickle the object when using Windows. app.config_from_object('django.conf:settings') app.autodiscover_tasks() @app.task(bind=True) def debug_task(self): print('Request: {0!r}'.format(self.request)) core/tasks.py from celery import Celery from celery.schedules import crontab from celery.decorators import periodic_task app = Celery('tasks', broker='redis://localhost//') @periodic_task(run_every=timedelta(minutes=1)) def update_keep_alive(self): logger.info("running keep alive task") statsd.incr(statsd_tags.CELERY_BEAT_ALIVE) @periodic_task( run_every=(crontab(seconds=10)), name="task_save_latest_flickr_image", ignore_result=True ) def task_save_latest_flickr_image(): print("Tester") logger.info("Saved image from Flickr") @app.task def see_you(): print("See you in ten seconds!") app.conf.beat_schedule = { "see-you-in-ten-seconds-task": { "task": "periodic.see_you", "schedule": 10.0 } }