TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

1 pointsby Systemic33about 12 years ago
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

1 comment

frankwilesabout 12 years ago
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.<p>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.
评论 #5437102 未加载