Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django属性错误';模块';对象没有属性';XYZ';_Python_Django - Fatal编程技术网

Python Django属性错误';模块';对象没有属性';XYZ';

Python Django属性错误';模块';对象没有属性';XYZ';,python,django,Python,Django,这就是我的URL.py from django.conf.urls import patterns, include, url from v1_1 import views urlpatterns = patterns('', url(r'', include('social_auth.urls')), url(r'^$', views.fblogin), ### LINE1 url(r'^logged-in/$', 'v1_1

这就是我的URL.py

from django.conf.urls import patterns, include, url
from v1_1 import views

urlpatterns = patterns('',
    url(r'', include('social_auth.urls')),
    url(r'^$', views.fblogin),                      ### LINE1
    url(r'^logged-in/$', 'v1_1.views.fb_loggedin'), ### LINE2
)
由于第1行的原因,它会导致错误。它(相同的代码)在一段时间以前是可以工作的。如果我将第1行更改为
url(r'^$','v1_1.views.fblogin'),
它可以正常工作。。。我无法理解这个问题:/

这是我的观点

from django.http import HttpResponse
from django.template import RequestContext, Context, Template
from django.template.loader import get_template
from kb_db1.models import User
from django.core.exceptions import ObjectDoesNotExist
import datetime

def home(request):
    t = get_template('profile.html')
    c = get_user(1)
    r = t.render(c)
    return HttpResponse(r)

def fblogin(request):
    t = get_template('login.html')
    c = Context({'name':'Suneet' , 'STATIC_URL':'/stic' , })
    r = t.render(c)
    return HttpResponse(r)

def fb_loggedin(request):
    t = get_template('profile.html')
    user = request.user
    c = get_user(user)
    #c = Context({'user2':user , 'fb_app_id':'139460226147895', 'app_scope':'email', 'STATIC_URL':'/stic' , })
    r = t.render(c)
    return HttpResponse(r)

def notfound(request):
    t = get_template('404.html')
    c = Context({'name': 'Adrian', 'section.title': 'Suneet'})
    r = t.render(c)
    return HttpResponse(r)

def display_meta(request):
    t = get_template('done.html')
    c = get_user(2)
    #return render(request, t, {'m_list': m_list})
    r = t.render(c)
    return HttpResponse(r)

def get_user(user):
    id = user.id
    try:
        u_list = User.objects.get(id=id)
        try:
            u_list.profile = u_list.get_profile()
            u_list.profile = prettify_user(u_list.profile)
        except ObjectDoesNotExist:
            u_list.profile = u_list
            u_list.profile.cumulative_rating = '- '
        c = Context({'u_list':u_list, 'user2':user, 'STATIC_URL':'/stic'})
    except ObjectDoesNotExist:
        print("Either the entry or blog doesn't exist.")
        c = Context({ 'name': 'Error', 'user2':user, 'fb_app_id':'139460226147895', 'STATIC_URL':'/stic'})
    return c

def prettify_user(user):
    try:
        confident_rating, confident_votes = calc_rating(user.cumulative_rating, user.cumulative_votes, 5.2, 5)
        user.cumulative_rating = "%.0f" %(confident_rating*10) # 9.750 => 97.50 => 98       |   9.749 => 97.49 => 97.4
        user.cumulative_votes = confident_votes
    except ObjectDoesNotExist:
        user = 'me'
    return user

def calc_rating(rating, votes, fake_rating_val, fake_votes_no):
    total_votes = votes+fake_votes_no
    rating = (float(rating*votes) + fake_rating_val*fake_votes_no)/total_votes
    return rating, total_votes

def chck_anon(user):
    if not user.is_anonymous:
        user.is_anonymous = True
    return user

你的views.py文件中有什么?实际的
模块和
XYZ
是什么?'module'对象没有属性'fblogin'。。。。令人困惑的是,相同的urls.py以前也在工作:/您最近升级过Django版本吗?什么是
v1\u 1
?@suneet为什么
url(r'',include('social\u auth.url'))中没有url模式