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'



  • 相关阅读:
    ADO数据库操作
    AfxMessageBox和MessageBox区别
    Qt — 子窗体操作父窗体中的方法
    Qt — tableWidget插入复选框
    Qt & MySQL
    windows下安装Qt
    Extjs — Grid数据导出成Excel
    Mac终端 vi/vim 的简单使用
    iOS开发CocoaPods使用说明
    Shell 脚本学习笔记十:Shell输入输出重定向
  • 原文地址:https://www.cnblogs.com/tianhangzhang/p/5503626.html
Copyright © 2011-2022 走看看