News for hackers. Stuff that matters.
Re:Show HN: Django Admin Site Customization Tutorial by leetrout on Wednesday July 26, 2023 @08:38AM (#36876645)
Strong opinion: DO NOT break up your project into apps.

Make 1 app called core or common of whatever and replace models.py with models/<namespace_or_domain>.py and import those into models/__init__.py

Everyone jumps into apps with foreign keys across app boundaries and it makes a mess of things from the start that doesnt buy you anything.

1 app. 1 set of migrations. Turn models, views, etc into a package instead of the single file module.

Its the one thing I wish the docs would prescribe and demonstrate for new project advice. .

Re:Show HN: Django Admin Site Customization Tutorial by pdmccormick on Wednesday July 26, 2023 @08:51AM (#36876812)
After many years, I’ve come to the same conclusions and can heartily recommend these suggestions!

Another similar suggestion I’d add is make a settings module with a base collection of configuration (i.e. myproject/settings/common.py) that other deployment-specific dev.py & prod.py import from.

Basically, don’t forget that Django projects are always Python modules too, so go ahead and use those language features too.

Re:Show HN: Django Admin Site Customization Tutorial by zakki on Wednesday July 26, 2023 @08:51AM (#36876818)
Do you have a tutorial for more detailed example of what you wrote?
Re:Show HN: Django Admin Site Customization Tutorial by matthiaswh on Wednesday July 26, 2023 @09:39AM (#36877508)
This tutorial addresses the practice: https://doordash.engineering/2017/05/15/tips-for-building-hi...

There's also a long, uh, spirited discussion about it here with some decent arguments going both directions: https://forum.djangoproject.com/t/why-do-we-need-apps/827/19

Re:Show HN: Django Admin Site Customization Tutorial by synergy20 on Wednesday July 26, 2023 @09:23AM (#36877258)
if not, please write one when you have time, short one is better than none :)
Re:Show HN: Django Admin Site Customization Tutorial by appliku on Wednesday July 26, 2023 @10:14AM (#36878080)
After many years of experiments i came to the same exact conclusion.

In 15 years I haven't seen a single case when splitting a project into multiple apps brought anything but pain.

Also, splitting files like models into packages is also a great approach. 6 months ago I found myself with models.py, API.py (my alternative for API views vs regular views) and serializes.py each over 3k lines of code. Spent 3 days splitting them into small files by topic. Way easier to work.

I also wish docs suggested that it is an option and better to split them earlier. Because it is so easy to just "add one more model to the end of the file, what can go wrong?"

You understand what goes wrong after 2-3k LoC

Re:Show HN: Django Admin Site Customization Tutorial by stavros on Wednesday July 26, 2023 @10:28AM (#36878321)
Agreed. Only make another app if it's almost entirely decoupled from the main app, e.g. a blog app or similar.
Re:Show HN: Django Admin Site Customization Tutorial by jstarfish on Wednesday July 26, 2023 @01:32PM (#36881531)
> Make 1 app called core or common

Do not call it core. There's an existing app or module or something with that name and this will introduce hard-to-diagnose bugs. Common is preferable.

Re:Show HN: Django Admin Site Customization Tutorial by jareklupinski on Wednesday July 26, 2023 @05:08PM (#36885059)
i've been getting away with calling the folder with models/views 'app' and the folder with asgi/wsgi/settings 'config' (top-folder name is the project name)

so far nothing bit me other than an awkward 'app' in my installed_apps, fingers crossed

Re:Show HN: Django Admin Site Customization Tutorial by leetrout on Friday July 28, 2023 @07:03PM (#36914559)
Thats a strawman. Many libs use common as well.