启动服务器时,错误崩溃,我应注意哪个文件和一段代码?该网站上提供的其他答案无济于事。
端子:
group_by_sub_category =
VAR sub_category_wise_total =
GROUPBY (
percentage_subcategory,
percentage_subcategory[YearMonth],
percentage_subcategory[PercentRange],
"sum_sub1",
SUMX(
CURRENTGROUP()
,
IF(
percentage_subcategory[SubCategory] = "Sub1",
percentage_subcategory[TotalCount],
BLANK()
)
)
,
"sum_sub2",
SUMX(
CURRENTGROUP()
,
IF(
percentage_subcategory[SubCategory] = "Sub2",
percentage_subcategory[TotalCount],
BLANK()
)
)
,
"sum_total_count", SUMX(CURRENTGROUP(), percentage_subcategory[TotalCount])
)
RETURN
SELECTCOLUMNS (
sub_category_wise_total,
"YearMonth",percentage_subcategory[YearMonth],
"PercentRange",percentage_subcategory[PercentRange],
"sum_sub1",[sum_sub1],
"sum_sub2",[sum_sub2],
"sum_total_count", [sum_total_count],
"sub1_percentage",([sum_sub1]/[sum_total_count]),
"sub2_percentage",([sum_sub2]/[sum_total_count])
)
接下来是我的应用程序代码。
主要urls.py
File "/home/lab/ProjectsDjango/env_bookmarks/dj-bookmarks/bookmarks/account/urls.py", line 7, in <module>
url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
File "/home/lab/ProjectsDjango/env_bookmarks/bookmarks/lib/python3.8/site-packages/django/conf/urls/__init__.py", line 22, in url
return re_path(regex, view, kwargs, name)
File "/home/lab/ProjectsDjango/env_bookmarks/bookmarks/lib/python3.8/site-packages/django/urls/conf.py", line 73, in _path
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
应用查看次数。py
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^account/', include('account.urls')),
]
应用urls.py
from django.http import HttpResponse
from django.shortcuts import render
from django.contrib.auth import authenticate, login
from .forms import LoginForm
from django.contrib.auth.decorators import login_required
def user_login(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
user = authenticate(username=cd['username'], password=cd['password'])
if user is not None:
if user.is_active:
login(request, user)
return HttpResponse('Authenticated successfully')
else:
return HttpResponse('Disabled account')
else:
return HttpResponse('Invalid login')
else:
form = LoginForm()
return render(request, 'account/login.html', {'form': form})
@login_required
def dashboard(request):
return render(request, 'account/dashboard.html', {'section': 'dashboard'})
也许我在错误的地方找东西,并试图在不存在的地方找到错误?
答案 0 :(得分:0)
我假设您正在使用django> 1.9:您不能将字符串用作视图。因此,您需要对所有视图执行以下操作:
from django.contrib.auth import login, logout
urlpatterns = [
url(r'^login/$', login, name='login'),
url(r'^logout/$', logout, name='logout'),
......
]