Creating field value “unique” throughout the collection in Django MongoDB models?

I am having hard time to understand how to make field value unique while using Django has a model:

class Projects(models.Model):
    projectName =models.CharField(max_length = 100,unique=True)
    projectManager = EmbeddedModelField('Users')

Here i want whenever a new project instance is added it should have unique projectName.But this code is not working out as it allows adding same value for projectName and doesn't give me error.I read its possible to make field value Unique by using indexes in pymongo but how do I do it in Django MongoDB.


Answer to my own question is I had to add unique=True for model field before doing syncdb.Thanks to culebron.Its working now

Need Your Help

How do I get my text to be both bold and italic in iText?

fonts styles itext bold italic

I am trying to make my text both bold and italic at the same time for a paragraph in a PDF document using iText.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.