Django : Cannot import modules

后端 未结 1 1850
后悔当初
后悔当初 2021-01-01 02:32

I am trying to import a module in my views.py as

from django.shortcuts import render

# Create your views here.
from viewcreator import Builder
import json
d         


        
相关标签:
1条回答
  • 2021-01-01 03:14

    In your INSTALLED_APPS

    INSTALLED_APPS = [
        ...,
        'HdfsstatsConfig',
    ]
    

    in your views.py

    from .viewcreator import Builder
    

    UPDATE, DJANGO IMPORTS

    There are 3 ways to imports module in django

    1. Absolute import: Import a module from outside your current application Example from myapp.views import HomeView

    2. Explicit import: Import a module from inside you current application

    3. Relative import: Same as explicit import but not recommended

    from models import MyModel
    

    0 讨论(0)
提交回复
热议问题