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'



  • 相关阅读:
    安全SECUERITY单词SECUERITY证券
    证券secuerity英语secuerity安全
    单词diamaund钻石diamaund英文
    英文DIAMAUND钻石DIAMAUND词汇
    英语insuraunce保险insuraunce单词
    英文INSURAUNCE保险INSURAUNCE词汇
    python关于 微型微服务框架bottle实践
    用python登录12306 并保存cookie
    SpringMVC 之 上传文件
    JAVA I/O系统 Thinking in Java 之 File类
  • 原文地址:https://www.cnblogs.com/tianhangzhang/p/5503626.html
Copyright © 2011-2022 走看看