On 6 Gen, 00:32, Malcolm Tredinnick <malc...@pointy-stick.com> wrote:
> On Mon, 2009-01-05 at 06:31 -0800, drakkan wrote:
> > however if i delete an user with records associated in the view I have
> > this error:
>
> > NotSupportedError: cannot delete from a view
> > HINT:  You need an unconditional ON DELETE DO INSTEAD rule.
>
> > django try to delete record from the view and this obviously fails,
>
> > there is a know workaround for this? any way to declare read only the
> > model?
>
> There's no way to say a model is read only. But the solution is easy:
> don't try to delete anything on it. You are in complete control of your
> code. It's entirely up to you whether you try to delete or save things
> on a model, so if it hurts when you do that, just don't do it.

Malcolm, I try to delete an user from the auth_user table; the user is
referenced as foreign key in the view and the delete cascade django
default try to delete all the reference,

I need a foreign key like in the view to write code such as:

databaseview.user.username

so I can use select_related and get all needed database object with
only one query (I use the database view to aggregate some many to many
tables)

so a possible solution is delete the referenced foreign key from the
table on which the views is based on and then delete the target object
(an user object in my example),

however this is error prone, I'm searching a more clean solution such
as redefine delete() or some hack with custom manager,

thanks
drakkan
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to