9 ms·
> exceptionally complicated and hard-to-modify As an exceptionally mediocre programmer who routinely creates extensive admin customisations I dispute this. Se
by andybak 9y ago
> exceptionally complicated and hard-to-modify
As an exceptionally mediocre programmer who routinely creates extensive admin customisations I dispute this.
Seriously. Where does this meme come from? The admin is remarkably easy to customize for the most part. It's biggest flaws are incomplete documentation and a few monolithic methods/templates mostly around changelists.
- andkon 9y agoAt least part of the problem is that it looks so, so weird, and it's really tightly bound to models. This is like the most customized admin i've made and it's still pretty simple, but it sure doesn't feel that easy to reason about when you look at it (it's an admin page that lets you link a specific admin-page input to a model, then display it in a list that you can add to): from django.contrib import admin from django.forms import Textarea from .models import * # Register your models here. class BotTextInline(admin.StackedInline): model = BotReplyContent extra = 1 fieldsets = [ (None, {'fields': ('message_type', 'text', ('template_text', 'example_text',), 'order',)}), ('Actions and inputs', {'classes': ('collapse,'), 'fields': ('action_type', 'input_type',)}) ] # readonly_fields = ['input_type_ptr'] class BotReplyAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ('state', 'intent', 'context', 'description', 'next_state',)}), ] formfield_overrides = { models.CharField: {'widget': Textarea()} } list_display = ('state', 'intent', 'context', 'description',) save_as = True # lets you save the content on screen as a new id inlines = [BotTextInline] admin.site.register(BotReply, BotReplyAdmin) ```
- Daishiman 9y agoThis is a trivial amount of customization. Yes, you have to know what the class fields do. But you just saved yourself days of having to make your own CRUD view from scratch.
- andkon 9y agoTotally trivial. And yet, I still can barely parse what's going on in there.
- Daishiman 9y agoBut proportional to the docs and total customizability and sheer mass of code and functionality that happens. You're getting free authentication for an admin + free UI + a fully customizable list view + customizable create/update view + delete with a useful confirmation dialog + trivial field search + trivial filters of all sorts include date drill-downs. It's a huge amount of things to do by hand.
- theptip 9y agoMy experience report is based on operating a production API with about 30 DB models, not incredibly complex, but with somewhat non-standard requirements like multi-tenancy. This opinion is shared by the developers on my team as well, if that's worth anything in addition. I've found the easy stuff to be very easy to do in the Django admin, and every time I've tried to do something off the beaten track, it's taken me days instead of the hours or minutes it feels like it should do. Any of these would be good examples of things that feel like they should be easy, but aren't: * Adding a link to a custom page onto the frontpage of the admin, ideally under a custom "App" header. * Creating a read-only view onto related objects (impossible in some situations, depending on the direction of the FKey relationship, annoying in others). * Presenting a form for creating nested one-to-one objects along with a parent. I'm sure that if you routinely make modifications to the Django Admin it gets easier; the second time on any of these items is 10-100 times quicker for me. I'd blame the poor code discoverability of the template-based system, poor documentation, and lack of a broad corpus of examples for making this harder than it could be.
- elnygren 9y agoIf you are spending "days" in some Django Admin modifications, you are definitely doing it wrong. At that point you should have rolled out your own admin just like any other feature. Clearly the builtin admin is working against you rather than with you if it takes that long to do what you need to get done. The Django admin is meant for development. Ofc, it can be used by non-devs and I've seen a multimillion dollar business that mainly uses the builtin admin to manage their main product. However, there's always that point when customising something that is fundamentally different than what your needs are doesn't make sense.
- 3131s 9y agoI recently overrode the admin widget for ArrayField to make it possible to add and delete entries individually rather than entering the whole array as a big comma-separated block. I got it working but it felt pretty hackish. Maybe there was a better way but I had trouble finding good resources on what I wanted to do.
- seanwilson 9y ago> Seriously. Where does this meme come from? The admin is remarkably easy to customize for the most part. I haven't found this myself to be honest. Usually you have to trawl through several stackoverflow posts and evaluate several different ways to do things you would expect to be simple. I don't have many examples in mind right now except showing image thumbnails, dealing with base64 image uploads and automatically resizing image uploads were way more cumbersome to implement than I would have expected. Most solutions we arrived at felt hacky for tasks you would think would be built in by now but I don't have a better framework in mind for CRUD work. The default admin interface is really good though as well as the database migration tooling.