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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Django: An Unofficial Opinionated FAQ

3 点作者 spapas82大约 6 年前

1 comment

spapas82大约 6 年前
A bunch of my own opinions to the FAQ:<p>- Should I use Flask or Django? - Agreed, Django<p>- Should I split my code up into multiple apps? - I think it&#x27;s better if you split your code into different apps from the beginning especially if its about different things that don&#x27;t have a heavy relations. For example I usually put my user, profile, preferences etc things in a different app.<p>- Should I use Django’s default template language (DTL) or something else? - Agreed, DTL<p>- DTL doesn’t do what I want - should I use something else like Jinja2? - Agreed, use DTL and mix a bunch of template tags for things that can&#x27;t be implemented with only the DTL<p>- Should I use Gunicorn or uWSGI to run Django? - Agreed, definitely use gunicorn unless you really know what you are doing. uWSGI is a PITA to setup and has various problems with security, when reloading it etc<p>- Where should I deploy my app? - No opinion I mainly deploy to internal (Centos) servers<p>- What should I use to serve my static files? - Whitenoise is a good solution for some projects but if you are going to put your app behind a reverse proxy (i.e nginx) then why not just serve your static files from there directly ?<p>- I’m trying to get the admin to do X… - Agreed, admin is for internal users &#x2F; operators; CBV is excellent. Also if you want something more configurable try my django generic scaffold package: <a href="https:&#x2F;&#x2F;github.com&#x2F;spapas&#x2F;django-generic-scaffold&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;spapas&#x2F;django-generic-scaffold&#x2F;</a><p>- What database should I use? - Agreed, Postgres all the way; don&#x27;t forget to take a look at the django-postgresql specific models <a href="https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;2.1&#x2F;ref&#x2F;contrib&#x2F;postgres&#x2F;fields&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;2.1&#x2F;ref&#x2F;contrib&#x2F;postgres&#x2F;f...</a><p>- How should I split my settings file between production &#x2F; development? - I disagree; I use the common pattern with a settings package and dev&#x2F;uat&#x2F;prod modules. Using env vars is not always feasible since python is much more expressive than a string (think when you need to setup a setting with a dict)<p>- Should I use a custom User model? - Agreed; follow the docs if you start from scratch but be careful if you have a project with live migrations