33 ms·
Django has allowed me to enjoy some side entrepreneurship. I have released three products as a solo part time dev that I would never have been able to do in a r
by rlawson 5y ago
Django has allowed me to enjoy some side entrepreneurship. I have released three products as a solo part time dev that I would never have been able to do in a reasonable time using Java/Spring (my strongest stack). My first project went nowhere, but the second generated 1k+ a month and sold for 50k, and the third one is following a similar trajectory.
My advice - keep it simple
- function based views
- centralize access to the ORM (avoid fat models, use a service layer)
- responsive bootstrap template with crispy forms
- minimal js
- 12 factor type setup - django-environ or similar
- be aware of n+1 select problem (I use django debug toolbar but looking into django-zen-queries)
- plop it on heroku, AWS lightsail, Digital Ocean or if containerizing use AWS Fargate
- avoid celery unless you are at a scale you need it - use django-cron, django-db-queue or similar
- use a managed database and managed email service
I have had zero scalability problems. People say Django is slow but it handled 10k active users on a small EC2 instance without any issues (static stuff served via cloudfront)
- kaba0 5y agoI’m sorry but I don’t buy that. Spring Boot is very highly productive — I really don’t believe any other stack would fare better by a significant margin.
- karolsputo 5y agoI recommend this post when thinking about fat models/service layers https://www.b-list.org/weblog/2020/mar/16/no-service/ https://www.b-list.org/weblog/2020/mar/16/no-service/
- bencollier49 5y agoMay I ask what the projects were?
- rlawson 5y agoCar reservation system for auto dealers (never got traction) Covid screening application (sold) Inventory management (initial clients in alcohol beverage bottling/distribution)
- raihansaputra 5y agoDo you have any recommended readings/resources to help with data modelling? Especially regarding reservation/scheduling and inventory management?
- rlawson 5y agoThe reservation app was super simple so no real guidance there I'd recommend really getting familiar with the Django ORM so that you understand how it generates the schema and how to tweak it to get what you want. As far as inventory management - I looked at several opensource projects and tried to understand their schema and use cases. Not just Django ones but other languages like PHP - PartKeepr for example. Inventory management is surprisingly complicated to do in a generic way.
- raihansaputra 5y agoThanks for the pointers! Yeah generalizing inventory management is very confusing. I tried looking into Oodo but can't get my head around the data modeling. It feels like trying to implement double-entry accounting, but the money can rot/be broken/gone for other reasons.
- tcrow 5y agoCongrats on making a return on your investment! may I ask how you went about locating a buyer for the screener app?
- nisegami 5y ago>avoid fat models, use a service layer I had not heard the term "fat models" before so I googled it. It did not go in the direction I expected.
- matsemann 5y agoAnother classic is "c string".
- skinkestek 5y agoAnother classic was (I haven't tested recently) that while Firefox would search if you entered a word that was not an address into the adress bar, while certain older browsers, at least Safari just added .com :-/
- slig 5y agoI remember that, specifically Python dot com. (was NSFW back in the day, enter at your own risk).
- BeFlatXIII 5y agoI just got results for repairing cellos and violas. "G string" got the expected spicy content in addition to violin repair ads. Surprisingly, no string bass repairs (in spite of the bass also having a g-string)
- _peeley 5y agoEvery time I need to write up a research paper in TeX and insert a graph, I make the same mistake of searching "latex images" and getting some pretty exotic results
- bobbyi 5y agoWhen I first started using the python tool/ library named fabric, I knew that putting just "fabric" into google would not get me what I wanted, so I instead searched for "python fabric". The top results were trying to sell me handbags and boots. (These days, the library does rank first for "python fabric").
- matsemann 5y agoIt's great for getting things up and running. And can last a long time. But now that we're 40 devs or so working in the same 400k LOC codebase, I'd prefer Java/Spring (or really, Kotlin). So hard to maintain django in the long run, need to be really strict, or one ends up with each app spaghettied with other apps. Doing queries where you filter deep on other apps' models, and since it's only done as kwargs with no typing nothing stops that from exploding runtime when someone changes a model somewhere. Too easy to send fat objects around everywhere, accidentally doing heavy db stuff when using a property. Also makes it harder to test, because everything leaks.
- rlawson 5y agoI can see that happening on a large codebase with a lot of devs. Being a Java guy, I organized all the business logic and db access into a service layer, added type info and wrote a decent amount of unit tests. I can't deny however that I am 2x faster cranking out crud screens in Django than in Java and the combination of ORM, migrations, templates, and access to the 3rd party app ecosystem is a real productivity booster.
- matsemann 5y agoYeah, for a simple app, it's so quick to get some auth, rest endpoints, a fine admin panel etc. Problem is when you start abusing stuff. Just hook into some signal to do something, nbd, but suddenly it's an interconnected mess. Just add some custom stuff to the admin page, and suddenly what should have been a custom made page is now a weird mess it's hard to extend. Need to do stuff async in the background, and what could have been adding a task on some queue and having a thread poll it is instead this behemoth of complexity. A large django app can also be good, I think, but then one at some part have to realize when to stop tweaking built in django features and write custom stuff, to avoid adding hacks on top of hacks. And also early stop doing the easy communication between apps, instead take the annoying detour around services and hard boundaries.
- stavros 5y agoYes, but nothing is stopping you from typing and organizing everything, right? I agree that it's not the default, which isn't ideal, but you can do it fairly easily (and keep it enforced).
- Alex3917 5y ago> function based views Class-based views, in their most basic form, are a lot easier to read. E.g. look at the DRF CBVs I have here: https://github.com/Alex3917/django_for_startups/blob/main/django_for_startups/app/views/account_management_views.py https://github.com/Alex3917/django_for_startups/blob/main/dj... If you can avoid Generic CBVs (things like ListView) and inheritance, then the only difference between FBVs and CBVs is that CBVs make it easier to see what's a GET / PUT / POST / DELETE by adding some syntax highlighting that makes it easier to visually differentiate which code goes to which method. You don't need to know anything about classes in Python in order to use them. It's not at all difficult to switch from FBVs to CBVs later, and most people (myself included) use FBVs when getting started. But I'd also say that if you're willing to push through the initial discomfort and spend the extra half hour or whatever on YouTube in order to understand them, then you do get a little bit of a nicer overall development experience.
- bitexploder 5y agoClass views are fine. Even just a TemplateView saves some effort, but it comes with learning some Django magic about the life cycle of the view to load data in and out and what methods to implement. I still recommend it. You don’t have to fully embrace it and it lets you avoid repeating a lot of code.
- Nextgrid 5y agoMy recommendation for learning class-based views is to use a good editor or IDE that allows you to drill down into the library code easily. In PyCharm/IntelliJ I can just command-click on the TemplateView symbol and see its implementation, and do so recursively until I've unraveled the entire thing.
- ChipotleRice 5y agoAgreed. Django's documentation is pretty light on the order in which certain functions will be executed and diving into the code is the only way I've been able to understand what happens when handling forms and views.
- anoojb 5y agoI’ve found managed databases to be quite expensive at places like Azure and AWS. Especially compared to just installing pgsql on raw compute. What managed databases do you recommend that adequately meet price/performance needs of indie developers?
- robjan 5y agoI've used ElephantSQL before. As long as you write efficient queries (especially avoiding N+1) and choose the right data centre it's usually reasonable for a small project.
- int0x2e 5y agoPaaS and managed services let you trade money for time and effort - patch management, backups, security, config optimization, simplified scale-out/availability/etc. all take time, effort and skill to get right and keep running well over time. With RDS/Aurora/AzureSql/CosmosDb (and the like) you get to focus on your app/service/product instead. It all ends up being a question of how much your time (and being able to focus) are worth to you. If this is an actual business and not a hobby, and assuming market rates for your time - I believe the managed service offering ends up the cheaper option overall.
- rlawson 5y agoRDS - Aurora/Postgres flavor - small instance. Entire AWS bill was < $100/month to support 10k users - app load balancer - WAF rules - EC2 instance - RDS - Cloudfront I use fargate when deploying now to get out of box management
- mlboss 5y agoDigital ocean also offers managed db(postgres/mysql) starting at $15/month
- zdiscov 5y agoDid you ever have to use Vue or other reactive frameworks with Django? Do you use DRF at all or just mostly Django?
- lifeisstillgood 5y agoplease point us at your side projects - and congratulations that's a fantastic outcome
- WD-42 5y agoI think CBVs get a lot of unnecessary hate. DetailView, ListView, DeleteView, etc save so much time and repetition for basic CRUD pages. Once things get complicated and you start having to override too many methods, it's often best to write the post(), get(), put(), etc methods explicitly. At that point you are still writing CBVs but it's much more organized.
- leetrout 5y agoThey are alive and well when using Django Rest Framework
- akulbe 5y agoThe one that you sold… what made you decide to sell, if it was a money maker for you?
- rlawson 5y agoBasically I didn't want to support it. It was a lot of schools and small businesses and so plenty of "I can't login" and when you work with them it's their wifi or something. The company I sold it too had customer support :)
- lambdadmitry 5y agoIdeally try to avoid using Celery at all. It's the most consistently buggy, poorly documented, worst quality major Python project I have used so far. Here is a fresh example: they deprecated CELERY_ prefixes in Django settings for some reason, which makes zero sense [1]. But because it's Celery, they only warn on a few properties but not others, and the tool they ship inexplicably renamed completely unrelated settings for me [2]. And yes, apparently the new way doesn't work either [3]. It's very characteristic of what I've seen from Celery over the last few years of working with it. If you are doing anything greenfield, it's best to avoid it altogether. [1] https://stackoverflow.com/questions/65554242/celery-imports-celery-result-backend-deprecated-how-to-use-alternative https://stackoverflow.com/questions/65554242/celery-imports-... [2] https://twitter.com/lambdadmitry/status/1468337594358546435?s=21 https://twitter.com/lambdadmitry/status/1468337594358546435?... [3] https://github.com/celery/celery/issues/7140 https://github.com/celery/celery/issues/7140
- hda111 5y ago+1 for trying to avoid celery. Too much complexity for simple asynchronous tasks. You should use it however if you are instagram (I think they use a customized Django and Celery).