我得到int main(){
int n, count =0;
printf("enter an integer = ");
scanf("%d", &n);
printf("your number %d has ", n);
while (n!=0){
n/=10;
count++;
}
printf("%d digits", count);
return 0;
}
。任何帮助表示赞赏。有什么想法吗?
FieldError: Unsupported lookup 'unaccent' for CharField or join on the field not permitted
Traceback指向:
#template
<form class="navbar-form navbar-left" method="GET" action="{% url 'search' %}" value="{{request.get.q}}">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" >
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
#views.py
def Search(request):
queryset_list=Testimony.objects.all().order_by('timestamp')
if request.user.is_staff or request.user.is_superuser:
queryset_list=Testimony.objects.all()
print('1')
if request.method=='GET':
query=request.GET.get("q")
print('2')
queryset_list = Testimony.objects.filter(
Q(title__unaccent__lower__trigram_similar=query)|
Q(body__unaccent__lower__trigram_similar=query)|
Q(username__unaccent__lower__trigram_similar=query)
#Q(firstname__unaccent__lower__trigram_similar__icontains=query)
).distinct().order_by('timestamp')
print('3')
paginator = Paginator(queryset_list, 20)
page_request_var="page"
page=request.GET.get(page_request_var)
try:
queryset=paginator.page(page)
except PageNotAnInteger:
queryset=paginator.page(1)
except EmptyPage:
queryset=paginator.page(paginator_num.pages)
print('4')
context={
"object_list": queryset,
"title":"list",
"page_request_var":page_request_var,
}
return render(request, 'search.html', {'queryset_list':queryset_list})
答案 0 :(得分:0)
对于Django至少为1.11(source),而对于PostgreSQL至少为8.5(source)
from django.contrib.postgres.operations import UnaccentExtension
class Migration(migrations.Migration):
dependencies = [
(<snip>)
]
operations = [
UnaccentExtension()
]
琐事:它不适用于admin.py,但适用于其他.py文件。