Python 无法将名称导入\u本机\u字符串

Python 无法将名称导入\u本机\u字符串,python,django,Python,Django,我尝试过其他类似问题中给出的解决方案,但似乎都不起作用 这是我的档案: models.py from django.db.models import * from django.contrib.auth.models import User from django.contrib import admin #from django.conf import settings class Posts(Model): title = CharField(max_length = 40)

我尝试过其他类似问题中给出的解决方案,但似乎都不起作用

这是我的档案:

models.py

from django.db.models import *
from django.contrib.auth.models import User
from django.contrib import admin

#from django.conf import settings

class Posts(Model):
    title = CharField(max_length = 40)
    body = TextField()
    category = CharField(max_length = 20)
    created = DateTimeField(auto_now_add = True)

    class Meta:
        ordering = ["-created"]

    def __unicode__(self):
        return self.title

#class UserProfile(Model):
#    avatar = ImageField("Profile Pic", upload_to="images/", blank=True, null=True)
#    user   = OneToOneField(User, related_name="profile")


class Comments(Model):
    author = ForeignKey(User)
    title = CharField(max_length = 30)
    body = TextField()
    created = DateTimeField(auto_now_add = True)

    class Meta:
        ordering = ["-created"]

    def __unicode__(self):
        return self.title

    #def __unicode__(self):
    #    return unicode(self.user)
设置.py

"""
Django settings for ashishpatil_in project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from os.path import join as pjoin

BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'p4t(+by4n-^vhe+5@9lg784xsivib&f&%-s7p2bn(axn7j&u@$'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'bootstrap3',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.twitter',
    'allauth.socialaccount.providers.google',
    'blog',
)

SITE_ID = 1

ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = True


MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (

    # Required by `allauth` template tags
    "django.core.context_processors.request",
    "django.contrib.auth.context_processors.auth",

    # `allauth` specific context processors
    "allauth.account.context_processors.account",
    "allauth.socialaccount.context_processors.socialaccount",

)

AUTHENTICATION_BACKENDS = (

    # Needed to login by username in Django admin, regardless of `allauth`
    "django.contrib.auth.backends.ModelBackend",

    # `allauth` specific authentication methods, such as login by e-mail
    "allauth.account.auth_backends.AuthenticationBackend",

)

MEDIA_URL = '/media/'
MEDIA_ROOT = pjoin(BASE_DIR, "media")


ROOT_URLCONF = 'ashishpatil_in.urls'

WSGI_APPLICATION = 'ashishpatil_in.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'
以下是异常位置:

/Library/Python/2.7/site-packages/requests_oauthlib/oauth1_auth.py in <module>, line 10

请将
pip freeze
的输出粘贴到项目的环境中,好吗?这似乎是一个依赖性问题。添加了pip的输出,请求是最新的(>2.0.0),并且应该具有在引发异常的行中导入的
to_native_string
方法。
Beaker==1.6.5.post1
Django==1.7.4
FormEncode==1.3.0
Mako==1.0.1
Markdown==2.6.1
MarkupSafe==0.23
Paste==1.7.5.1
PasteDeploy==1.5.2
PasteScript==1.7.5
Pillow==2.7.0
Pygments==2.0.2
Pylons==1.0.1
Routes==2.1
Tempita==0.5.2
Twisted==13.2.0
WebError==0.10.3
WebHelpers==1.3
WebOb==1.4
WebTest==2.0.18
altgraph==0.10.2
bdist-mpkg==0.5.0
beautifulsoup4==4.3.2
bonjour-py==0.3
decorator==3.4.0
django-allauth==0.19.1
django-bootstrap3==5.2.0
django-crispy-forms==1.4.0
django-debug-toolbar==1.3.0
django-registration==1.0
django-registration-redux==1.1
django-xadmin==0.5.0
macholib==1.5.1
matplotlib==1.3.1
modulegraph==0.10.4
nltk==3.0.0
nose==1.3.4
numpy==1.8.0rc1
oauthlib==0.7.2
paster==0.8
py2app==0.7.3
pyOpenSSL==0.13.1
pylibmc==1.4.1
pyobjc-core==2.5.1
pyobjc-framework-Accounts==2.5.1
pyobjc-framework-AddressBook==2.5.1
pyobjc-framework-AppleScriptKit==2.5.1
pyobjc-framework-AppleScriptObjC==2.5.1
pyobjc-framework-Automator==2.5.1
pyobjc-framework-CFNetwork==2.5.1
pyobjc-framework-Cocoa==2.5.1
pyobjc-framework-Collaboration==2.5.1
pyobjc-framework-CoreData==2.5.1
pyobjc-framework-CoreLocation==2.5.1
pyobjc-framework-CoreText==2.5.1
pyobjc-framework-DictionaryServices==2.5.1
pyobjc-framework-EventKit==2.5.1
pyobjc-framework-ExceptionHandling==2.5.1
pyobjc-framework-FSEvents==2.5.1
pyobjc-framework-InputMethodKit==2.5.1
pyobjc-framework-InstallerPlugins==2.5.1
pyobjc-framework-InstantMessage==2.5.1
pyobjc-framework-LatentSemanticMapping==2.5.1
pyobjc-framework-LaunchServices==2.5.1
pyobjc-framework-Message==2.5.1
pyobjc-framework-OpenDirectory==2.5.1
pyobjc-framework-PreferencePanes==2.5.1
pyobjc-framework-PubSub==2.5.1
pyobjc-framework-QTKit==2.5.1
pyobjc-framework-Quartz==2.5.1
pyobjc-framework-ScreenSaver==2.5.1
pyobjc-framework-ScriptingBridge==2.5.1
pyobjc-framework-SearchKit==2.5.1
pyobjc-framework-ServiceManagement==2.5.1
pyobjc-framework-Social==2.5.1
pyobjc-framework-SyncServices==2.5.1
pyobjc-framework-SystemConfiguration==2.5.1
pyobjc-framework-WebKit==2.5.1
pyparsing==2.0.1
python-dateutil==1.5
python-memcached==1.53
python-openid==2.2.5
pytz==2013.7
repoze.lru==0.6
requests==2.6.0
requests-oauthlib==0.4.2
scipy==0.13.0b1
simplejson==3.6.5
six==1.4.1
sqlparse==0.1.14
waitress==0.8.9
wsgiref==0.1.2
xattr==0.6.4
zope.interface==4.1.1