[Django] #30344: Converted serve static to class base views

11 views
Skip to first unread message

Django

unread,
Apr 9, 2019, 5:54:45 PM4/9/19
to django-...@googlegroups.com
#30344: Converted serve static to class base views
-----------------------------------------+------------------------
Reporter: Tom Turner | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Hi I wanted to override the serve static I couldn't do this as it wasn't
class based

pull request https://github.com/django/django/pull/11193

--
Ticket URL: <https://code.djangoproject.com/ticket/30344>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 10, 2019, 3:21:37 PM4/10/19
to django-...@googlegroups.com
#30344: Converted serve static to class base views
-------------------------------------+-------------------------------------

Reporter: Tom Turner | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Florian Apolloner):

* cc: Florian Apolloner (added)
* version: 2.2 => master
* component: Uncategorized => contrib.staticfiles


Comment:

What exactly couldn't you override/change? Changing views to functions
based views, just so they are a class is probably not enough. Also this
change is currently highly backwards incompatible.

--
Ticket URL: <https://code.djangoproject.com/ticket/30344#comment:1>

Django

unread,
Apr 11, 2019, 4:10:31 PM4/11/19
to django-...@googlegroups.com
#30344: Converted serve static to class base views
-------------------------------------+-------------------------------------

Reporter: Tom Turner | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.staticfiles | Version: master
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* status: new => closed
* resolution: => wontfix
* type: Uncategorized => Cleanup/optimization


Comment:

Agreed with Florian, just transforming to a class-based view without
making "entry-point" method to override for real use cases doesn't make
much sense. Maybe you could discuss that first on the django-developers
mailing list.

--
Ticket URL: <https://code.djangoproject.com/ticket/30344#comment:2>

Django

unread,
Apr 11, 2019, 4:54:49 PM4/11/19
to django-...@googlegroups.com
#30344: Converted serve static to class base views
-------------------------------------+-------------------------------------

Reporter: Tom Turner | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.staticfiles | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tom Turner):

I agree it not backward compatible however that an easy fix more me to do
I wasn't going to do unless the ticket was accepted. I also agree the
patch needs some tidying up in regards to code comments


I will now give more details why I wanted this patch. 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. I believe this could do this 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 with something like this in
the 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.

Hopefully you now see the use case I want to do.

--
Ticket URL: <https://code.djangoproject.com/ticket/30344#comment:3>

Django

unread,
Apr 12, 2019, 3:47:30 AM4/12/19
to django-...@googlegroups.com
#30344: Converted serve static to class base views
-------------------------------------+-------------------------------------

Reporter: Tom Turner | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.staticfiles | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Florian Apolloner):

You are saying:

> 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.

I do not see how your changes would make this any easier, or why this
would not be possible with the current function based view.

--
Ticket URL: <https://code.djangoproject.com/ticket/30344#comment:4>

Reply all
Reply to author
Forward
0 new messages