On Wed, Nov 12, 2014 at 11:42 AM, Edward Armes <edward.ar...@gmail.com>
wrote:

> HI guys,
>
> Thanks for your responses, they have indeed answered all my questions
> pretty much as I was mainly looking for information on how to modify how
> Django accesses it's ORM layer. However from your answer it seems that it
> would be better that I do it at the model layer. I apologize for being so
> vague in my question it was semi-deliberate as I wanted to avoid people
> posting application specific solutions like "Use module X and do Y" and
> often when you ask questions reguarding internals on open-source projects
> and other places (i.e. Stack Overflow) you normaly get a load people
> responding with "why?" which for understandable reasons I wanted to avoid.
>
> To follow on from this I have a few more quick questions:-
>
> - If my understanding is correct the Django admin interface uses the model
> layer? If so while learning Django I remember reading (although I can't
> find the link now) that if you use a model that doesn't use Django database
> layer the admin code doesn't work? if this is the case why so?
>

Yes with an if, no with a but :-)

Out of the box, Django's admin only works with Django models. This is
because most of what the admin is doing is based around model introspection
- it's not making database calls per se, it's using the fact that you've
registered your "Product" model, and a Django model has internal mechanisms
to answer questions like "what fields do you have, and what type are those
fields". From that, Django Admin can build a basic CRUD workflow around the
model.

If your data store *isn't* a Django model, then Django's admin doesn't have
any metadata about the model to work with, so it doesn't have any way to
build that workflow.

That said - one of the driving forces behind the Meta Refactor that I
referenced was to formalize what that metadata interface actually is, so in
principle, *any* data model could be displayed in Django's admin, as long
as it is self-describing in the way the Django admin is expecting. As a
proof of concept of this Daniel (the GSoC student responsible) built a
wrapper that lets you browse your Gmail inbox in Django's admin - after
all, email is just a bunch of models like Message, Thread, Folder etc, and
there's an API for manipulating them. That API doesn't use a database, but
it does do Create, retrieve, update and delete, so Django's admin can be
used as a visualisation for it.


> - Secondly would I be correct in thinking that by having asynchronous
> models it would break the default forms and views lthat are included ike
> the wonderful Admin package?
>

Again - only "out of the box". If you make it quack like a Django-shaped
duck by providing an interface that is compatible with Django's
expectations, then it *should* work, and the Meta refactor that is
hopefully coming for 1.8 should make this a lot easier.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq848GOqfVh9QBqeDFf546P5AmGTbqyWLbtx-215kiAPi_WQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to