Converting serve static to class base views

43 views
Skip to first unread message

Thomas Turner

unread,
Apr 11, 2019, 5:05:36 PM4/11/19
to Django developers (Contributions to Django itself)

Hi all

I want to make a case for converting the Serve Static to Class Base View it is ticket number 30344 https://code.djangoproject.com/ticket/30344


I am the maintainer of a project called Django Tenants ​http://github.com/tomturner/django-tenants which allows you to have tenants in Django ie a.mydomain.com and b.mydomain.com. The problem I have is that on the different domains I want to serve different static files. The problem is I cant pick up the domain and set the correct tenant for static files. I believe this could be done easier if the serve static is class based. Making the serve static class base will not affect users of Django and I know a lot of other areas in Django have been converted to class base views such as the admin


I believe one could override the entry point could be manual added to a URL


re_path(r'^site_media/(?P<path>.*)$', static.ServeStatic.as_view(document_root=media_dir, show_indexes=True))


I know server static should only be used for development use only.





Florian Apolloner

unread,
Apr 12, 2019, 3:57:50 AM4/12/19
to Django developers (Contributions to Django itself)
Hi,

as written on the ticket already you have to present __why__ and __what__ your class based view makes easier. As it currently stands I cannot see anything which you couldn't also achieve by "inheriting" the function based view.

Cheers,
Florian
Reply all
Reply to author
Forward
0 new messages