我的代码:
from django.conf.urls import url
from api import views
urlpatterns = [
url(r"^entries", views.EntryList.as_view(), name="api-entries-list"),
url(r"^entries/(?P<pk>[0-9]+)/$", views.EntrySingle.as_view(), name="api-entry")
]
from blog.models import *
from cvitae.models import *
from activities.models import *
from rest_framework import serializers
class EntrySerializer(serializers.ModelSerializer):
class Meta:
model = Entry
fields = ("title", "slug")
我有一个名为blog
的应用程序,它包含Entry
模型,简称为title
、content
和{/api/entries
时,没关系,它给出数据库中所有的Entry
模型实例。在
[
{
"title": "And Maybe This is Another One",
"slug": "and-maybe-this-is-another-one"
},
{
"title": "Another Topic Here",
"slug": "another-topic-here"
},
{
"title": "An Example Title",
"slug": "an-example-title"
}
]
但是,当我确实想要一个Entry
实例时,我仍然得到相同的输出,这意味着我仍然得到所有对象。我不知道我哪里做错了。在
您需要终止第一个regex,否则它将匹配以“entries”开头的所有内容。在
相关问题 更多 >
编程相关推荐