Consider the following python class:
class Event(Document):
name = StringField()
time = DateField()
location = GeoPointField()
def __unicode__(self):
return self.name
Now I create a list of Events:
x = [Event(name='California Wine Mixer'),
Event(name='American Civil War'),
Event(name='Immaculate Conception')]
Now I want to add only unique events by searching via the event name. How is this done with the boolean in syntax?
The following is incorrect:
a = Event(name='California Wine Mixer')
if a.name in x(Event.name):
x.append(a)