4

Just learning django here, going through their website's tutorial.

When they take you through their admin panel, it's like, wow, all I have to do is define a model and django will give me a cool web page like this?

But that doesn't seem to be the case--it seems as if all that cool automatic functionality is only inside the admin panel. It seems that, if you want to have a cool add/change form, for instance, a form that looks and acts like the one in the admin panel, you're going to have to do all the layout and cool features by hand.

Am I wrong about this? Is there some way to make something that looks and works exactly like the admin's "change record" panel, but at your own url?

Cagatay Barin
  • 3,428
  • 2
  • 24
  • 43
Le Mot Juiced
  • 3,761
  • 1
  • 26
  • 46
  • 1
    Django admin leverages all of the same functionality available in Django itself. – Brandon Taylor Feb 01 '16 at 22:04
  • 1
    http://stackoverflow.com/questions/5449604/django-calendar-widget-in-a-custom-form You should use the Django ModelForm class because that's what Django Admin is based on, and to make it look like the Admin Site I think that post will help, the same goes for other Django Admin widgets which you can find here https://github.com/django/django/blob/master/django/contrib/admin/widgets.py – kushtrimh Feb 01 '16 at 22:13
  • @Brandon, you're right of course, but that's not the question. Mere functionality is one thing, but I'm specifically referring to *automatic* functionality. I said: "It seems that, if you want a cool add/change form.... you're going to have to do all the layout and cool features by hand." Since, when you create a model and access it via the admin panel, it does a ton of cool stuff *for* you, my question is if there's some way to use that existing pre-rolled format/functionality *outside* the admin panel, without having to redo it all yourself. – Le Mot Juiced Feb 13 '16 at 21:31
  • Not that I'm aware of. – Brandon Taylor Feb 13 '16 at 21:54
  • 1
    Class based views are like the admin with training wheels off. You still have to write your own templates, but often its just a case of supplying a model to get a standard view functionality (generating forms based on the model, or a list based on the model). This site is great for learning them. http://ccbv.co.uk/ – wobbily_col Feb 26 '16 at 14:15
  • I once built some functionality admin site has. Use below url. That shoulnt take more than a few hour. https://github.com/codigodaniel/Django-Magic-Frontend/tree/master/django_magic_frontend – durdenk May 16 '16 at 16:13

1 Answers1

2

You are right, but I guess your expectations might be wrong.

Django's automatic admin site is one of the things that makes it very powerful. For example if you're building a large site, normally you'd also have to spend a lot of time to create a admin site, I mean A LOT! So Django provides a useful admin site automatically and it does a good job, which is great.

On the other hand your actual site is always going to be different so Django doesn't provide you the similar "automatic" ways as you expect. But it provides you the same building blocks, like ModelForms, ClassBasesView etc.. And of course, you have to put them together. But it's so much easier and faster to build sites with those blocks then doing it by yourself.

That being said, if you really like how admin site is looking and behaving then you can copy and use them on your main site, which will still require you to do some work.

(Couldn't comment, lacking reps)

Tiny Instance
  • 2,351
  • 17
  • 21
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/13075196) – Adam Katz Jul 21 '16 at 18:28
  • I didn't have enough reps to comment at that time. And I mentioned it at the bottom of the post. I just reached 60 reps. – Tiny Instance Jul 21 '16 at 23:17
  • 1
    Actually this is exactly the kind of answer I was looking for. It clarifies a category mistake I was making, in that I was thinking that the admin site was a template. – Le Mot Juiced Jul 22 '16 at 13:26