Jacob Kaplan-Moss wrote:
> 
> 
> On Sep 19, 2005, at 11:39 AM, Robert Wittams wrote:
> 
>> Well, I'm not an author of the framework, but the admin code is very
>> hard to understand (imo). I'm sure the authors understand it fine, but
>> for open source to instill confidence clarity is key. The admin view
>> should be a great example to django users, but unfortunately right now
>> it isn't.
> 
> 
> No, it shouldn't -- the admin views are incredibly complex because  the
> admin interface is incredibly complex.  Public views are almost  always
> going to be much much simpler.  Even if the admin views get  cleaned up
> -- which they should be, of course -- they still won't be  a very good
> example.  You wouldn't tell someone to read the Linux  kernel source to
> learn how to program in C; the admin views should be  thought of the
> same way. 

I can't help thinking that this boils down to : It is complex now, so it
must be complex. I honestly do not feel that the admin code will
necessarily be horrific.

>> My point was really that the admin view presents a really nice  interface
>> by default, and it is a real shame that it doesn't achieve this by
>> utilising the standard recommended django bits. If it is  "impossible" to
>> get something like the admin view without hacking, then the best  course
>> of action is to make it possible.
>>
>> I don't want to alarm anyone or put anyone off django. It is a great
>> framework, and that is why I'm using it. I just think we need to be
>> clear that it is currently not possible to make stuff similar to the
>> admin views without a fair bit of hackery. I hope to obviate this.
> 
> 
> Can you explain in more detail how you feel the admin uses "hacks"?  
> There's nothing the admin uses that you can't use in the public  views;
> it's just that the admin interface is very complex, and so the  code is
> very complex. 

The first problem is the inexplicable concatenation of templates. This
is effectively layering two layers of logic. This makes the code hard to
follow - and it is very inconsistent as to where a particular bit of
logic goes. Even making the AST of the template dynamically would make
more sense (but I don't think it is necessary or desirable).

The parts which I consider to be real hacks are the bits which just
plain don't work in generic views, and require huge messing around in
the view functions. Eg select fields do not pick up their values (
http://code.djangoproject.com/ticket/338 ). The flatten_data stuff is
essential for certain things to work, but is only in the admin. There is
all kinds of special casing that is done, imo in the wrong place.

TBH, my point is not really fixing the admin. My point is making
manipulators and formfields work out of the box. This also needs the
admin to be fixed (as they seem fairly intertwined atm) so I started
working on that. Whilst doing so, I couldn't help thinking that the
whole thing needed a spruce up, which I'm willing to do.

Rob

Reply via email to