models.py

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.


#from mongoengine import * 
from mongoengine import StringField
from mongoengine import ListField
from mongoengine import connect
from mongoengine import Document

connect('wangzuxian', host='127.0.0.1', port=27017) # 指明要连接的数据库 

class ArtiInfo(Document): 
    URL = StringField()
    Info = StringField() 
    IP = StringField()  
    CDN = StringField() 
    title = StringField()
    area = ListField(StringField()) # 定义列表类型 
    cates = ListField(StringField()) 

    meta = { 'collection': 'Info'} # 指明连接数据库的哪张表 

#for i in ArtiInfo.objects: # 测试是否连接成功 
    #print(i.IP)
   

你可能感兴趣的:(models.py)