« Simple Character Truncate Filter And Dot Dot Dot Variant | Home | Joost Meets Django »
Using Django Models In Batch Jobs
By Paul Kenjora | July 4, 2007
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
- Contact
- Constructive reasons to use Django instead of Rails (Proxied)
- Django Generic Relations Made Easier
- All You Need For Parsing RSS Feeds
- Django Deserializer Bug On Foreign Key When None
Aware Labs Recommends
- Five Things I Hate About Django. (USwaretech)
- Why you should try Django : Agility (Dougal Matthews)
- Django Request Response processing (USwaretech)
Topics: Batch Code, Code Snippets, Tutorial | Comments
-
pkenjora
-
Mathieu Fenniak
-
SuperJared