zoukankan      html  css  js  c++  java
  • django学习遇到的问题解决方式

    1、django.core.exceptions.ImproperlyConfigured: The TEMPLATE_DIRS setting must be a tuple. Please fix your settings.

    解决方法:

    在项目的setting.py文件中修改相关的文件脚本

    TEMPLATE_DIRS = (
        os.path.join(os.path.dirname(__file__), 'templates').replace('\', '/'),
    )

    2、“Unknown command syncdb” running “python manage.py syncdb”

    由于使用了django1.9而1.9中的syncdb已被移除,因此如需创建数据库则应该使用python.exe manage.py createsuperuser

    进行重新初始化数据库则需要使用一下方法

    先manage.py makemigrations

    再进行manage.py migrate

    3、静态的文件访问问题

    首先设置配置setting

    STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    os.path.join( os.path.dirname(__file__),'static').replace('\','/'),
    )

    其次设置配置templates路径

    TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    os.path.join( os.path.dirname(__file__),'tempates').replace('\','/'),
    )

    最后可以进行访问

    <link rel="stylesheet" href="css/style.css" type="text/css">
    <link rel="stylesheet" href="css/reset.css" type="text/css">
    <link rel="stylesheet" href="css/home.css" type="text/css">
    <script type="text/javascript" src="js/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="js/jquery.wookmark.js"></script>

    访问css等样式

    <link rel="stylesheet" href="../static/css/style.css" type="text/css">
    <link rel="stylesheet" href="../static/reset.css" type="text/css">
    <link rel="stylesheet" href="../static/css/home.css" type="text/css">
    <script type="text/javascript" src="../static/js/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="../static/js/jquery.wookmark.js"></script>

    4、WARNINGS:

    ?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 a
    nd the TEMPLATES dictionary takes precedence. You must put the values of the fol
    lowing settings into your default TEMPLATES dict: TEMPLATE_DIRS.

    解决方法:

    把 TEMPLATE_DIRS 删了

    5、raise ImproperlyConfigured("settings.DATABASES is improperly configured. "

    django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly co
    nfigured. Please supply the ENGINE value. Check settings documentation for more
    details.

    解决方法:

     DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'blog',
            'USER': 'root',
            'PASSWORD': '123123',
            'HOST': '',
            'PORT': '',
        }
    }
     
    6、Python3.4使用pip安装django报错

    E:Python34Scripts>pip
    Fatal error in launcher: Unable to create process using '"E:Python34python.exe
    " "E:Python34Scriptspip.exe" '

     原因:由于路径含有空格

    解决办法:python -m pip install Django

     
     
    7、python3安装MySQLdb报错

    原因:

    1、由于其模块已在Python3中不支持

    2、缺失C++模块

    解决办法:

    重新安装PyMySQL或者是安装C++,并更改配置

    VS120COMNTOOLS=D:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/Tools/

    有而VS100COMNTOOLS没有。

    然后当然set VS100COMNTOOLS=%VS120COMNTOOLS%

    另外,从D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC下面拷贝一个vcvarsal.bat到

    D:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/Tools/

    下面即可。

     
  • 相关阅读:
    在Spring Boot中使用数据库事务
    Data Consistency Primer
    在Spring Boot中输出REST资源
    Android开发——进程间通信之Messenger
    初识在Spring Boot中使用JPA
    设计模式——享元模式详解
    回首2016,展望2017
    [转]OpenStack Keystone V3
    [原]Openstack之identity server(keystone)
    [原]secureCRT 改变显示宽度
  • 原文地址:https://www.cnblogs.com/xiaoyaowuming/p/5458862.html
Copyright © 2011-2022 走看看