I'm working with a model using a CharField primary key, and want to ask whether it is appropriate to use force_update=True in a save() override on the model. 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 realize that the Django ORM works best with an auto id column, and I can use that if necessary. I'm experimenting with a custom PK for two reasons: a) this key is an externally assigned alphanumeric ID that won't change over the lifetime of the object, and b) some legacy tables I'll need to work with in the future have the same layout. I first noticed this in the admin app, where edting (this Model's) pk field creates or updates a different object with that pk. Confirmed in the shell, and mentioned in the docs [1]. Thanks for any suggestions. [1] Forcing an INSERT or UPDATE http://docs.djangoproject.com/en/dev/ref/models/instances/#forcing-an-insert-or-update [2] Changing the value of the primary key http://groups.google.com/group/django-users/browse_thread/thread/6a0567912d2f035/06c503c65189fabc [3] Admin interface using CharField as a primary key http://groups.google.com/group/django-users/browse_thread/thread/50be5ff7b516bd76/e07e653d7f51c493 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---