jazzband / django-oauth-toolkit

OAuth2 goodies for the Djangonauts!
https://django-oauth-toolkit.readthedocs.io
Other
3.13k stars 792 forks source link

Missing Import in Documentation #1421

Closed giovanniacg closed 4 months ago

giovanniacg commented 4 months ago

Description:

The code snippet provided in the documentation needs an additional import to function correctly. Without this import, the code does not raise any errors, but it fails to discover @shared_tasks in other files.

Link to Documentation: Django OAuth Toolkit Tutorial - Step 5

Code:

import os
from celery import Celery

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tutorial.settings')
app = Celery('tutorial', broker="pyamqp://guest@localhost//")
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django apps.
app.autodiscover_tasks()

Necessary Import:

# The documentation does not mention the need to import this module
from django.conf import settings

Problem: Without the from django.conf import settings import, the code does not produce any errors, but it fails to discover @shared_tasks in other files.

Reported Issues:

References:

n2ygk commented 4 months ago

Feel free to submit a PR.

giovanniacg commented 4 months ago

Thanks Alan.

Opened in https://github.com/jazzband/django-oauth-toolkit/pull/1424

On Mon, May 20, 2024 at 3:53 PM Alan Crosswell @.***> wrote:

Feel free to submit a PR.

— Reply to this email directly, view it on GitHub https://github.com/jazzband/django-oauth-toolkit/issues/1421#issuecomment-2121016967, or unsubscribe https://github.com/notifications/unsubscribe-auth/APIHMOLCTV4Q5XULO5MNBALZDJBBRAVCNFSM6AAAAABH6CGL2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRRGAYTMOJWG4 . You are receiving this because you authored the thread.Message ID: @.***>

williank commented 1 month ago

I had to make this amount to discovery out my tasks; I wasn't comfortable with it

Django OAuth Toolkit Tutorial - Passo 5

Finally, update tutorial/init.py to make sure Celery gets loaded when the app starts up: from .celery import app as celery_app all = ('celery_app',)