我有以下网址:
http://localhost:8000/store/add/?points=5
我想从我的 URL 中提取点数。
在我的views.py
,我有:
points = request.GET.get('points',0)
问题是它永远找不到点,所以它使用默认值 0。
任何洞察我做错了什么?
我的urls.py
from django.conf.urls.defaults import *
from store.models import Part, Category, UniPart, LibraryRequest
from django.views.generic.list_detail import object_list
from voting.views import vote_on_object
urlpatterns=patterns('',
#/store/
url(r'^$','store.views.all_models',name="all_models"),
#/integer/view_part
url(r'^(\d+)/view_part/$','store.views.view_part',name="view_part"),
url(r'^your_models/$','store.views.your_models',name="your_models"),#/your_model
url(r'^user_models/(?P<username>\w+)/$','store.views.user_models',name="user_models"),
url(r'^add/(?P<points>\d+)/','store.views.add_model'),
截取自views.py
:
def add_model(request, points=None):
print points