django-scheduler
django-scheduler copied to clipboard
Use app_name to ease namespace integration in project
Hi, Maybe I misunderstand how django-scheduler should be implemented in my project. If I include urls.py in a sub namespace (as 'dashboard' in my case) I have these issue:
- NoReverse Match issue when loading a page (as scheduler-list)
- TemplateTags like prev_url(target, calendar, period) can't reverse either
So I have to include django-schedulers urls with a namespace:
In dashboard/urls.py
path('schedule/', include('schedule.urls', namespace='schedule')),
Wich force me to prepend all urls in template as following and to define app_name = 'schedule' in django_scheduler urls.py :
{% url "dashboard:schedule:schedule_list" %}
But this doesn't solve the templatetag issue as they can't reverse anyway the url without the correct namespace.
So what is the best solution to implement this app in a subapp? Wouldn't be a solution to create a new setting var like 'SCHEDULER_NAMESPACE' in settings and import it whenever a reverse operation is done in django-scheduler?
If you set up urls in project root your would do it like: root.urls: path('schedule/', include('schedule.urls', namespace='schedule')),
Then call it in template by "{% url 'schedule:schedule_list' %}". Not sure why would you say "dashboard" there. Might be complicated project settings but normally it works like I showed.
Under root, putting the path include with namespace get me this error:
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.