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'



  • 相关阅读:
    2016/4/27 xml
    2016/4/27 网络编程
    2016/4/25 java io
    mysql 基础列题
    数据库的语法
    数据库
    io流
    xml
    网络编程
    gui2
  • 原文地址:https://www.cnblogs.com/tianhangzhang/p/5503626.html
Copyright © 2011-2022 走看看