Live data from Hacker News

Eighteen months of Django

dangoldin.com

51–60 of 85 posts

Re: Eighteen months of Django

#51
post #15
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?

Neither! Actually, as the others have said it completely depends on what you're making. Django is great if you're making a standard cms type website. News feed, blog, etc. There's a bit of a learning curve but it gives you a lot of the scaffolding out of the box (and there are loads of examples to learn from). It has the biggest community (I guess?) so you'll always be able to find answers / libraries / sample code.…

> In terms of the admin I think that the days of writing admin grid and edit screens that post back and forth to the server are numbered (I use REST and Angular now) - so that's not a bit of Django I use either.

My feeling too. Are there any projects which are starting to create the boilerplate for this? I'm new to Angular, so looking for where to get started...

Re: Eighteen months of Django

#52
How well does Django handle complex forms? The kind where "if x = y show fields p-r (and make them required), if x = z jump the next screen)?

I've just implemented one of these in PHP using the 'old' Symfony 1.4 and it was painful. I ended up hardcoding most of the frontend, and writing ridiculous modifications for "add another row" and validation.

Is Django any better at that? Complex forms have been my pain point for over 11 years, and if a framework handles them... I'm in!

Re: Eighteen months of Django

#53
post #9

Earlier quoted context omitted.

Funny that I wrote that Flask is for advanced usage and you wrote that Flask is for simple usage. If the project is really simple - no database, no declarative forms etc. - then Flask will be better. But if you go to "medium complexity" Django gives you ready components which you need to integrate in Flask (SQLAlchemy, WTForms etc.). You also need to invent your own project structure, and Django already has a hardcod…

I actually disagree. Flask does not necessarily shine with projects of high complexity. The framework designers themselves say as much: "However Flask is just not designed for large applications or asynchronous servers. Flask wants to make it quick and easy to write a traditional web application."[1] Flask is excellent when you just don't need a bunch of the stuff in Django, and don't need the batteries to be include…

"However Flask is just not designed for large applications or asynchronous servers. Flask wants to make it quick and easy to write a traditional web application."

Armin has said before that he needs to update/clarify that statement -- as dvanduzer said, it's not really relevant anymore.

Re: Eighteen months of Django

#54

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.

What about http://pythonhosted.org/APScheduler/ ? Celery is for more massive, high capacity solutions.

Re: Eighteen months of Django

#55
post #52

How well does Django handle complex forms? The kind where "if x = y show fields p-r (and make them required), if x = z jump the next screen)? I've just implemented one of these in PHP using the 'old' Symfony 1.4 and it was painful . I ended up hardcoding most of the frontend, and writing ridiculous modifications for "add another row" and validation. Is Django any better at that? Complex forms have been my pain point…

Very much this - though I've experienced this in other stacks.

Would love to know the best way people handle this.

Re: Eighteen months of Django

#56
post #52

How well does Django handle complex forms? The kind where "if x = y show fields p-r (and make them required), if x = z jump the next screen)? I've just implemented one of these in PHP using the 'old' Symfony 1.4 and it was painful . I ended up hardcoding most of the frontend, and writing ridiculous modifications for "add another row" and validation. Is Django any better at that? Complex forms have been my pain point…

If I'm understanding you correctly, you want to have the fields on the form depend on the contents of what was entered on the previous form e.g. if user selects name, ask for name, otherwise ask for address.

In that case, I tend to use class-based views and set different forms, templates etc. depending on those values. If the form is different enough, it's easier just to send them to a completely different URL.

Re: Eighteen months of Django

#58
post #52

How well does Django handle complex forms? The kind where "if x = y show fields p-r (and make them required), if x = z jump the next screen)? I've just implemented one of these in PHP using the 'old' Symfony 1.4 and it was painful . I ended up hardcoding most of the frontend, and writing ridiculous modifications for "add another row" and validation. Is Django any better at that? Complex forms have been my pain point…

I've recently (2-3 months) switched to Python/Django and my experience so far has been very positive.

Multi-step forms can be implemented in Django using Form wizards [1]. In order to optionally show fields or make them required I think you could build it easily using the WizardView.get_form method [2]. The functionality to skip steps is built-in and it's very easy implement using conditional views [3].

In conclusion, it's fairly easy to implement the functionality you described using only the core framework without the need to rely on external packages.

[1] - https://docs.djangoproject.com/en/dev/ref/contrib/formtools/... [2] - https://docs.djangoproject.com/en/dev/ref/contrib/formtools/... [3] - https://docs.djangoproject.com/en/dev/ref/contrib/formtools/...

Re: Eighteen months of Django

#59
For dealing with packages such as python-psycopg2 and python-mysql, your best bet is to use --system-site-packages.

This allows the virtualenv to depend on packages provided by your distro instead of trying to compile its own. Wherever possible, I try to do this with Python packages that require a C compiler to make deployment a little easier and reduce dependencies.

Personally, I'm not a fan of Fabric and I much prefer configuration management (Salt, Chef, Puppet) because of the added flexibility you get. About the most I use Fabric for is logging into the Salt Master and kicking off a deployment process.

Re: Eighteen months of Django

#60
post #15

Earlier quoted context omitted.

Neither! Actually, as the others have said it completely depends on what you're making. Django is great if you're making a standard cms type website. News feed, blog, etc. There's a bit of a learning curve but it gives you a lot of the scaffolding out of the box (and there are loads of examples to learn from). It has the biggest community (I guess?) so you'll always be able to find answers / libraries / sample code.…

What is your opinion about web2py? I started exploring it a week back, and it seems to have a lot of built in functionality. I thought it would be the easiest web framework to get started with (since it was originally built to help teach students about web programming). However, it seems to have a vast number of components, and it looks like learning all of it would entail almost the same effort as learning Django...

I've never used it so I really can't comment, sorry. There are a few that I've only skimmed the documentation for to see how they compare to Django / Flask. Bottle for example - when I look through the examples it seems so close to Flask that I don't feel I need to look any closer at it (so I may be missing out on something there).
Post reply on HN