Using Django Models In Batch Jobs
If you want to run batch jobs that support your Django website the model interface is very handy. You may even use templates with this approach. Here is the basic setup to run Django applications from the command line.
#!/home/username/lib/python2.4
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'arkayne.settings'
sys.path.append(os.path.abspath('/home/someuser/django'))
sys.path.append(os.path.abspath('/home/someuser/lib/python2.4'))
from arkayne.arkayne.models import Page
def main(argv):
pages = Page.objects.all()
for page in pages:
print page.url
if __name__ == "__main__":
main(sys.argv[1:])
More from Aware Labs
- Retiring Old Posts To Keep Django Fresh
- Django Generic Relations Made Easier
- Constructive reasons to use Django instead of Rails (Proxied)
- What Is Your Version Of Django
- All You Need For Parsing RSS Feeds
Aware Labs Recommends
- Popularizing Django — Or Reusable apps considered harmful. (USwaretech)
- Using Google AdWords Keyword Tool (The Arkayne Blog)
- Django’s tipping point (Antonio Cangiano)
-
pkenjora
-
Mathieu Fenniak
-
SuperJared

![Recommend [AwareLabs]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)