[Django]-Django Import Class From models.py

15👍

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 🙂

👤simon

3👍

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

Leave a comment