djangomongodbdjango-nonreldjango-mongodb-engine

How does unique_together work in Django-nonrel?


I am using django-nonrel and django-mongodb engine.

In engine's documentation, it says that it supports django's Meta options.

I tried using unique_together in a model as such:

class Bottler(models.Model):

    location = models.CharField(max_length=20)

    source = models.CharField(max_length=20)

    transactionID = models.CharField()

    class Meta:
        unique_together = (("location","source"),)

However this doesn't seem to have worked since I could create duplicates without any error being raised.

I know unique_together is enforced at the database level.

What does that translate to in MongoDB? Do I have to validate it manually?


Solution

  • You need to run syncdb in order to sync database indices.