Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app file structure #100

Closed
SummerSeaSun opened this issue Oct 22, 2015 · 3 comments
Closed

app file structure #100

SummerSeaSun opened this issue Oct 22, 2015 · 3 comments

Comments

@SummerSeaSun
Copy link

I've already worked with django, sorry if this is a silly question.

This is the usual file structure:

project:
mydata_app
manage.py

I should add the tasks to a file called tasks.py?
It should be inside mydata_app or in the projects directory?

the call for the tasks can be placed in the views.py?

@Eagllus
Copy link
Collaborator

Eagllus commented Oct 23, 2015

Hi @summer88,
I recommend placing all your tasks related to a app in a file named tasks.py
example:

project:
    my_app/
        tasks.py

   my_other_app/
        tasks.py

   manage.py

The location you where you call a tasks is depend on where you want the task to go to the background.
Nice examples of this are available in the documentation.
https://django-q.readthedocs.org/en/latest/examples.html

@Koed00
Copy link
Owner

Koed00 commented Oct 23, 2015

Django Q does not enforce a location for your task. It can be any function inside your environment.
As long as it's importable, you can run it as a task. However it is always good practice to keep things together in once place.

You can use imports:

from my_app import somefunction

async(somefunction, somearguments)

or full paths:

async('my_app.somefunction', somearguments)

both do the same thing.

@SummerSeaSun
Copy link
Author

Thanks for the explanation, I will try it out asap!

@Koed00 Koed00 closed this as completed Jan 9, 2016
panhaoyu pushed a commit to panhaoyu/django-q that referenced this issue Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants