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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Why should I use Django?

92 点作者 xcoding超过 8 年前
I want to build an app allowing users to search local car for rent availability.

36 条评论

cyberpanther超过 8 年前
If you want to use Python then use Django. As with any framework, it can be hard to work around but Django gives you the most options to work around the framework than any other framework I&#x27;ve found.<p>Normally, if you are having a hard time with Django its because you&#x27;re trying to work around it the wrong way. This takes time to learn but Django can be really elegant to work around and with.<p>The second option is Flask or Tornado which are pretty great too. Both would give you more freedom but also less structure. I find it better to have the structure because unless your an experienced engineer your Flask or Tornado project will turn messy quick. Django projects can turn messy too, but at least there is a more training and protocols for people to follow.<p>I use Flask&#x2F;Tornado if I want to use Python and I know my project is a small service and will probably not get big.<p>I use Django if I want to use Python and I know the project will grow over time or I need features from the start like a database, migrations, cache, etc.
评论 #13027691 未加载
评论 #13033503 未加载
评论 #13029404 未加载
jonasvp超过 8 年前
We&#x27;ve built web applications based on Django for small CMS sites, large multi-language CMS sites, up to large custom-built applications (mostly API-based) for the likes of Mercedes-Benz and Deutsche Bahn. I can honestly say that I never regretted the decision.<p>It scales beautifully (see the likes of Instagram, Disqus, Sentry, etc.), has a great security track record, sane deprecation schedules, and the core team keeps up with the times and new technologies but does so at a sane pace and without rushing things.<p>Not to mention the documentation - ohmygod, the documentation!<p>In a nutshell: pick Django, keep learning Python, and try to build something that your users love.
评论 #13031498 未加载
评论 #13025747 未加载
hobarrera超过 8 年前
Things I really like about django that are objectively good:<p>* A lot of _very common_ situations and patterns are already solved for you, and they&#x27;re solved in the cleanest way possible.<p>* The documentation is excellent, both with &quot;guides&quot;, examples, and API reference. Django (along with OpenBSD), has probably the best documentation I&#x27;ve seen around.<p>* Clean design (of django itself) means that you can extend it, or avoid using bits that for some reason don&#x27;t suit you.<p>* Very transparent development, and the developers are really into open source - everything is done out in the open. This last point might not be really important as a user, but it helps if you ever want to contribute (or understand) anything to django itself.<p>---<p>Even after years of django, I very occasionally still come across a functionality in django that I&#x27;d overlooked and saves be a bunch of my own code.
falcolas超过 8 年前
If you have a usecase that matches Django&#x27;s niche - i.e. a CMS style CRUD application - you would have a hard time doing better than Django. If you&#x27;re not in that usecase, think long and hard about it. Django is fantastic to use when writing with the framework, and a nightmare to work around when you need to do something it doesn&#x27;t easily support.<p>Your app does sound like it is in Django&#x27;s wheelhouse (CRUD against a DB with users), so it is probably a good fit.
评论 #13024145 未加载
wahnfrieden超过 8 年前
Django REST Framework is Django&#x27;s killer app (as Django is Python&#x27;s killer app). If you need an API, it&#x27;s a great batteries-included way to build one.
评论 #13026594 未加载
评论 #13024190 未加载
评论 #13024205 未加载
评论 #13026808 未加载
评论 #13024301 未加载
评论 #13024302 未加载
superquest超过 8 年前
Before I was sophisticated enough to investigate such decisions on my own (given the mass of discussion freely available on the internet), I really don&#x27;t think it mattered which framework I chose.<p>So I&#x27;d suggest you just some popular framework and don&#x27;t worry whether it&#x27;s the right one. Pick one and run with it!
dopeboy超过 8 年前
I picked up Django early 2015 and it has been my choice of backend ever since. Though I haven&#x27;t used Django to build a fullstack application, I have used Django REST framework extensively for my backend. Impressions over 1.92 years:<p>1) Great documentation. Well organized, well written. Good balance between theory and examples.<p>2) Superb ecosystem. Coming from PHP land, I got the sense of a &quot;anything-goes&quot; mentality. On SO, people who help are very much interested in doing things the idiomatic way.<p>3) You get to practice Python!
评论 #13024411 未加载
rubberstamp超过 8 年前
Consider Pyramid web framework. Deploy it on gunicorn server with eventlet workers. Use pushpin if you need realtime.<p>Its easy, it scales, use any DB and Pyramid framework has good documentation too.<p>Or go with web2py if you need to start simple and easy and fast prototyping. It has an ORM which supports many Relational DB and MongoDB too if you need it. It has good documentation. Its authentication and authorization system is too easy.<p>Stick to python3.<p>Really good python learning resources.<p><a href="http:&#x2F;&#x2F;www.diveintopython3.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.diveintopython3.net&#x2F;</a><p>and<p><a href="http:&#x2F;&#x2F;greenteapress.com&#x2F;wp&#x2F;think-python-2e&#x2F;" rel="nofollow">http:&#x2F;&#x2F;greenteapress.com&#x2F;wp&#x2F;think-python-2e&#x2F;</a>
评论 #13027496 未加载
dom0超过 8 年前
Django is a good framework, because it&#x27;s opinionated about <i>the right</i> things (ie those that fit most very well).<p>Also, &quot;there&#x27;s an app for that&quot;. The ecosystem is large and healthy.<p>If you don&#x27;t want Django cause it&#x27;s Django, then Flask and Pyramid are other excellent alternatives. There is also a swath of more specialized frameworks (eg. Tornado).
dexterbt1超过 8 年前
I&#x27;m copying here what I wrote back in 2013 to some other forum, much of it is still true...<p>Django is mature, full-stack, flexible, has sound architectural decisions behind it, relatively good security track record. There is a built-in admin and permission systems to help with what you require. Batteries included such as an ORM, templating, routing, forms. The Django third-party apps&#x2F;module ecosystem is rather large and accessible: from authentication, social media integration, payment gateway integrations, APIs, to whole apps like invoicing, helpdesk, etc.
jstimpfle超过 8 年前
I don&#x27;t have experience with Django, but you could also just build everything yourself on plain WSGI (the python version of (Fast)CGI).<p>Note I am not saying &quot;build a new, generic framework because all other frameworks stink&quot;. Building libraries with the goal to support other projects is a neverending task.<p>But only building the support paste as you actually need it is not a lot of work. WSGI is a quite simple interface. I&#x27;m doing this myself and the support I currently need is only ~500 lines. The only external library I use is jinja2 templates. As database I use plain sqlite3 from the python standard lib and in some places text files.<p>If you don&#x27;t know and don&#x27;t want to learn HTTP and Web application architecture you will of course end up with a broken design. On the other hand it&#x27;s very rewarding to learn how to decompose an application into independent components (templates, services, routing, database access, business logic, authorization, session management, config parsing, project directory structure, what have you).<p>The other big advantage is of course flexibility. If you do a good job the decomposition is better than with a framework. This means flexibility. It&#x27;s easier to fix problems than with an opinionated framework.
olavgg超过 8 年前
I think frameworks like Django, Rails or Grails are excellent tools for building many business applications. Especially when there are plenty of CRUD operations and complex workflows with different administrative roles. These frameworks excels in developer productivity, stability and maintenance over years.<p>I&#x27;ve been using Grails for over 10 years, my clients are super happy with what I have delivered. I&#x27;ve built complex issue tracking systems, e-commerce web sites, administration panels, data management tools and so on. Code I wrote 10 years ago is still working fine today! I highly recommend learning one of these frameworks, you will make new friends and good money!
评论 #13034319 未加载
kayman超过 8 年前
If you&#x27;re using Python and don&#x27;t use Django (I&#x27;ve tried it as an exercise for one of my pet projects), you have 2 options.<p>Create your own framework - writing http headers etc from scratch which will take you forever or Use a lightweight framework like Flask or Web.py.<p>Either way, you&#x27;ll end up creating your own ways to query the database and creating patterns to communicate with frontend. As you write more code, you&#x27;ll abstract your code to reusable methods.<p>About a month into the project, you&#x27;ll realize that you&#x27;re slowly rolling out your own framework which has grown organically.<p>Soon you&#x27;ll realize you&#x27;re better off using a polished framework like Django which has abstracted many of the details so you can focus on delivering value instead of clobbering together your own framework which will become a burden to maintain alongside your app.
评论 #13026878 未加载
评论 #13026765 未加载
dv35z超过 8 年前
Any Django developers who have made the switch to Play Franework (in Scala), would you share your experience? About to go down that route, and would like to know if it&#x27;s as great as everyone says, challenges, etc. The usecase is fairly mundane CRUD app, 10-15 interconnected tables.
评论 #13026090 未加载
alexbecker超过 8 年前
Django is great for fast prototyping if you need very dynamic pages (because views written in Python are so powerful), a complex site structure (because it has excellent url routing), and lots of database interaction (because of the ORM). If you only need the first two, I recommend Flask instead.<p>But be careful if you intend to create a stable, heavily-used site. I have so many problems with Django in this use case that I&#x27;ve gotten tired of listing them each time it comes up and collected them into a blogpost: <a href="https:&#x2F;&#x2F;alexcbecker.net&#x2F;blog.html#django-is-terrible" rel="nofollow">https:&#x2F;&#x2F;alexcbecker.net&#x2F;blog.html#django-is-terrible</a>
megamark16超过 8 年前
Django gives you a ton out of the box, with lots of sane defaults, but it still allows you to override those defaults when you&#x27;re ready for more complicated functionality or business rules. I like the templating language, it lets you drop a lot of dynamic functionality into existing html templates, while staying out of the way for the most part.
econner超过 8 年前
Lots of people will say not to use Django because ORMs don&#x27;t scale. In my experience, if you don&#x27;t use an ORM you end up writing one (and doing a poor job) in the early stages of a project. Usually this happens because you&#x27;re changing things quickly and favoring iteration time. You don&#x27;t know what you&#x27;re building yet, so you can&#x27;t choose the super optimized solution. Once you need to scale things can become specialized and it&#x27;s easier to go that route because you have a better idea what you&#x27;re building.
评论 #13024764 未加载
NumberCruncher超过 8 年前
If you want to use python I would give web2py + intercooler.js a try. It is &quot;good enough&quot; for most CRUD pet projects. Reading here the comments about Django&#x27;s advantages an inner voice always says &quot;fine, web2py has it too&quot; except the excessive documentation and the weird non-pythonic syntax.<p>If you want to make something really professional just ignore the words of a n00b.
koliber超过 8 年前
Figuratively speaking, Django gets you from zero to 60mph in 2.4 seconds. Getting from 60mph to 100mph takes 20 seconds. Going above that takes a lot more time.<p>Lacking details, it seems like your app could be a good candidate for Django.<p>For me, the main appeal is the Django admin. It gives you a great way of interacting with your data with minimal effort.
评论 #13026731 未加载
rayalez超过 8 年前
As far as the backend frameworks go, you have the 3 most popular, very good options:<p>- Ruby on Rails<p>- Node + Express<p>- Django<p>The major reason I have picked Django is that it is written in Python, which allows me to use an elegant and beautiful language that I can apply in any field, and utilize a huge amount of python apps, scripts, and stackoverflow examples.<p>Using Django has also enabled me to learn the solid foundations of web development, which I can expand upon and apply anywhere.<p>For example now I am experimenting with React and Express, and knowing Django helps me enormously, it makes understanding these things way easier.<p>I have built a bunch of projects with Django, and I am extremely happy about my choice, so I highly recommend it to anyone who is beginning to learn web development.
idm超过 8 年前
Django has excellent documentation. Whether you&#x27;re a beginner or an expert, it is appropriate. That is to say: there are good tutorials for starting out and there is good reference material for going deep.<p>As others have mentioned, Django is opinionated and I think they get it mostly right.<p>I use Flask myself, in part because I wish for my data modelling language to be a separate part of my stack, but my use of Flask is heavily influenced by Django&#x27;s philosophy.<p>I am the primary developer of Flask-Diamond, which attempts to adapt Django&#x27;s opinionated choices to Flask. However, I would still recommend that most people start with Django.
welder超过 8 年前
This post about Django vs Flask might help you decide to use Django or not:<p><a href="https:&#x2F;&#x2F;wakatime.com&#x2F;blog&#x2F;14-pirates-use-flask-the-navy-uses-django" rel="nofollow">https:&#x2F;&#x2F;wakatime.com&#x2F;blog&#x2F;14-pirates-use-flask-the-navy-uses...</a>
jasonthevillain超过 8 年前
The reason I keep sticking with it is the &quot;optional batteries included&quot; approach. User auth, for example, is something that just works out of the box with the admin&#x2F;ORM, and has a lot of basic security necessities addressed.<p>In a more a la carte framework, such as Flask, there are packages to help with user auth, but you have to do a lot more work to get them working with whatever ORM you choose.<p>This means I can spend my time making products instead of wrangling packages together.
andr超过 8 年前
After spending several years developing in Django, I am currently building something in a Scala web framework (not gonna name names) and the level to which Django just works is utterly amazing.<p>If your application fits the use case - a mostly CRUD application based on SQL, HTML-based or REST, no heavy real-time component - don&#x27;t think twice about it. Of course, none of those factors are a hard limitation, but if you stick to them, Django fits like a glove.
al11588超过 8 年前
All you need to do is use Django as the backend create a rest API and then use react or Angular to retrieve the data.
zitterbewegung超过 8 年前
Do you want to make a CRUD app and know python with good documentation and batteries included? Use django.
dopeboy超过 8 年前
Couldn&#x27;t anyone comment on the pros&#x2F;cons of using Flask? Currently I&#x27;ve been using DRF and it&#x27;s been serving my needs pretty well. I&#x27;m curious if there&#x27;s anything to be gained from Flask.
cmdrfred超过 8 年前
Are you proficient in Python?
评论 #13024089 未加载
sunstone超过 8 年前
Because you&#x27;re a gentleman of exceptional demeanor, character and surpassing technical judgement, who unfailingly chooses the best tool for the job at hand from the Maelstrom of pretenders.
评论 #13026141 未加载
wenbin超过 8 年前
Popular websites &#x2F; online services that use Django: - Instagram - Pinterest - Nextdoor - The Onion - Disqus - Washington Post - Bitbucket - Eventbrite
morissette超过 8 年前
And thoughts for microservice architectures? I run flask for our microservice backend and have a angular frontend decoupled from the backend
评论 #13031076 未加载
ericfrederich超过 8 年前
<a href="https:&#x2F;&#x2F;youtu.be&#x2F;Niq-HoraNPo" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;Niq-HoraNPo</a>
symmitchry超过 8 年前
Nice documentation in one good reason. The official tutorial is great.
garymoon超过 8 年前
I have experience with Flask, that&#x27;s why I have the same question.<p>Any answers?
评论 #13024243 未加载
评论 #13024159 未加载
pmontra超过 8 年前
I read in an answer of yours that you&#x27;re learning Python. I learned Ruby myself with Rails in 2005 because I had no other reason to use Ruby back then. Rails was a much lighter framework than Django is now. I would recommend to start with something very lightweight, get the gist of it and move on to Web2py or Django.<p>What you&#x27;re looking for could be Flask or even something simpler like<p><a href="https:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;library&#x2F;simplehttpserver.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;library&#x2F;simplehttpserver.html</a><p>or its Python3 version<p><a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;http.server.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;http.server.html</a><p>Now, about Django...<p>I inherited a Django project and after a few months working on it I wouldn&#x27;t start a project of mine with it. Obviously customers can ask me to do anything :-)<p>Disclaimer: I might be biased against it because I don&#x27;t like Python much (it looks like a badly engineered Ruby, and probably the other way around if you like Python, no bad feelings).<p>First problem: coming from 10 years of Rails, Django is very weakly opinionated, so you can arrange the project as you want, name the db fields as you want, etc. This is not as bad as having no framework or using Flask, but a developer joining a project might have to spend time to get familiar with the general structure of it (and the bill for the customer keeps growing, so the chances he won&#x27;t be happy).<p>Second problem: it doesn&#x27;t import automatically every model and module. It gets tiresome to do that in every file and in the shell (and the bill...) This is not a language thing because Ruby has to import modules too but somewhat Rails works around that. Surprisingly it raised problems for me only a couple of times. The sum of the time lost with Python in the last few months is greater than the one I lost in Rails because of that.<p>Third: the templating language is not Python but some crippled down language. Somewhat people still manage to write nice code with Web2py which uses full Python in the templates. Rails too. Why not Django? More time lost to learn one more thing.<p>Web2py is an alternative but it has its share of problems: the first two of Django plus a very risky approach at migrations which are automatically enforced as soon as you run the code. If there is a way to turn that off and you really like Python or have to work with it, look at Web2py.<p>About the nice points, it&#x27;s got everything that it has to be taken for granted in a past 2005 web framework: tests, migrations, ORM. It doesn&#x27;t miss any particular feature, it&#x27;s got a big community so it&#x27;s a safe choice and I won&#x27;t steer customers away from it.
评论 #13025374 未加载
评论 #13030100 未加载
dschiptsov超过 8 年前
In theory, one should take a look at web.py and flask first.. It will teach essentialism and minimalism (web.py) and doing the right thing in a right way (all of them and Python in general).