TypeError: Значение '[UUID('8b3e3b85-418e-46ef-b7c7-6d1a7fc6b66a')]' не является верным UUID-ом.
Traceback (most recent call last):
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\exception.py", line 39, in inner
response = get_response(request)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\reversion\revisions.py", line 296, in do_revision_context
return func(*args, **kwargs)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\query.py", line 660, in exists
return self.query.has_results(using=self.db)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\sql\query.py", line 494, in has_results
return compiler.has_results()
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\sql\compiler.py", line 806, in has_results
return bool(self.execute_sql(SINGLE))
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\sql\compiler.py", line 824, in execute_sql
sql, params = self.as_sql()
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sql_server\pyodbc\compiler.py", line 91, in as_sql
where, w_params = self.compile(self.where) if self.where is not None else ("", [])
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sql_server\pyodbc\compiler.py", line 213, in compile
return super(SQLCompiler, self).compile(node, select_format)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\sql\compiler.py", line 353, in compile
sql, params = node.as_sql(self, self.connection)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\sql\where.py", line 79, in as_sql
sql, params = compiler.compile(child)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sql_server\pyodbc\compiler.py", line 213, in compile
return super(SQLCompiler, self).compile(node, select_format)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\sql\compiler.py", line 353, in compile
sql, params = node.as_sql(self, self.connection)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\fields\related_lookups.py", line 115, in as_sql
return super(RelatedLookupMixin, self).as_sql(compiler, connection)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\lookups.py", line 156, in as_sql
rhs_sql, rhs_params = self.process_rhs(compiler, connection)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\lookups.py", line 92, in process_rhs
return self.get_db_prep_lookup(value, connection)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\lookups.py", line 182, in get_db_prep_lookup
[get_db_prep_value(value, connection, prepared=True)]
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\fields\related.py", line 912, in get_db_prep_value
return self.target_field.get_db_prep_value(value, connection, prepared)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\models\fields\__init__.py", line 2373, in get_db_prep_value
raise TypeError(self.error_messages['invalid'] % {'value': value})
TypeError: Значение '[<Function: B.2.2: Наименование функции 9>]' не является верным UUID-ом.
def clean_function(self):
data = self.cleaned_data['function']
return data
class Requirement(models.Model):
name = models.CharField(_('Name'), max_length=250)
function = models.ManyToManyField("Function")
class RequirementForm(forms.ModelForm):
class Meta:
model = Requirement
fields = ('name', 'function')
widgets={'function': ???}
function= requirement_form.cleaned_data['function']
programs = requirement_form.cleaned_data['programs']
requirement= requirement_form.save(commit=False)
requirement.function.add(function)
for program in programs:
requirement.program.add(program)
groups = Group.objects.all()
for group in groups:
tasks = Task.objects.filter(group=group)
for task in tasks:
function = Function.objects.filter(task=task)
<form method="post" action="">
{% for group in groups %}
{% for task in group.task_set.all %}
{% for function in task.function_set.all %}
<p><input type="checkbox" name="function-{{ forloop.counter }}" value="{{ function }}"><span>{{ function }}</span></p>
{% endfor %}
{% endfor %}
{% endfor %}
<input type="submit" value="Отправить">
</form>
function= requirement_form.cleaned_data['function']
requirement= requirement_form.save(commit=False)
requirement.function.add(function)
<script src="{% static 'django_select2/django_select2.js' %}"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css">
$('#id_company').djangoSelect2({multiple: true});
в ajax в beforeSend, думал заработает, но те места где объявил {{ product_form.media.css }} и {{ product_form.media.js }} пусты. Проверял html в браузере. Тогда я решил в ручную указать эти файлы и добавил следующее, но виджет Select2MultipleWidget так и не появился. Что можете еще посоветовать?<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css">
<script src="{% static 'django_select2/django_select2.js' %}"></script>
Uncaught TypeError: $(...).djangoSelect2 is not a function at 127.0.0.1/:131