Closed burakkilic closed 11 years ago
Since you are using ReferenceField, you should assign the user field a user.to_dbref() value. Otherwise, you should make it required = False, if activities do not require an assigned user reference.
I tried to_dbref(). I doesn't work.
rating = Activity.objects.create(venue=venue.to_dbref(),user=user.to_dbref())
My User registration is like:
def register(request):
if request.method == 'POST' and request.POST['name'] and request.POST['password']:
u = User(username=request.POST['name'])
u.set_password(request.POST['password'])
u.save()
return render_to_response('registration/register.html')
And User model is:
class User(auth.User):
email = EmailField()
first_name = StringField(max_length=50)
last_name = StringField(max_length=50)
photo = URLField()
auth.User is mongoengine' s User.
You should just pass a saved user object and it will convert correctly. If this is still an issue - please post a ticket to the official repo: https://github.com/MongoEngine/mongoengine
When I am trying to insert a new Activity, I am getting ValidationError. What is the problem?