views:

60

answers:

2

I am new to django and have gotten a bit stuck on trying to make the admin site work as I'd like it to. I am wondering if for making the admin functionality I want it is better to make a custom admin app with a template inheriting from admin/base_site.html, using the frontend login with a redirect when is_staff is true.

The initial details that make me think this:

  1. I have a chain of foreignkeys and would like to display nested inlines on the parent admin page. I have tried using easymode, but it's got its own issues and requirements that may cause headaches later i can do without.

  2. I would like to add a function allowing the admin to add an instance of a model, which triggers the creation of instances its related models and redirects etc. This requires adding some callables at least, which I havent figured out yet how to really do with any success in the admin model, and at the moment seems easier to just quickly do this in the views.py of my own app rather than trying to toy with the admin views.

In general, creating a custom admin app (using a is_staff=true redirect on the FrontEnd login) seems more flexible in the long run, and will result in a more designed and intuitive admin interface for the client - so I suppose my question is, what are the semi-pros doing? (if you know how to hack the admin views and templates to your heart's content you are not a semi-pro :) )

Thanks for any advice you can offer, Im still getting my feet wet and this kind of advice could save me alot of time and headache.

A: 

Slow down. Relax. Follow the Django philosophy.

  1. You have an "app". It presents data. Focus on presentation.

  2. You have a default, built-in admin for your "app". It updates data and it's already there.

  3. If the admin app doesn't meet your needs update Forms and update Models to get close. But don't strain yourself messing with admin. Get as close as you can. But relax about it.

[Also, "more intuitive admin" is sometimes not an accurate description of what you're trying to do. It could be, but I've seen some "more intuitive" that actually wasn't.]

a more designed and intuitive admin interface for the client.

Is this part of the app? Does the app do more than simply present data?

If the app is transactional -- add, change, delete -- crud rules -- that kind of thing, then that's your app. If you want a fancy UI, that's not admin any more. There's no redirect. That's your app.

It's just coding. Stop messing with admin and start writing your app.

Hint: Use generic views as much as possible.

Other than that, you're talking about your app, not hacking the admin stuff that already works.

if you know how to hack the admin views and templates to your heart's content you are not a semi-pro

Wrong. All the source is there. You can read it, also. That's what the pros do. We read the source. And we don't hack the admin app.

If you have complex transactions, you have a first-class, for-real, actual application. Not default admin, but a part of your app that has forms.

If you have forms, then, well, you have forms. This does not require hacking the admin app, it's just coding more of your app.

S.Lott
Haha, i like the opener: Slow down, relax! Wish I could, but I make lavish promises :)
HdN8
Thanks for the clarifications, your point 3. i think is the answer, update Forms and Models to get close, but dont mess with the admin app. "If you want a fancy UI, then thats not admin anymore, thats your app" This one I have to think over :) Thanks again for your advice!
HdN8
@HdN8: If Update/Change/Delete is part of your app then the default admin may not be completely appropriate. We have a few transactions that we handle outside admin because we wanted more "intuitive" processing. But a large portion of our database is not for "end users" to touch; so we use default admin for that.
S.Lott
Yea, I went with this option too, and am making views for these parts of the functionality. It's more like Im making this for another "end-admin", so thats why I want it to be "intuitive" to manage. Yes, I use this word with caution...
HdN8
A: 

Go through the links mentioned in this post as well. This may be helpful for you.

http://stackoverflow.com/questions/3155624/is-django-admin-difficult-to-customize

anand