#12265: Media (js/css) collection strategy in Forms has no order dependence concept --------------------------------+------------------------------------------- Reporter: tblanch...@mac.com | Owner: nobody Status: new | Milestone: Component: Forms | Version: 1.1 Keywords: | Stage: Unreviewed Has_patch: 0 | --------------------------------+------------------------------------------- And thus is broken. I have a form with a bunch of fields in it and when collecting the js files to include it mixes up the order and thus core.js ends up loaded later than files that require addEvent and the js load fails. At the end of the day, this mechanism is just half baked and would be better removed entirely so busy developers can just get stuff done and not waste time with it.
For example: class NewIncidentForm(forms.ModelForm): place = forms.CharField(widget=EditableMap(options={ 'layers': ['google.hybrid', 'google.streets', 'google.physical', 'google.satellite', ], 'default_lat': 39.4421, 'default_lon': -100.0, 'default_zoom': 7, 'geometry': 'point', })) when_occurred = forms.DateTimeField(widget=widgets.AdminSplitDateTime()) when_reported = forms.DateTimeField(widget=widgets.AdminSplitDateTime()) class Meta: model = Incident class Media: js = ( '/media/js/core.js', '/media/js/admin/RelatedObjectLookups.js', '/media/js/getElementsBySelector.js', '/media/js/actions.js', ) class Incident(models.Model): title = models.CharField(max_length=128) when_occurred = models.DateTimeField() when_reported = models.DateTimeField() reporter = models.ForeignKey(User) place = models.PointField() notes = models.TextField(max_length=4000) what_type = models.ForeignKey(IncidentType) # allow spatial querying objects = models.GeoManager() results in this: <link href="/static/olwidget/css/olwidget.css" type="text/css" media="all" rel="stylesheet" /> <script type="text/javascript" src="/media/js/calendar.js"></script> <script type="text/javascript" src="/media/js/admin/DateTimeShortcuts.js"></script> <script type="text/javascript" src="http://openlayers.org/api/2.8/OpenLayers.js"></script> <script type="text/javascript" src="/static/olwidget/js/olwidget.js"></script> <script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAWGazslnMSgtzbIMfXLHIgBS5ci6sQZUkD9hfwKAiXgiJK2N7uxTWbLDcob2apHjRnK6OlA7hReqQaA"></script> <script type="text/javascript" src="/media/js/core.js"></script> <script type="text/javascript" src="/media/js/admin/RelatedObjectLookups.js"></script> <script type="text/javascript" src="/media/js/getElementsBySelector.js"></script> <script type="text/javascript" src="/media/js/actions.js"></script> which fails because DateTimeShortcuts requires addEvent which is defined in core.js -- Ticket URL: <http://code.djangoproject.com/ticket/12265> Django <http://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 post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.