Okay, I finally solve the problem.
In models I had to declare how the db is, as always...
(models.py)
# Create your models here.
from mongoengine import *
class User(Document):
email = StringField(required=True)
first_name = StringField(max_length=50)
last_name = StringField(max_length=50)
class Comment(EmbeddedDocument):
content = StringField()
name = StringField(max_length=120)
class Post(Document):
title = StringField(max_length=120, required=True)
author = ReferenceField(User)
tags = ListField(StringField(max_length=30))
comments = ListField(EmbeddedDocumentField(Comment))
meta = {'allow_inheritance': True}
class TextPost(Post):
content = StringField()
class ImagePost(Post):
image_path = StringField()
class LinkPost(Post):
link_url = StringField()
In views.py(or python console either)....
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from game.models import * //Import the models
from mongoengine import * //Import things like connect
def testview(request):
connect('reborn')//Connect to DB
//Let's add some data!
article = User(email = 'test@title.com',first_name = 'test content')
article.save()
return HttpResponse("SAVED")