Skip to content

Commit 126da05

Browse files
Merge branch 'add_celery_app' of TheCodeBlogs/django-tcb-blog into master
2 parents 5af57e3 + c666a48 commit 126da05

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

README.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ Quick start
1616

1717
path('blog_api/', include('blog.urls')),
1818

19-
3. Run ``python manage.py migrate`` to create the blog models.
19+
3. Setup a module named 'backend'
2020

21-
4. Start the development server and visit http://127.0.0.1:8000/admin/
22-
to create a poll (you'll need the Admin app enabled).
21+
4. Using celery.py.sample as a guide, setup celery do that tasks will work
2322

24-
5. Visit http://127.0.0.1:8000/blog_api/ to see something.
23+
5. Run ``python manage.py migrate`` to create the blog models.
24+
25+
6. Start the development server and visit http://127.0.0.1:8000/admin/
26+
to create a poll (you'll need the Admin app enabled).
27+
28+
7. Visit http://127.0.0.1:8000/blog_api/ to see something.

celery.py.sample

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from __future__ import absolute_import
2+
import os
3+
from celery import Celery
4+
from django.conf import settings
5+
6+
# set the default Django settings module for the 'celery' program.
7+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
8+
app = Celery('backend')
9+
10+
# Using a string here means the worker will not have to
11+
# pickle the object when using Windows.
12+
app.config_from_object('django.conf:settings', namespace='CELERY')
13+
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
14+
15+
16+
@app.task(name="debug", bind=True)
17+
def debug_task(self):
18+
print('Request: {0!r}'.format(self.request))

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = django-tcb-blog
3-
version = 0.1
3+
version = 0.2
44
description = A Django backend based on DRF for blogging
55
url = https://www.thecodeblogs.com/
66
author = Brent Jameson

0 commit comments

Comments
 (0)