Как динамически создать url-путь из списка dicts
У меня есть список dicts, который содержит путь, представление и имя представления
Предположим, у меня есть следующий список с большим количеством URL, которые имеют следующий формат
url_lsts = [
{"path" "preview/", "view": reverse("app:index"), name="preview"}
...
]
urlpatterns = [
path(url["path"], url["view"], name=url["name"]) for url in url_lsts
]
при использовании reverse я получаю следующий url
django.core.exceptions.ImproperlyConfigured:
The included URLconf 'aisp.urls' does not appear to have any patterns in it.
If you see valid patterns in the file then the issue is probably caused by a circular import.
Я попробовал reverse_lazy и получил следующий URL
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().