Jeff Kowalczyk wrote:
> I'm working with a model using a CharField primary key, ...
> I need to prevent other objects from being created/updated
> if save() is called with a changed pk value.
>
> class Widget(models.Model):
>     identifier = models.CharField(primary_key=True, max_length=10)

I worked on handling this with model save() overrides, or pre_save()
signal handlers. I haven't tried subclassing the CharField pk to add a
pre_save() override, but that's next on my agenda.

Using the admin change_form and a breakpoint, I inspected the self
Widget in Widget.save(self) or the instance kwarg pre_save() in ipdb.
The data is already updated at that point, which makes sense.

However, I could not find any private or _meta attributes which
carried the old data forward for comparison to the new data with the
django save machinery. Is the request-like old data available anywhere
during Model save ?

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

Reply via email to