Is it possible to use Django models module only in my project?
<p>I am developing a small independent python application which uses Celery. I have built this using django framework but my application is back end only. This means that the users do not need to visit my site and my application is built only for the purpose of receiving tasks queue from celery and performing operations on the database. In order to perform operations on the database, I need to use Django modules.</p>

<p>What I am trying to do is eliminate the rest of my django application and use ONLY celery and django models modules (including the dependencies required to run these).</p>

<p>In short, my simple celery application will be running receiving instructions from my redis broker and perform operations in database using django models.</p>

<p>Is is possible to do this? If so, how?</p>

<p>Here is my project structure:</p>

<pre><code>myproject/
--manage.py
--myproject/
----celery.py
----models.py
----settings.py
----tasks.py
----urls.py
----wsgi.py
</code></pre>

<p>Here is my settings.py:</p>

<p>You have have a python script that requires some celery tasks and you need Django ORM too for the database interactions. </p>

<ol>
<li><p>You can setup the django project</p></li>
<li><p>create an app for your purpose, include in settings.py and  inside your app in models.py create the required models.
ref : <a href="http://stackoverflow.com/questions/34519576/what-minimal-files-i-need-to-use-django-orm">What minimal files i need to use django ORM</a> </p></li>
<li><p>Set up the environment for executing celery. Ie, redis server.  integrate "djcelery" with django project. for the celery task purpose. 
you can use celery beats for the periodic tasks.  or delay.
ref: <a href="http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html" rel="nofollow">http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html</a></p></li>
<li><p>You can import and use the django models like normal inside the celery tasks. </p></li>
<li><p>And The celery tasks you can run using </p>

<p>i. celery -A tasks worker --loglevel=info</p>

<p>ii. celery -A tasks beat -l info. use beats if you want the tasks which are written for periodic execution. </p></li>
<li><p>If the tasks need to be executed asynchronously just immediately or after a time interval , you can use task_name.delay() 
call the tasks inside the python script using delay()
i think to use djcelery in your script you may need to set up the django env inside the script.
just Do django.setup().</p></li>
</ol>

<p>i think this will help you to solve your problem. </p>

python django django-models celery