jazzband / django-cookie-consent

Reusable application for managing various cookies and visitors consent for their use in Django project.
https://django-cookie-consent.readthedocs.org/en/latest/
BSD 2-Clause "Simplified" License
225 stars 73 forks source link

[Feature request] Configuration to customize or disable the page `/cookies/` #114

Open cdutr opened 9 months ago

cdutr commented 9 months ago

I installed django-cookie-consent on a website and tried to disable the main page on [site-url]/cookies/, but the code stops working. I can not translate it as well.

I suggest we have a logic to allow the website to disable this page, or customize it.

Maybe it is already possible, but I couldn't find anything related in the documentation. If it is, I would appreciate some help.

some1ataplace commented 9 months ago

For now you can try overriding the URLs yourself or redirect your user somewhere else if they try to access that page. Add URL entries like these to urls.py before including django-cookie-consent urls.

from django.urls import path, re_path
from django.views.generic import TemplateView, RedirectView

urlpatterns = [
    # These URLs shadow django-cookie-consent URLs to shut them down:
    path('cookies/', RedirectView.as_view(url='/')),
]

Source: https://stackoverflow.com/questions/14959217/django-url-redirect

It would not be a bad idea though to implement a True/False setting that disables the cookies URL.

cdutr commented 9 months ago

I tried this, but the cookie logic stops working. Apparently the lib depends on the site.com/cookies URL being available and sending to the cookies page.

sergei-maertens commented 7 months ago

I will look into this in the next few weeks!

The approach where you manage the URL conf yourself is favourable, as that is just a standard django mechanism and gives you as developer full control when you need it, but indeed, if there's other code that's reversing this URL, then that should be more decoupled.

Do you have a traceback for the situation where "the cookie logic stops working"?