I have following model for which i want to update team which is a list:
class Users(models.Model):
name = models.CharField(max_length = 100,unique=True)
designation = models.CharField(max_length =100 )
team = ListField(models.CharField(max_length =100),null=True)
I know I can first fetch the team attribute of object and the append the new value to list and then update the object with new list , but is thr any other way for updating ListField?
For appending a value to a list, you want to use a
$pushoperator on theteamfield.The django mongoDb engine has a hook for it:
http://django-mongodb.org/topics/atomic-updates.html
And here is the documentation on how to use the
$pushoperator in mongodb:http://www.mongodb.org/display/DOCS/Updating#Updating-%24push
Hope this helps.