TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Django Best Practices

48 点作者 rs超过 13 年前

5 条评论

zentrus超过 13 年前
I have been using Django for about 6 months now. Previously, I had been working on PHP and Rails apps. I have been looking hard for some good best practices for Django. There are some things I really like about Django. I like it's readability and I like that new web developers can get up to speed rather quickly. There is one area that I really wish were better though. It is unfathomable to me that the norm (and best practice too apparently) is to cram pounds of code into single files (views.py, models.py, etc). Now sure, it's Python. You can break it up. But the documentation and also what you see in Django projects perpetuates this insanity. To break up your models, you must add additional glue code to each and every model (app_label) and if your app is large you <i>will</i> run into circular import issues. This is just not practical for medium to large projects. The best practice is to break up your project into applications. Yes, that does help some but you still are going to want to break up an app's model, view, etc into multiple files. Isn't this common sense? This and other areas of Django often makes me wonder: Why does Django make it easy to do the wrong things and hard to do the right thing?
smackay超过 13 年前
It is good to see this but it is also an indictment against Django that there is no one, true way to get it all set up. Since everything is a python module it really does not matter how everything is configured, only that it can be found somewhere on the path, however this causes a great deal of confusion when getting started that leads to a lot of frustation until the module penny drops.
评论 #2937052 未加载
earle超过 13 年前
<a href="http://blog.zacharyvoase.com/2010/02/03/django-project-conventions/" rel="nofollow">http://blog.zacharyvoase.com/2010/02/03/django-project-conve...</a><p>Is much more complete IMHO
评论 #2937089 未加载
Halienja超过 13 年前
Django devs should bookmark this <a href="https://code.djangoproject.com/wiki/DjangoResources" rel="nofollow">https://code.djangoproject.com/wiki/DjangoResources</a>
ndreas超过 13 年前
This is nice. I've been wanting to dabble a bit in Django, but I find it a bit hard to find basic information like this, for example, how to decide when creating a separate app inside a project is better than putting everything in a single app.<p>It definitely helps to have conventions to follow while you're learning, until you become proficient enough to break those conventions.
评论 #2937107 未加载