1

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.

asked Sep 21, 2010 at 8:28
4
  • 2
    Use django.contrib.admin, don't write your own. That way madness lies (from my experience of doing so, and then getting fed up at all the repetitiveness, and going back to the admin). Commented Sep 21, 2010 at 8:31
  • Ugh, damn. Well in that case Im lacking some documentation for writing in functionality to the admin, such as using callables (def's in the admin model), customizing the admin.py to show related items in the same view (nested foreignkeys), adding links for easier navigation to the related items... The django documentation for this isn't very clear, any pointers? Commented Sep 21, 2010 at 9:24
  • write a separate question on Stack Overflow for each problem you're having (probably do this one at a time, so people don't get mad at you for spamming the site!) Make sure questions are tagged django. There are a bunch of people on here who know Django very well who would be happy to help out. Commented Sep 21, 2010 at 9:37
  • Ok, will do. thanks Dominic. Commented Sep 21, 2010 at 12:18

2 Answers 2

9

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.

answered Sep 21, 2010 at 10:22
Sign up to request clarification or add additional context in comments.

3 Comments

Haha, i like the opener: Slow down, relax! Wish I could, but I make lavish promises :)
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!
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...
0

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

Is Django admin difficult to customize?

answered Sep 22, 2010 at 4:34

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.