mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
[soc2009/admin-ui] Fix for a bug where saving m2m autocomplete fields was throwing an exception because there was a trailing comma. This also allows trailing commas on m2m raw_id_fields.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/admin-ui@11796 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2ea3b4e058
commit
60a77788be
@ -1,12 +1,9 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
<a href="{{ related_url }}{{ url }}" class="related-lookup" id="lookup_id_{{ name }}" onclick="return showRelatedObjectLookupPopup(this);">
|
<a href="{{ related_url }}{{ url }}" class="related-lookup" id="lookup_id_{{ name }}" onclick="return showRelatedObjectLookupPopup(this);">
|
||||||
<img src="{{ admin_media_prefix }}img/admin/selector-search.gif" width="16" height="16" alt="{% trans "Lookup" %}" />
|
<img src="{{ admin_media_prefix }}img/admin/selector-search.gif" width="16" height="16" alt="{% trans "Lookup" %}" />
|
||||||
</a>
|
</a>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Show lookup input
|
|
||||||
|
|
||||||
$('#id_{{ name }}').tokenInput("{{ search_path }}", {
|
$('#id_{{ name }}').tokenInput("{{ search_path }}", {
|
||||||
noResultsText: "No results found.",
|
noResultsText: "No results found.",
|
||||||
searchingText: "Searching..."
|
searchingText: "Searching..."
|
||||||
|
@ -246,8 +246,12 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
|
|||||||
|
|
||||||
def value_from_datadict(self, data, files, name):
|
def value_from_datadict(self, data, files, name):
|
||||||
value = data.get(name, None)
|
value = data.get(name, None)
|
||||||
|
|
||||||
|
if value and value[-1] == ',':
|
||||||
|
value = value[0:-1] # truncate trailing comma
|
||||||
|
|
||||||
if value and ',' in value:
|
if value and ',' in value:
|
||||||
return data[name].split(',')
|
return value.split(',')
|
||||||
if value:
|
if value:
|
||||||
return [value]
|
return [value]
|
||||||
return None
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user