small problem of Django and its reverse url,
I try to have a link from a model to another model in the same admin:app
I have this function to run reverse('admin:jobs_xml_jobboardexterne')
I run from this page admin/jobs_xml/countjobboarderrors/
and I get an error:
https://i.sstatic.net/Uf00J.png
here the code was make the call :
class CountJobBoardErrorsAdmin(admin.ModelAdmin):
list_display = ("have_error_job_board", "have_not_error_job_board", "total_job_board")
def have_error_job_board(self, obj):
url = reverse('admin:jobs_xml_jobboardexterne')
return mark_safe(f'<a href={url}>{JobBoardExterne.objects.count()}</a>')
ok, so Django can't find my link, in my settings.py I have the application noted
INSTALLED_APPS = [
...,
'jobs_xml',
...
]
my project urls.py also
admin.autodiscover()
urlpatterns = [
...,
url(r'^admin/', admin.site.urls),
]
an idea ? I can't find the error.
thank you for your help :)
SOLUTION >>> I was needed to add the verbe https://docs.djangoproject.com/en/4.1/ref/contrib/admin/#reversing-admin-urls
Add 'change_list' to the end.
Try:
reverse('admin:jobs_xml_jobboardexterne_changelist')
Or (if jobboardexternes
is plural)
reverse('admin:jobs_xml_jobboardexternes_changelist')