Live data from Hacker News

Eighteen months of Django

dangoldin.com

21–30 of 85 posts

Re: Eighteen months of Django

#21

Great short and concise article. I'm in the process of writing a pet project using Django and would really appreciate your insights on what packages you find useful (as mentioned at the bottom of your post).

From someone who wasn't asked but has input... ;)

It's not a Python package in the sense that you might mean, but using virtualenv is absolutely fundamental to good Python development (at least the kind that lets you keep your sanity).

South is also exceptional; however, the developer recently ran a successful Kickstarter campaign dedicated to creating an improved version intended to be merged with Django itself, so that's something to watch for.

Django-CMS has proven invaluable for many of my projects and clients, though it's very heavy and more of a project-tacked-on-to-your-project than just a package. It's great to know, though, and very powerful.

django-registration can be useful if you're into full-on user profile usage, though many sites don't actually need this. There's a separate project that provides a set of default templates for this package, and it's almost more useful than django-registration itself.

livesettings is an outgrowth of django-cms that's pretty useful when you need what would otherwise be settings.py constants that can be modified at runtime without a deployment and server restart. Be careful, though, as overuse of this means you might have design issues.

feedparser is a very, very easy way to consume XML feeds.

If you want to parse something in a very user-friendly way, BeautifulSoup is hard to beat. If you're into the nitty gritty and/or need serious performance, lxml serves the same purpose but kicks far more ass.

If you need to interface with Amazon's AWS environments (EC2, S3, etc.), boto is a brilliant library.

These are more Python-in-general than Django-specific, but that's often a good thing.

Re: Eighteen months of Django

#22
post #2

As someone who is thinking about doing a python project, should I learn Django or just go with Flask? Any thoughts on those two?

I've been building (more or less solo) a web app marketplace for our startup for about a year now. I love Python, and had dabbled in Django and Flask prior to this, but built nothing with either to any significant degree. I went with Django because I was able to get something up relatively quickly, and I feel like that was a solid decision. I also am relatively confident in my ability to move towards Flask in the longer term if the Django app becomes too much, but I haven't experienced that yet.

Also Heroku has been mostly a godsend, as I haven't had to spend nearly any time on sysadmin stuff. One thing that caught me early on, not sure if it's a bug or what, but in Heroku, if you use git URLs for some of your packages in pip requirements (which is useful if you need to customize a package or more frequently fix a bug and can't wait for it to be pushed to pypi), Heroku's package cache has trouble knowing when to update unless you a) change the package version in its setup.py (may or may not be a good idea) or b) change the Python version in runtime.txt (kind of a pain as generally that means two deploys for an update, bump down one minor, then back up).

Re: Eighteen months of Django

#23
post #2

As someone who is thinking about doing a python project, should I learn Django or just go with Flask? Any thoughts on those two?

Flask is so simple that it's definitely worth picking that up regardless (in any case, I think it's well done and worth having in your arsenal).

However, for large web projects, Django beats it hands down. Doing similar work with Flask would require so much wheel-reinvention that it'd be hard to justify your time or your client's money when it's all built quite well already.

Of course it's not perfect, and it's not for everything. But it's a great general-purpose, medium-performance web framework. It becomes a pain on very high-traffic sites (perhaps more so than JVM-based solutions and on par with scaling Ruby frameworks), but if you use it in the right place and/or team up with systems people that know their stuff, it's a powerful tool for quickly building complex websites in a maintainable and intuitive way.

Re: Eighteen months of Django

#24

I'll add that if you need to background anything, django-celery makes it easy. celeryd is also good for scheduling tasks with either single or periodic execution. http://docs.celeryproject.org/en/latest/getting-started/firs... You can also use it in a typical task queue role. It will pickle or serialize the Python objects that accompany tasks for transmission over the wire.

Note that periodic execution, one of the more useful aspects of celery, is not supported on all backends. If you're using rabbitMQ, you're golden. If you're using most or all other transports (including SQS), you're likely SOL and will have to resort to either bare cron jobs or something like django-cronograph that accomplishes the same thing.

celery is definitely nice, but it does have its limitations (like everything else).

Re: Eighteen months of Django

#25
post #12

Using S3 for static media makes perfect sense, but does anyone have information on S3 when your contributors (users in the admin) are uploading lots of images for via something like django-filebrowser or a simple zipfile upload (that extracts the images into a folder)? I haven't seen anything like this in any examples.

I think the standard method of dealing with this is to have your users upload the items to the local web server and then have some sort of async task or cron job responsible for moving the files to S3 later on.

Of course this means you'll have to keep track of where the uploaded file is currently located, but if you ever want to scale to multiple web servers you'll need to do that anyway.

Re: Eighteen months of Django

#26
post #12

Using S3 for static media makes perfect sense, but does anyone have information on S3 when your contributors (users in the admin) are uploading lots of images for via something like django-filebrowser or a simple zipfile upload (that extracts the images into a folder)? I haven't seen anything like this in any examples.

This is supported quite well via django-storages. Unless the libs you're using are doing something manual instead of using Django's built-in file handling, this will neatly override the local-filesystem defaults and send all of your content to S3.

http://django-storages.readthedocs.org/en/latest/

Re: Eighteen months of Django

#27
post #7

Earlier quoted context omitted.

If you are new to Python and just want to have a working project instead of tinkering, then Django is better suited. Flask is for more advanced uses where you need to have more control or be able to integrate components you choose (like SQLAlchemy instead of Django ORM, or a NoSQL DB).

I disagree somewhat.. I'm a hobbyist at best when it comes to programming. Like I've never actually shipped anything in my life. I recently decided to put an end to that to solve a problem for a family member's business. They just wanted a simple web form, where the sales people could add notes throughout the day and then automatically email those notes to the owner at the end of the day. I first tried Django and was…

Flask is definitely easier... it also offers far less. Which is fine in some circumstances -- perhaps many -- but the fact that Django has a steeper learning curve is due to the fact that it covers a lot more ground in terms of things many if not most web applications need.

This doesn't make it better, but it also doesn't make it worse.

Re: Eighteen months of Django

#28

Great short and concise article. I'm in the process of writing a pet project using Django and would really appreciate your insights on what packages you find useful (as mentioned at the bottom of your post).

From someone who wasn't asked but has input... ;) It's not a Python package in the sense that you might mean, but using virtualenv is absolutely fundamental to good Python development (at least the kind that lets you keep your sanity). South is also exceptional; however, the developer recently ran a successful Kickstarter campaign dedicated to creating an improved version intended to be merged with Django itself, so…

Thanks for the reply.

While all suggestion are useful the biggest take away for me is livesettings. TBH I can't think of how I would use it at the moment but I can see that it could come in handy later.

Re: Eighteen months of Django

#29
post #2

As someone who is thinking about doing a python project, should I learn Django or just go with Flask? Any thoughts on those two?

You might also want to take a look at Pyramid. There's pros and cons for each.

I absolutely love pyramid, but I found the learning curve for it to be much higher than flask or django. If pyramid had a few more things working in a simple way out of the box I would go for it every time.

Re: Eighteen months of Django

#30
post #12

Using S3 for static media makes perfect sense, but does anyone have information on S3 when your contributors (users in the admin) are uploading lots of images for via something like django-filebrowser or a simple zipfile upload (that extracts the images into a folder)? I haven't seen anything like this in any examples.

You can use S3's CORS support to allow your users to upload directly to S3 without even touching your server. Downside is that it can be hard to debug and it requires your users to use JavaScript -- but otherwise it's a big win.

See http://philfreo.com/blog/how-to-allow-direct-file-uploads-fr... for a Python example.

Post reply on HN