tags:

views:

222

answers:

2

I've written an entire app pretty successfully in Django but I have this nagging question that I think I know the answer to but I just want to make sure.

One of the things I really liked about Django was the data model and the ability to not have to do "obvious" stuff. For example, we use the admin interface extensively in our app. The fact that I don't need to write an edit screen for every model and keep it up to date every time the model changes is really nice.

What I'm puzzled by is that I wanted to have one part of the app render "read-only" versions of the models. Essentially I want exactly what I have in the Admin interface but without editable widgets. Now I notice, from the Django code, that that admin interface actually goes through and substitutes the widgets to use the editable ones so I know that non-editable is certainly there.

But as far I can tell, there is no way to just say "render this object" and have Django do the "obvious" thing and render it just like it does for the admin interface but with non-editable fields. I find this hard to believe since it seems like a) this is easier than the admin stuff and b) I know the widgets are already there. But I've looked all over and even the Django examples seem to always create a template and spell out exactly what the page should look like.

Writing a template is probably a good idea in general but early on in development when things are changing it would be better to have something that just does something basic given the information available in the model.

Am I missing something? Sorry if this is a stupid question.

+2  A: 

Could be that most non-toy sites want a custom layout/html anyway?

Or, are you looking for Databrowse?

Marcus Lindblom
I completely agree, non-toy sites want custom layout and HTML. I don't expect this to be useful for polished sites. I just wish I had it primarily for development and even in the odd "it doesn't matter so much" case. Based on a quick scan of the documentation, databrowse looks very much like what I was looking for.I figured it had to exist but I never saw it in the book I have (which admittedly is out of date, at v0.96) or in any of the tutorial material I read.I figured something like this existed. It ends up being very difficult to find stuff when you don't know what it is called.
Michael Tiller
Yeah, it'd be nice if there was documentation for databrowse. Patches welcome, I'm sure :-)
Carl Meyer
A: 

I used something like this: http://www.djangosnippets.org/snippets/937/

There are other similar things around if you google for 'django read-only admin' or similar.

Never underestimate how flexible the Django Admin is...

andybak