4 ms·
This is what gives a Django developer super powders. There are comments here suggesting that you should wait for the time needed to develop your admin tools to
by samwillis 4y ago
This is what gives a Django developer super powders. There are comments here suggesting that you should wait for the time needed to develop your admin tools to be less than the time it takes to perform the action manually. With Django that's literally 5 min! To add a "basic" first pass of an admin to a model is literally a 5 min job. And when I say "basic" it's not really that basic, you can achieve a lot very quickly with the admin framework.
If you are using Django and not building out admin tools as you go you are doing it wrong.
The other thing touched on in this post is audit trails. I now tend to create a "{model}Log" model for the "key" models in an application, fairly basic with a JSON column. So for a shop, the products, basket, orders, etc. Then aggressively log to it all and any actions that happen, both internal stuff and external API calls (requests and responses). I make this log visible in the admin on the page for each of the key models. It makes digging into what is happening so much easer for everyone.
If you eventually find you are logging too much, just turn it down.
I do however very much see there bing two layers to admin tools, the first being the visibility, CRUD, audit tools. The second layer of tools for specific actions (e.g. compiling with GDPR removal requests) can make sense to wait until you have experienced doing it manually a few times to understand the problem better. But even then, it's better to build as soon as you have that knowledge.
- t-writescode 4y agoAs much as I hate Ruby, Rails has a similar thing, and ActiveAdmin is just plain wonderful. Django AdminTools and Rails ones are must haves for me anymore.
- irjustin 4y agoDjango AdminTools has been' updated since 2021. Is there an alternative that you use? +1 on ActiveAdmin. We recently switched from Rails to Django and AA is something I'm severely missing. The DSL is terrribbblee but once you learn it, omg so fast to do anything.
- t-writescode 4y agoI haven't used Django in around 3 years, but I recall seeing very verbose tooling when I was learning it edit: the default provided admin tools. I didn't know if it was called AdminTools or whatever.
- cpursley 4y agoJust stick appsmith, budibase or any of the other low code admin interfaces in front of your database.
- irjustin 4y agoI really looked into appsmith because of how cool the look, but one key problem I have is we're fintech so auditing objects is critical. Appsmith has its own logging system and our Django app will also have one through django-simple-history. Reconciling the two will be super annoying. Rollbacks for user edited objects will be effectively impossible w/o a separate system.
- cpursley 4y agoAuditing who's accessed/used the admin?
- irjustin 4y agoAuditing changes to objects.
- cpursley 4y agoYou could handle that with an audit log (there's some standard ways to do this in SQL databases). And then expose that in the admin interface via the low code tools (which have SQL-to-UI builders). Here's an example of an audit log I put together for an in app activity feed (in Postgres): https://gist.github.com/cpursley/a2ae79423bee9274e3639839967e17ff https://gist.github.com/cpursley/a2ae79423bee9274e3639839967...
- irjustin 4y agoThe thing that's killing me w/ Django's Admin system is there's no concept of pure Viewing data. A big part of administering your end users is having staff be able to "see" what is going on w/ the user (i.e. a dashboard for user and all user related objects, like what company they belong to, money, products, purchases etc). But it's weird that the viewing page is also the editing page.
- reubenmorais 4y agoYou can give staff users limited privileges, such as view only.
- irjustin 4y agoThe goal isn't to give staff view only. It's to separate the viewing and editing.
- simonw 4y agoOnce you figure out how to do it the Django admin actually has really neat support for read-only views of data. The trick is to implement these methods on your ModelAdmin subclass: https://docs.djangoproject.com/en/4.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.has_add_permission https://docs.djangoproject.com/en/4.1/ref/contrib/admin/#dja... You can make has_add_permission(), has_change_permission() and has_delete_permission() all return False, while has_view_permission() returns True. The readonly_fields and related get_readonly_fields() method are very useful too. I wrote up another related trick in this TIL: https://til.simonwillison.net/django/extra-read-only-admin-information https://til.simonwillison.net/django/extra-read-only-admin-i...
- irjustin 4y agoThanks, but the goal isn't to prevent editing. It's to prevent accidental editing. Staff need to be able to change things but 95% of the time they're simply viewing data to help answer questions, etc.
- 4y ago
- mejutoco 4y agoDjango admin is great too in the rare case when you inherit a database only from an old project. You can point Django to the database and it can create an admin model for you, and from that you can start using django normally with migrations, admin panel, etc.