#28866: merge method of class Media doesn't work properly
---------------------------------+--------------------------------------
Reporter: clincher | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 2.0
Severity: Release blocker | Resolution:
Keywords: forms, media | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by clincher):
Hi guys, thanks for fast response!
I know that static assets must not be duplicated as well as follow
predefined order. The easiest way to do it will be like that:
for item in list_2:
if item not in list_1:
list_1.append(item)
it will follow all the orders and not duplicate anything.
Personally I find it overcaring to throw the warning about unmatching
order in different lists (Media). However if you are sure it is super
necessary, than I don't find the current logic proper. I barely experience
problem with reading other's people code, but the current method blowed
me. However I think the current algorithm is not correct (as it shown with
data I provided in the ticket) and probably it's not possible way to solve
it.
For throwing the warning (if you really badly need it, guys), we can do
that way:
order_list = []
for item in list_2:
try:
order_list.append(list_1.index(item))
except ValueError:
pass
if order_list is not sort(order_list):
OrderWarning(...)
So, the idea will be that we can associate order of first and second list
and if it is not strictly incremental then throw the warning.
However, seriously, guys, I find it too much and still not perfect,
because there can be a cases when in list_2 will be additional paths
before/after and we can't take care of all the files in third-party
libraries. But what we must do is make Django work as expected: merge
lists of paths in the proper way, not as it is now. In other words better
we will have working explicit solution without warning rather than buggy
solution with warning. What do you think?
--
Ticket URL: <https://code.djangoproject.com/ticket/28866#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.91679af522a4604ec1d4a90bcbf5b1f9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.