zoukankan      html  css  js  c++  java
  • [python] can not find app ,module

    • can not find module

       1 startapp appname 而不是 startproject

       2 不要自己创建项目根目录,要用mamage.py生成

    • can not find app: 
      因为copy code而误删modell里的:from __future__ import unicode_literals
    • doesn't declare an explicit app_label
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "C:Program Files (x86)JetBrainsPyCharm 2016.1.2helperspydev\_pydev_bundlepydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "C:/Users/tianhang/PycharmProjects/WebAppapp_hyperlinkmodels.py", line 11, in <module>
        class Snippet(models.Model):
      File "C:Python27libsite-packagesdjangodbmodelsase.py", line 102, in __new__
        "INSTALLED_APPS." % (module, name)
    RuntimeError: Model class app_hyperlink.models.Snippet doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

    解决方法:在model添加 app_label = 'app_hyperlink'

    class Snippet(models.Model):
        owner = models.ForeignKey('auth.User', related_name='snippet_user2')
        created = models.DateTimeField(auto_now_add=True)
        title = models.CharField(max_length=100, blank=True, default='')
        code = models.TextField()
        linenos = models.BooleanField(default=False)
        language = models.CharField(choices=LANGUAGE_CHOICES, default='python', max_length=100)
        style = models.CharField(choices=STYLE_CHOICES, default='friendly', max_length=100)
    
        class Meta:
            ordering = ('created',)
            app_label = 'app_hyperlink'



  • 相关阅读:
    Springboot vue 前后分离 跨域 Activiti6 工作流 集成代码生成器 shiro权限
    mybatis3批量更新 批量插入
    Java GC的工作原理详解
    Hadoop的Map侧join
    cut 命令
    head 与 tail
    常用正则
    vim 设置
    Java泛型初探
    linux修改PS1,自定义命令提示符样式
  • 原文地址:https://www.cnblogs.com/tianhangzhang/p/5503626.html
Copyright © 2011-2022 走看看