slow_mondays
slow_mondays

Reputation: 871

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?

Upvotes: 2

Views: 431

Answers (2)

Somehow syncbd will not update your indexes in mongodb. What you can try (if possible in your situation) is to delete the collection and then run syncdb. In my case it did create the indexes then.

Upvotes: 0

Jonas H.
Jonas H.

Reputation: 2491

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

Upvotes: 1

Related Questions