On 26 Jan 2011, at 12:26, Jaroslav Dobrek wrote:
>>
>> http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique
> Example:
>
> This should be allowed:
>
> car1: manufacturer = "foo", name = "bar"
> car2: manufacturer = "foo", name = "baz"
>
> This should not be allowed:
>
> car1: manufacturer = "foo", name = "bar"
> car2: manufacturer = "foo", name = "bar"
Doesn't look to be directly possible from the Django's API; but I guess you
could,
class Car(models.Model):
manufacturer = models.CharField(max_length=127)
name = models.CharField(max_length=127)
manufacturer_name = models.CharField(max_length=256, unique=True)
def save(self, *args, **kwargs):
manufacturer_name = "%s_%s" % (self.manufacturer, self.name)
super(Charge, self).save(*args, **kwargs)
aid
--
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.