Thomas Guettler wrote: > Stan Dyck schrieb: > >> I'm converting a simple database-backed web form to Django. Each form >> submit inserts a row into a database. >> >> >> > > Hi, > > you can use yourmodel.objects.get_or_create(...) > To force the uniqueness on database level you should use unique_together. > > Perfect! This appears to be what I'm looking for. Thanks.
>> To avoid multiple posts inserting duplicate rows I calculate a checksum >> on selected fields in the form and insert the checksum value into the >> database along with the form data itself. The checksum field is set in >> the database schema to be unique so that if an attempt is made to insert >> a duplicate row, the database will reject the insert. >> >> > I think that this is not a good solution. Most databases can check > uniqueness > over several columns. > My first impulse is that I could override the save method on the form > and use it to check the database for a checksum value. If I don't find > it, I insert the row along with the checksum. If I find it, I just > reject the insert and send the appropriate message to the response. > > This might be possible, but I would handle this outside the save method. > > > Thomas > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---