Developers January 26, 2021

Is Django a waste of time?

a_swings

Hi all, this is my first post. Quick intro: I am working as a full time data scientist using mainly Python, R, Airflow, Docker and such.

I am hugely inspired by what you guys are building and want to start with a small side hustle, a basic blog and maybe one web-app. Since I am already doing well in Python, I thought Django would be a good idea to get started.

BUT, I always read about Ruby on Rails, Laravel, etc. and that time is more well-invested learning these frameworks. I am quite motivated, but my time is limited because of a full time job, so I would love some opinions on what is the best way forward.

Thanks a lot!

  1. 10

    If you're strapped for time I'd say it's definitely worth using a technology that you're already familiar with. One flipside to this, particularly if you work with that technology during your day job is that your side project can end up feeling a bit like work.

    I work with Rails and Vue in my day job and initially started building my own application in these. It felt like work to use exactly the same stack at all times so I decided on a nice compromise. I kept Rails but ditched vue and built a full stack app with a different front end. In this case I used Stimulus JS and it's been a great choice. As I'm still using Rails as I can get things built pretty quickly but as I'm learning a new (but fairly simple) JavaScript framework it's still enjoyable as I am solving different problems (server rendered HTML vs browser rendered) without being totally blocked by starting from scratch.

    I hope that helps, good luck!

    1. 2

      That's what I fear as well. Maybe going into a completely different language feels more recreative, or interesting at least.

      1. 1

        It's certainly more interesting, however I suppose it depends on what you really want to achieve? If you're looking to get something out there ASAP then a brand new language probably isn't the way to go, if you want to learn a tonne in the process then it probably is. Looking forward to seeing what you come up with :)

        1. 1

          Thanks! I think no matter which way I go, this is the most important part. Just get into a habit of producing :P

    2. 1

      I will say that I use Django for my day job and I enjoy using a lot for side projects, I've never felt that my side projects were too close to work. That being said I think the core of what you mentioned is to always be learning and trying new things. I've experimented with different front end frameworks along side django, integrating graphql and using the Django Rest Framework etc.

      I think keeping it fresh can be achieved in a number of ways, whether it's entirely new language, new frameworks, packages, new design pattern etc.

  2. 8

    Django is great. It has a lot in common with Laravel and Ruby on Rails, just less fanboy behaviour around it for some reason. Fundamentally they are all frameworks for creating server side rendered web applications and they make very similar architectural choices.

    Whatever you choose, you will be defining models that map to database tables, views that handle requests, and templates that define how data from your views are translated into HTML.

    The terminology will differ (Django calls the classes and functions and handle requests "views", but it's more common to call them "controllers"), but the basic ideas are the same.

    If you want to create an SPA, you can use Django Rest Framework to create an API and consume it from your frontend written in React or whatever.

    The Django ecosystem is huge, and the framework is easy to get started with, but you will be learning new things about it for years if you decide to go for it.

    1. 0

      Huge ecosystem does not sound wrong :) that's what I like about Python anyway. Any recommendations on the frontend? Seems like you don't think it matter that much, correct?

      1. 2

        Personally I've used Vue, React, Angular, and plain JS + HTML. They're all fine.

        If you are already comfortable with one of those, go with that one :) If not, go with the minimum viable choice - the one that requires the least effort on your side to start.

      2. 1

        I have used Angular and React. I am currently using React.

        A standard server side rendered application is always going to be easier and less complex than using a frontend framework. If you can build the features you want that way, that's what I would recommend.

  3. 5

    Hell no!

    Django is awesome and don't let anyone tell you otherwise. If it's good enough for Instagram and Robin Hood, it's certainly good enough for you. There are loads of IH-ers successfully using Django, including @HermanMartinus @mattfreire and @allison

    Rails, Laravel, and JS get more attention among the IH community but that doesn't make them better. At the end of the day all of these frameworks are great, and they can all get the job done. It's almost always best to go with what you know rather than try and learn an entire new tool.

    Shameless plug: if you're strapped for time you can always check out my product SaaS Pegasus which is designed to help people like you launch fast. I've helped loads of Indie Hackers get their first projects off the ground using Django, and many of them have turned Pegasus projects into full-time businesses.

    Or if you're more a DIY type, I've also written extensive guides to building a SaaS in Django. Don't hesitate to reach out if you have any questions!

    1. 2

      What did you use for multi-tenancy?

      1. 1

        It's currently just built into the application layer - e.g. every "tenanted" model has a ForeignKey to the tenant model, and then it ships with some utilities to restrict views, models etc. by tenant.

        I find this is the best architecture for small-to-medium size projects and makes the right tradeoffs between security and complexity.

        Options I also considered:

        • django-organizations - looked a bit heavyweight for a v1, but I'm still considering it for a future release.
        • django-tenant-schemas - relies on Postgres schemas. Too complex/heavyweight for my taste, though a good project if you are sure you want to use that architecture.
        1. 2

          Yeah, I did something similar by just using a foreign key to the tenant model.

          I also needed to do subdomains so I made a unique slugfield on the tenant model and wrote a request middleware to extract the subdomain, look up the tenant and pass it to the tenant views, or return a 404 if no tenant with the corresponding slug existed.

          It's a DRF application so I extended ModelViewSet to automatically restrict the queryset to objects that belong to the tenant.

          A few custom permissions too.

          I evaluated those packages you mentioned and they seemed too heavyweight for me too. I prefer to keep things in the same table with a fk.

          I looked for something like your boilerplate when I started this project, but I didn't come across yours. I'm past that point now, but I will consider it in the future.

          1. 1

            That all makes sense. I went back and forth on subdomains, but decided to go with url routes instead. Still requires a unique slugfield, middleware, and 404 handling for the URL parsing though. Guessing it's 95% the same as what you had to do with a little bit less complexity on the DNS / Nginx side.

            Sorry you didn't find Pegasus in time, but would love to help out in the future. Don't hesitate to reach out if you have any questions!

            1. 1

              You could do it your way and use rewrites at the web server in front of it to map subdomains to an element of the path.

              mytenant.app.com/resource/ -> app.com/mytenant/resource/

              Right now I need to edit my hosts file when developing locally to make django pick up the subdomain.

              1. 1

                Interesting and good to know! Will explore that if I ever have a need for subdomains.

        2. 1

          Interesting idea.

          I see SaaS pegasus cokes with Celery built in.

          How does your homegrown tenant architecture plays eith Celery?

          Aksing because I had to add Celery today to a project and only after an hour of pulling out my hair realized I need to install some extra package because app is multi-tenant.

          1. 1

            Since Pegasus bakes multi-tenancy into the app layer there's not really any issues with using Celery out-of-the-box. The tasks just work off tenant models where necessary.

            What is your multitenancy stack that required something special?

            1. 1

              We're using django-tenant-schemas.

              We had some issues where tasks would call Model.save() and it tried to save to public schema instead of tenant specific one.

              Installing celery-tenant-schemas fixed the problem.

              1. 1

                I remember I dropped django-tenant-schemas when I first tried to use the public schema (I wanted users on the public schema so that one user could belong to different tenants).

                Now, 1 year later, I'll have to add Celery to my project as well. It's scary how complexity escalates fast and in unexpected ways!

                Btw, the Django community desperately needs some multitenancy tutorials! wink wink

              2. 1

                Ah yeah that makes sense. Think in django-tenant-schemas the tenant is inferred by the request/middleware so you'd need a similar process in celery. Good to know there's a library for that!

    2. 1

      Can confirm, Django is great. I moved my app from Flask to Django and it was the best decision I've made yet. I think the Rails community is a big bigger which is why it's talked about more.

    3. 1

      one noob question regarding this platform: is there no private messaging function here? Seems like only mail and twitter are provided

      1. 1

        Oh, yeah I don't think so. I'm cory at saaspegasus.com if you want to email me.

    4. 0

      Cheers, mate. Great guides, will give them a go before getting started. I must say all the comments here which plug their projects are helpful, but this one fits just perfect

      1. 0

        Haha, thanks! And sorry about the plugging - I try hard to only promote my own stuff where I actually think it will add value so glad it was a good match at least!

  4. 3

    I have only played with Django and not recently, but I can testify to the immense productivity that Rails offers. The framework itself is awesome and made even better with gems that allow implementing features very very quickly. There's a gem for just about everything these days. Also Ruby is a joy to work with IMO. I believe it wouldn't take long for you to pick up the basics with Ruby and Rails and start to be productive.

    Ps. for the blog you could give www.dynablogger.com a try - it's my own blogging platform and there's a free plan so it's easy to try. I would love any feedback you may have :)

    1. 2

      Thanks, will check it out! Honestly, doing something new and fun is maybe not so bad, since I am working with Python anyway every day!

      1. 2

        Then do try Rails, I am sure you'll love the productivity ;)

  5. 2

    I feel I could share some advice, as I use Django for my SaaS (http://panelbear.com/), but also lead an engineering team that handles several billion requests/mo with various languages/frameworks.

    My tip: As a solo founder (or small team), you can get pretty far with any monolithic framework. They help you focus on your product, and avoid reinventing the wheel. Time to market and development speed is key to be able to compete. But "will it scale"? Yes, as many companies have demonstrated: GitHub, Instagram, DoorDash, Robinhood, Pinterest, Spotify, etc... Although the reality is that most projects won't ever reach that scale.

    Pick any of Django, Rails, Laravel. You can't go wrong with either. Sprinkle some React/Vue for the pages that need to be more interactive, and you've got yourself a pretty solid setup for a one-man product.

    These frameworks take care of migrations, middleware, sessions, common security flaws, database connections, caching, etc... And they'll help you focus on building your product, instead learning the framework flavour of the week.

    In short, use what you already know best. Tools are just a means to an end. If you are already comfortable with Python and Django, leverage that - it's a great choice!

    1. 2

      Thanks, asimon. Your tool looks great and clean. "You can't go wrong" sounds good, now I just have to get started

  6. 2

    You are where I was in 2018. I was a data scientist... in a company that lacked a data culture. I earned well, but I wasn't actually doing anything impactful for the company. Since the company had a Treehouse subscription, I started to take as many courses as I could, Django among them.

    In 2019, I started a little Django project. It was a workforce analytics product that I hoped to power with some ML algorithms. I figured it would make sense to keep the stack in a single language.

    This later became my product, pluckd.co.

    If you already know python, then Django is a no brainer: it will allow you to launch faster as well as help with your own data science projects (I found it much better to use than Flask, for instance). Launching faster is what matters.

    Besides, learning a new framework is never a waste of time.

    1. 1

      Thanks a lot. How did your story progress? Are you still working as employee?

      1. 1

        February 12th will be my last day! 🙌

        Pluckd still doesn't pay the mortgage, but I'll be joining a data engineering consultancy that will allow me more time flexibility.

  7. 1

    If you dont have time to learn new tech, just stick to Django. You will get things done much faster and thats all that matters if you are building a side project.

  8. 1

    I use Python all the time for similar things (data analysis, instrumentation, etc.) I went for Django and I never regretted it. Thanks to Django I learned plenty of things (for example on design patterns) that I could later implement in my daily job.

    Since you already know the language, learning the framework inside/out will be very fast, but it is still a vast ecosystem to absorb. And, you'll still need to learn about HTML, CSS, Javascript, etc. which are challenging to say the least.

    I think that what @lewisyoul says is true regarding feeling that your side project is still work, but bear in mind that he is mentioning only using different frameworks, but the same language (rails/javascript). You are already using a different framework (Django) and a new language (Html, etc.)

    Plus, if you are a data scientist, you probably will be tempted to build something end-to-end (for example, a web interface to a model you've trained). Keeping everything within Python will make your life so much easier! I use Flask for several IoT-like projects that include complex optimization routines. Keeping the same language across different concerns makes it much simpler...

  9. 1

    Programming language deaths when the people don't use it.

  10. 1

    I built my company in Django and got started in Django many years ago, pre 1.0, because the team I was running was using Python to do scripting. I started working in Python and really liked it. It felt like a no brainier to stay in the same ecosystem since I was familiar with Python and I enjoyed working in it.

    For me personally, I think working in a language you already know makes the most sense because you'll be productive in it. There are so many other things you have to think about and worry about, so why add a new framework AND a new language? You've been using the data structures and features of the language, which I think will allow you to stay focused on the project instead of trying to learn multiple technologies all at once. For example, if you're looking at the Django docs and they're talking about decorators you won't have to go digging into how these work and what you need them for. Things like this can be big time sucks.

    As you're building your project, you'll have to learn CSS, JavaScript and a whole bunch of other things. For me, having an understanding of my core language always gives me comfort.

    Personally, I also love the Python community. There are a lot of great projects and people (not that this doesn't exist in other languages, of course they do!) in the community and I've really come to like it. Every language and framework comes with it's own standards, culture and community but Python is the one I've grown fond of. I think this is just as important as the technology itself.

  11. 1

    One of the biggest traps that people with the developer mindset fall into is overthinking questions like these. When I used to make games I spent months researching different game engines trying to find the perfect one, and after years I'm finally able to cope with the truth that it doesn't really matter as much as we think.

    IMHO, You know python already and Django is an excellent framework with a large community and proven use in lots of big companies, just start solving your customers problems and making something. If Django isn't right for you try something different on your next project.

  12. 1

    Ive been using Django and Flask to build a large number of apps, small and large.

    I do like Flask for the simplicity, however Django comes with a bunch of batteries included which helps getting something useful out there quite fast. The docs are awesome, but since it’s a rather big framework it can take a bit of time to get comfortable and productive. Once you get over that threshold you are in for a very enjoyable time!

    Regarding performance: sure, other languages are faster but there’s a bunch of things you can do to improve performance while you scale. But hey. Why optimize for performance before that becomes a problem? Just be mindful of the areas where performance can become a bottleneck so that you know where to fix things when it comes to that.

  13. 1

    I normally do recommend Rails to people starting out, but given that you stated you want to make a blog and maybe an app, I'd go with WordPress.

    Especially as a technical person who isn't quite a dev, it can get you where you want an order of a magnitude faster than Django.

    You know what variables, functions, etc are and you'd mostly be downloading and configuring plugins rather than deep coding. You'll be able to stitch things together as needed without learning any appreciable amount of PHP. And given that WP powers over 30% of all the sites on the web, it won't be hard for you to find help when you need it!

    1. 2

      Thanks for the answer. I might have misstated that. Blogging isn't my main focus, its development. The app is the focus here

  14. 0

    I'm a long term Rails developer here. I think it's incredible and it's brought me much of my life's successes. Also, working in Ruby is a joy. You'd have to pry it from my dead hands.

    There's no question: if you're on a timeline, you should definitely use Django.

    Django is a perfectly great Pythonic alternative to Rails, even if it's not something I'd want for myself. Perhaps someday you'll be able to try working in Rails, and maybe you'll love it! But I wouldn't stress out about it. :)

  15. 0

    Yeah you should go for it! Django is a great framework to learn how the MVC pattern works. Once you understand the concepts, it will be fairly easy to jump to another framework if needed.

  16. 0

    Hi there!

    Since your goal is to build apps, stick to what is familiar and use Python to start. Django and Flask are two popular frameworks for Python. Again, as a start you will be fine picking any one of them. Python+Django/Flask will allow you build any backend that you may need for applications.

    In the larger scheme of things, once you have mastered a language, learning others become easier. What's more important though is to focus on learning fundamentals of application architecture, clean design etc.

    I have a couple of blog posts that might be helpful:

    End-to-End Project: A Beginner’s Guide to Building Your First Web App

    How to Learn Programming: A Roadmap for Becoming a Software Engineer

    Good luck!

    1. 1

      Thanks for the ressources!

  17. 0

    If you want to focus on the business side of your project then keep with what you know - the tech stack will very likely not be a make or break decision.

  18. -3

    This comment has been voted down. Click to show.

  19. 1

    This comment was deleted a month ago.

  20. 1

    This comment was deleted a month ago.

Recommended Posts