18 comments

  • matsemann1 hour ago
    I really like the ORM and the migrations, but some parts I really dislike. They&#x27;re maybe not Django&#x27;s fault, but how it&#x27;s used most places:<p>* Models being passed around everywhere, queries happening everywhere. I prefer having a dedicated service&#x2F;selector layer to do those things. Then convert to pydantic objects or something that&#x27;s passed around further.<p>* Corollary, but adding stuff to querymanagers quickly goes out of control. Sure, it&#x27;s nice to reuse MyModel.objects.annotate_something().annotate_something_else().... but it can quickly become unwieldy and even wrong with exploding joins. And it promotes doing queries in places they shouldn&#x27;t happen.<p>* It&#x27;s veeery easy to make spaghetti. Very easy to query across boundaries, into other apps. Fine on smaller projects, but in huge codebases it quickly makes things hard to control, especially since it&#x27;s all stringly typed. If I want to modify my model, it&#x27;s hard to know if someone else have done a query where they did theirmodel__some_relation__another_relation__mymodel__some_field. Blows up in production.<p>* For some reason it&#x27;s very common in Django&#x2F;python projects to have types.py, models.py, selectors.py, views.py, services.py etc. And then each of those end up with lots of unrelated things in the same python file, while related stuff is spread over many files. Django apps doesn&#x27;t really solve this cleanly either.
    • kitsune_32 minutes ago
      The ORM is really not good in my opinion because it is ActiveRecord&#x27;ish and has all its downsides. I wouldn&#x27;t use Django for any moderately complex domain. But even with simpler CRUD style apps I don&#x27;t really see the point in it.
    • DarkNova61 hour ago
      I seriously don&#x27;t get why Django ORM is using the Active Record pattern. This is such a stupid footgun that trivially causes horrible performance and BEGS you to cause n+1 problems.<p>Never in my life did I have a problem with lazy loading causing unbearable performance until I joined a Python Django team. I really tried to find sympathy for the &quot;dynamically typed&quot; folks (please spare me saying Python is technically statically typed), but coming from writing apps and backends in Java, Swift, C#, Objective-C and PHP, Python with Django was the worst experience bar none.<p>I worked on the project for 10 months, could at least refactor the project to something semi-sane where obvious mistakes (which would not be possible in other languages) could not happen. Then along comes a &quot;good Python dev&quot; and threw it all out of the window and start doing SQL queries all over the place (typically 3-6 lines long), remove the domain objects and cause the same problems I started with to begin with. But his approach was saying that the other developers were &quot;not good enough&quot;.<p>Yeah, have fun with schema changes going forward. Good riddance.
      • senko32 minutes ago
        Yes, if you attempt to use Django like you&#x27;d use your typical Java, Swift, C#, or Objective-C framework, you&#x27;re not going to have a good time.<p>I&#x27;ve seen the horrors Java devs start doing on a Python project when trying to &quot;fix&quot; things, where by &quot;fix&quot; they mean use patterns they had to in previous gigs.<p>It&#x27;s a different world.
        • DarkNova625 minutes ago
          Having basic defensive programming, some simple classes instead of dicts everywhere and avoiding n+1 is a &quot;different world&quot;?
      • JodieBenitez36 minutes ago
        &gt; BEGS you to cause n+1 problems<p>select_related, prefetch_related. n+1 problems be gone.
        • DarkNova628 minutes ago
          You misunderstand. And that is exactly the problem.<p>We did do that and that&#x27;s why our queries ended up being several lines long. But if you missed just one model? You openly walk a knife again.<p>It&#x27;s a mess and it only gets longer and longer. I ended the project with having some proper aggregates, only for that to be thrown out of the window by the guy after me.
    • Oxodao42 minutes ago
      I despise django-orm, doctrine is so much better. Like, who thought that using named arguments to do stuff was a proper way ??? `.filter(created_at__gte=XXXXX)` why? The rest of the framework is great but the ORM is definetly its weakest point.
      • zelphirkalt25 minutes ago
        I find those double underscore kwargs weird too, and would prefer to simply pass a lambda instead. What is your idea, what would you suggest?
      • JodieBenitez34 minutes ago
        Having used Doctrine, hard disagree. Never again.
  • phn25 minutes ago
    The only part I don&#x27;t really agree with, is the avoidance of app separation and signals. It&#x27;s one of the cleanest ways to decouple your modules and keep some level of sanity in a medium-sized codebase. It comes down to deciding what parts really need to depend on others and be very explicit about that.<p>I generally end up with a few core apps with the main data objects that a lot of other &quot;parallel&quot; ones depend on, a bit &quot;star shaped&quot;. And then a few &quot;aggregator&quot; apps that cover functionality that needs to work across multiple of these domains. I see it all as an extension of how you think about your data model.
  • stuaxo1 hour ago
    Nice.<p>I&#x27;ve been meaning to do my own Django post, on some other bits we take for granted - I should do it.<p>People should be using Django, the best parts are so useful you don&#x27;t notice them until you switch platforms and implement them badly.<p>Every app that used a more narrow solution ultimately ends up implementing parts of Django badly.<p>The best way to solve this from Djangos side would be to have official ways of:<p>- Using the ORM outside of Django - Doing single file Django apps<p>Both of these have various 3rd party solutions, which shows demand.<p>In the past other bits of Django have been split off by 3rd parties but those two are the places to start.
  • saaspirant54 minutes ago
    Django for Startup Founders: A better software architecture for SaaS startups and consumer apps: <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20210624040717&#x2F;https:&#x2F;&#x2F;alexkrupp.typepad.com&#x2F;sensemaking&#x2F;2021&#x2F;06&#x2F;django-for-startup-founders-a-better-software-architecture-for-saas-startups-and-consumer-apps.html" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20210624040717&#x2F;https:&#x2F;&#x2F;alexkrupp...</a><p>This article is very useful.<p>I use DRF but not serializers and write validations by hand because it is too abstract for me.<p>My views just call services and return the result.
  • JodieBenitez2 hours ago
    Most loved feature, for me: No dramatic changes, just sane and careful evolution.
    • almost0 minutes ago
      This is so important. I&#x27;ve been using Django for around 20 years and my current code base is 10 years old. Not having to do major rewrites or stick on outdated versions really matters.
  • harrouet1 hour ago
    Ah the old debate about function-based views and class-based views.<p>I totally understand why the OP would use only FBV, however when writing REST APIs you will want CBV to reuse base classes such as ListView.
  • tinodb1 hour ago
    &gt; 3. Actions<p>It is somewhat explained as a convention or something built-in, but I can&#x27;t find much about it elsewhere. Is it the author&#x27;s own convention or am I missing something?
    • jbarham51 minutes ago
      Yeah, I wondered about that too as normally Django &quot;actions&quot; mean admin actions (<a href="https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;dev&#x2F;ref&#x2F;contrib&#x2F;admin&#x2F;actions&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;dev&#x2F;ref&#x2F;contrib&#x2F;admin&#x2F;acti...</a>). But in this case it seems the blog post is referring to this pattern: <a href="https:&#x2F;&#x2F;www.jmduke.com&#x2F;posts&#x2F;in-praise-of-actions.html" rel="nofollow">https:&#x2F;&#x2F;www.jmduke.com&#x2F;posts&#x2F;in-praise-of-actions.html</a> (same author)
  • whateverboat54 minutes ago
    I really like django, but since being involved in it from early days, whenever someone now praises Django, I am reminded of this talk: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=i6Fr65PFqfk" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=i6Fr65PFqfk</a><p>DjangoCon 2008 Keynote: Cal Henderson
    • vb-844852 minutes ago
      what&#x27;s wrong nowadays w&#x2F; django?
  • Klonoar1 hour ago
    I feel sufficiently old after having read <i>South</i> in this article. Good god what a throwback.<p>Django is hands down one of my favorite frameworks ever created, and the only one I still reach for in some contexts. For a lot of projects I use it to drive database migrations, and stand up an easy admin portal for others to use - then anything else is driven by an API layer written in (e.g) Rust.<p>I haven&#x27;t had to care about Django&#x27;s performance in years but still get to reap some of the benefits.
    • zelphirkalt4 minutes ago
      How do your API calls get into the Django app(s)? Do you define the API as well on the Django side (duplicating the API)? Or is there some tool that translates the Rust API calls for Django efficiently?
  • 0x4d4c1 hour ago
    I remember, when I used it for the very first time in commercial project. Client briefed me in the afternoon, the next day, before the noon, she got ugly app, but with fully working admin backend. She was sold.<p>But I also remember, that some non-standard requirements were really difficult to implement or get around.<p>Having that in mind, the next project was entirely in Pylons. All was good, until we were asked to add Unicode support.<p>Since them I&#x27;m on Rails.
    • thraxil35 minutes ago
      &gt; Having that in mind, the next project was entirely in Pylons. All was good, until we were asked to add Unicode support.<p>How long ago was this? I feel like unicode has kind of been a solved problem in Python since python3 came out. In the python2 days it was, indeed, miserable.
  • sinpif51 minutes ago
    Migration churn adds up over the years but overall it&#x27;s nice and site-specific code is usually so small it fits very nice in LLM context.. easy to work with.
  • zelphirkalt29 minutes ago
    What I like about Django are the following things:<p>(1) It seems whenever I need to adjust how something works, there is some field or method, that I can override, or meta class attribute to set. None of it seems too inflexible. Overriding or changing how things work somehow always feels like someone already thought of this special case I have, and has made it mostly easy to do. Often when I have such a customization case, I have this feeling: &quot;AH, that&#x27;s how it is supposed to be done in Django.&quot; instead of having a feeling of having to fight the framework.<p>(2) Just being able to use a normal template engine (I always use Jinja2 with Django), instead of having some wannabe HTML lookalike thing. I don&#x27;t want to have to encode control flow inside HTML attributes. Why then make it look like HTML in the first place, if some JS framework then picks it apart? It is unnecessarily cumbersome to do that, and Django doesn&#x27;t engage in that.<p>(3) The ORM is good, and flexible. Some traps for many queries though. But also escape hatches, which let one write ORM calls, that will translate to efficient SQL in most cases.<p>(4) Django makes it so easy (comparatively) to write a phenomenal searching and ranking function for ones database entities. Check for example the code of my blog [1]. One page of code, very adjustable to ones needs.<p>(5) Handling of routes is easy. `reverse` is very useful to not have to hardcode routes.<p>(6) Even when using third-party things like django-allauth it is easy to override templates, without having to modify the dependency itself. With foresight there exists a way to put ones own templates in a place that is discovered before the other package&#x27;s templates.<p>(7) Adjustable django admin. I often have some &quot;Tags&quot; in my models, which are many-to-many. For example Posts-TagAssignment-Tag, where TagAssignment is a &quot;throught table&quot;. In Django admin one can have a nice little modification [2] to make a very usable widget appear for assigning tags.<p>In short: It very much gets out of ones way.<p>[1]: <a href="https:&#x2F;&#x2F;codeberg.org&#x2F;ZelphirKaltstahl&#x2F;django-website&#x2F;src&#x2F;commit&#x2F;71ae8fc27c935962087ae67918c382b94c905999&#x2F;website&#x2F;app&#x2F;utils&#x2F;search.py" rel="nofollow">https:&#x2F;&#x2F;codeberg.org&#x2F;ZelphirKaltstahl&#x2F;django-website&#x2F;src&#x2F;com...</a><p>[2]: <a href="https:&#x2F;&#x2F;codeberg.org&#x2F;ZelphirKaltstahl&#x2F;django-website&#x2F;src&#x2F;commit&#x2F;71ae8fc27c935962087ae67918c382b94c905999&#x2F;website&#x2F;app&#x2F;admin.py#L31-L39" rel="nofollow">https:&#x2F;&#x2F;codeberg.org&#x2F;ZelphirKaltstahl&#x2F;django-website&#x2F;src&#x2F;com...</a>
  • tonyedgecombe1 hour ago
    I haven’t used Django for a long time but when I did I found it one of the best documented projects out there.
  • Maxion2 hours ago
    Django is boring, which is why it works well. Use the ORM together with DRF serializers and an OpenApi generator and you can create TS types and TS client directly from your API.<p>Works incredibly well almost straight out of the box for even quite large applications. Once you start to grow out of it, it&#x27;s easy to bypass the ORM and write raw sql queries.<p>You also won&#x27;t be re-writing your backend every few years, the cost of which techbros often ignore.
    • aitchnyu1 hour ago
      If the DRF stack seamless like Ninja now?
    • angusj11 hour ago
      [flagged]
  • cryo321 hour ago
    My favourite part of Django is it&#x27;s not Rails :)
    • 0x4d4c1 hour ago
      Why is that? What&#x27;s wrong with Rails?
      • panzerboy1 hour ago
        It&#x27;s made by DHH.
        • Nextgrid26 minutes ago
          Some people are just <i>looking</i> to be offended. You don’t have to read or agree with his drivel to use his software.<p>(Do you also check out the blogs&#x2F;social media of every dev involved in every library you use?)
        • BoumTAC1 hour ago
          The DHH hate is absolutely crazy on HN.<p>I don&#x27;t understand how people can be so out of touch.
          • _old_dude_19 minutes ago
            It&#x27;s not hate, it&#x27;s not wanted to be associated with:<p>see <a href="https:&#x2F;&#x2F;victorwynne.com&#x2F;dhh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;victorwynne.com&#x2F;dhh&#x2F;</a>
          • owebmaster1 hour ago
            Do you think DHH is out of touch too?
          • panzerboy54 minutes ago
            I don&#x27;t hate the guy (I don&#x27;t know him personally so I cannot hate him), I just disagree with his opinions and I personally don&#x27;t want to use anything that he makes or endorses. Easy as that.<p>I know that there are other people contributing to Rails, and that&#x27;s their choice. Other people stopped contributing once DHH showed his true nature.
        • 0x4d4c1 hour ago
          And great bunch of other, awesome people.<p>I can take an argument of not buying a Tesla in order to avoid supporting Elons financial empire, but not using Rails because DHH made it is really hard to comprehend.
          • owebmaster1 hour ago
            Why is it hard? Elon got all the power he wanted. Not giving DHH the same free passes Elon got is a very reasonable take.
  • stavros2 hours ago
    I agree, Django is just fantastic. Nothing is perfect, but Django is just really well-designed, with components that fit together naturally into a balanced whole.
    • weatherlite2 hours ago
      Just wanted to say I saw your last stand up , you&#x27;re hilarious!
      • ustad16 minutes ago
        Stavros Halkias! Very funny guy. And also a maker and HN god! Never would have thought.
      • DoctorDabadedoo39 minutes ago
        What a random way to find out a stand up comedian I see now and then share a craft!
      • stavros2 hours ago
        Thanks, my love of comedy is only surpassed by my love of Django.
        • weatherlite2 hours ago
          Naa you lie you love twinkies more than Django
  • alexbelyanin1 hour ago
    [flagged]
  • songhonglei19851 hour ago
    [flagged]