Mostrar sólo algunos registros con changelist
Soy bastante inexperto en esto. Necesito corregir esto:
def verpz(request,pk):
myapplabel = Pozos._meta.app_label
mymodelname = Pozos._meta.model_name
infodata = myapplabel+'_'+mymodelname
return HttpResponseRedirect(reverse("admin:%s_changelist" % infodata,args=(pk,)))
El objetivo es que en el administrador se muestre la lista de cambios filtrada, no todos los registros, si no solamente los que cumplan con alguna condición cómo por ejemplo que tengan una id específica. Gracias por su colaboración.
Hello. I'm pretty inexperienced at this. I need to correct this:
def verpz(request,pk):
myapplabel = Wells._meta.app_label
mymodelname = Wells._meta.model_name
infodata = myapplabel+'_'+mymodelname
return HttpResponseRedirect(reverse("admin:%s_changelist" % infodata,args=(pk,)))
The objective is that the filtered list of changes is shown in the administrator, not all the records, but only those that meet some condition, such as having a specific id. Thank you for your cooperation.
'admin:%s_changelist' % infodata
dont get any args.
more here: https://docs.djangoproject.com/en/4.1/ref/contrib/admin/#reversing-admin-urls
in your case:
def verpz(request,pk):
... # your staff
return HttpResponseRedirect(reverse(f'admin:{infodata}_changelist'))