Tuesday, January 25, 2011

Re: DB-Views or read-only tables in models



2011/1/25 bvdb <bvdb@kanka.de>
A developer sometimes has to access and present data that existed
before his application. Common practice is for a database
administrator to define a database view (with a CREATE VIEW sql
command, not to be confused with the V in MVC) and give the Django
developer access to this. This is only a read access because in most
cases it is not possible or desireable to allow an UPDATE on a view.

Now I am new to Django, have some experience with databases - and
couldn't find a "read-only attribute" when defining a model.
Without knowing that a view - that is accessed with the same SELECT
syntax as a table - is read-only Django would for example generate an
admin interface that produces errors, and leave the user wondering
why.
It makes also sense in some cases to define a table read-only for a
model even it is fully accessible by the Django team.

Is it really not possible to define read-only access in Djangos ORM?
Or maybe I just overlooked the description?

Define a model for your db view and set the meta option 

managed=False


--
Simo

- Registered Linux User #395060

- Software is like sex, it is better when it is free  --> Linus B. Torvalds

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment