Django Import Class From models.py

半世苍凉 提交于 2019-12-04 13:38:58

use:

from library.models import MyClass

and you should be good to go :)

(the basic structure is from <app>.models import <ModelName>)

update:

the problem is (almost!) certainly that your model begins with '7' -- change it to a letter character, and all will be well, I'm (almost!) sure :)

Romans 8.38-39

for example in your models.py you got :

from django.db import models
from django.contrib.auth.models import User

class register(models.Model):  
    user = models.OneToOneField(User)

Then in your views.py, you can call like this :

from library.models import register
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!