Reputation: 2517
I use django admin and want to access the object id in an URL like this: http://localhost:8000/polls/platform/837/change
class PlatformAdmin(admin.ModelAdmin):
def get_queryset(self, request):
print(request.??)
So what should be returned is the 837
Upvotes: 0
Views: 159
Reputation: 2046
ModelAdmin
class has get_object
method which receives object_id
, so basically you need to override that method.
class PlatformAdmin(admin.ModelAdmin):
def get_object(self, request, object_id, form_field=None):
# print(object_id)
return super().get_object(request, object_id, form_field=None)
Upvotes: 1