I am trying to write a generic urlpatterns entry in urls.py that would replace hardcoded entries, as below:
path('apple/', RedirectView.as_view(url='/apple/abc/'), name='apple_redirect'),
path('orange/', RedirectView.as_view(url='/orange/def/'), name='orange_redirect'),
path('banana/', RedirectView.as_view(url='/banana/ghi/'), name='banana_redirect'),
The model called fruits holds the following data:
name = 'apple'
url = 'apple/abc/'
name = 'orange'
url = '/orange/def/'
name = 'banana'
url = '/banana/ghi/'
I would like to avoid the need for manual addition of another path in case new entry in fruits model is added.