我收到 ValueError of invalid literal for int() with base 10: ''
I am getting ValueError of invalid literal for int() with base 10: ''
from django.conf.urls import patterns, include, url
urlpatterns = [
url(r'^all/$','article.views.articles'),
url(r'^get/(?P<article_id>)\d+/','article.views.article'),
]
那是我的 urls.py 而且,
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.template.loader import get_template
from django.template import Context
from django.views.generic.base import TemplateView
from article.models import Article
def articles(request):
return render_to_response('articles.html',{'articles':Article.objects.all()})
def article(request, article_id=1):
return render_to_response('article.html', {'article':Article.objects.get(id=article_id)})
以上是我的 views.py 但是当我尝试 运行 mysite/get/1/ 它给了我无效文字的错误 int() with base 10: ''.试过参考其他问题解决,还是不行
检查命名捕获的语法。这是他们在 docs
中的样子
(?P<name>pattern)
所以你应该制作你的图案
(?P<article_id>\d+)
from django.conf.urls import patterns, include, url
urlpatterns = [
url(r'^all/$','article.views.articles'),
url(r'^get/(?P<article_id>)\d+/','article.views.article'),
]
那是我的 urls.py 而且,
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.template.loader import get_template
from django.template import Context
from django.views.generic.base import TemplateView
from article.models import Article
def articles(request):
return render_to_response('articles.html',{'articles':Article.objects.all()})
def article(request, article_id=1):
return render_to_response('article.html', {'article':Article.objects.get(id=article_id)})
以上是我的 views.py 但是当我尝试 运行 mysite/get/1/ 它给了我无效文字的错误 int() with base 10: ''.试过参考其他问题解决,还是不行
检查命名捕获的语法。这是他们在 docs
中的样子(?P<name>pattern)
所以你应该制作你的图案
(?P<article_id>\d+)