Hacker News new | ask | show | jobs
by mik4el 5025 days ago
Thanks! Good starting point. I'd like a section on using django on cloud services, e.g. AWS Elastic beanstalk. Another best practise I'd want is scheduling scripts with https://docs.djangoproject.com/en/dev/howto/custom-managemen... and Cron, or using Celery. There is much confusion on those topics I think.

Edited some spelling...

3 comments

I'm not giving best practises as I'm myself fairly new to Django, this is just a couple of packages to take a look at.

I've been deploying two projects to AWS very recently and we've been using django-pipeline and django-storages (with s3 boto storage) for asset management. ./manage.py collectstatic and all your static files are up on S3. With a bit of finagling around[1] you can even have user uploads hit there seamlessly as well.

[1]: http://stackoverflow.com/questions/10390244/how-to-set-up-a-...

EDIT: Pipeline isn't necessary for storing static files on S3, but if you want to compile SASS/LESS/cs files or any transforms really it works really well.

Thank you!
What's confusing you? (I'm trying to help, not being snarky)

If you want to invoke some Django-based logic at regular intervals without having to install Celery (and monitoring and a decent queue) you'll opt for a management command. The link you posted should help you out here. Invoking the script yourself or telling cron to invoke it for you shouldn't be hard if you know about cron.

With regards to Celery: I think the tutorial and docs are pretty clear on how to use it and how to set it up.

Thanks for your comment =) Nothing is confusing me there, but try to search for "django script cron" and you'll see people suggesting setting up urls to start the script, having an external script that import settings and many other complex things. The craziest thing I've seen (but probably useful for some cases) is to have the regular requests from google-bots invoke scripts... That's why I think it's a good thing to suggest managment commands when they're so easy and integrates nicely with your apps. Celery however is good for more complex usecases. I was merely making a suggestion for best-practise.
I imagine most of those icky suggestions are coming from people who used to run php on hosts with a lot of restrictions. You're right, this should definitely be a part of a best practices guide.
Thanks for the feedback! I filed a couple of issues to address this:

* https://github.com/lincolnloop/django-best-practices/issues/... * https://github.com/lincolnloop/django-best-practices/issues/...

If you think of any more, feel free to file your own.

Thanks! Filed my schedule scripts comment as an issue. Looking forward to see this develop. Hope I can contribute.