

Ask HN: Isn't generic views in django a bad practice (seperation of concerns) - Systemic33

In the Python tutorial documentation, it teaches the use of moving stuff like index, detail, etc into the urls.py. But isn't this bad practice, since it now mixes the url handling with presentation logic? What is HN's take on this?
Link to documentation: https://docs.djangoproject.com/en/1.5/intro/tutorial04/#use-generic-views-less-code-is-better
======
frankwiles
Not really a bad practice, more of a personal style choice. The concerns here
aren't any more mixed than if you created a views.py and sub-classed the
generic views settings your own options. urls.py just maps patterns to views,
it's just in this case you're setting several options on some generic views.

That being said, I almost always DO separate them because over time your
generic views often become more complex and more overridden. I also personally
prefer my urls.py to not get so "messy", but it's not really a horrible
practice or one with a lot of downsides.

~~~
Systemic33
That's exactly what I was thinking, just doing the simple example in the
tutorial makes the urls.py seem bloated in my eyes.

