The field is simple:
timestamp=DateTimeField(primary_key=True)
The timestamps are displayed in this format: "June 12, 2021, 2:40 a.m.".
When I try to delete an entry, it gives me this exception:
Traceback (most recent call last):
File "/home/pooh/venv39/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/contrib/admin/options.py", line 616, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 232, in inner
return view(request, *args, **kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1739, in changelist_view
response = self.response_action(request, queryset=cl.get_queryset(request))
File "/home/pooh/venv39/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1406, in response_action
queryset = queryset.filter(pk__in=selected)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/query.py", line 941, in filter
return self._filter_or_exclude(False, args, kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
clone._filter_or_exclude_inplace(negate, args, kwargs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1393, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1412, in _add_q
child_clause, needed_inner = self.build_filter(
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1347, in build_filter
condition = self.build_lookup(lookups, col, value)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1193, in build_lookup
lookup = lookup_class(lhs, rhs)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/lookups.py", line 25, in __init__
self.rhs = self.get_prep_lookup()
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/lookups.py", line 240, in get_prep_lookup
rhs_value = self.lhs.output_field.get_prep_value(rhs_value)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1406, in get_prep_value
value = super().get_prep_value(value)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1266, in get_prep_value
return self.to_python(value)
File "/home/pooh/venv39/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1388, in to_python
raise exceptions.ValidationError(
django.core.exceptions.ValidationError: ['“June 12, 2021, 2:40 a.m.” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']
[17/Nov/2021 20:04:01] "POST /admin/micogui/transaction/ HTTP/1.1" 500 162676
I've investigated, it's because of the intermediate delete confirmation dialog. When invoking the "delete selected items" action it sends the request with all the entries in correct format (YYYY-MM-DD...), but then after confirmation dialog I see this in the delete_selected_confirmation.html:
<input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}">
After this timestamp is being sent in the format I see on page (June 12, ...) and the code hiccups.
It will require someone from django developers to understand how to fix it best, I'm afraid.
Related
I have problem with google auth. Steps to reproduce problem:
Register password account
Try to log in with google auth
Get 500 answer
Traceback:
Internal Server Error: /api/v1/auth/google/
Traceback (most recent call last):
File "/home/andrew/.local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/andrew/.local/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/django/views/decorators/debug.py", line 89, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/dj_rest_auth/views.py", line 54, in dispatch
return super().dispatch(*args, **kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/home/andrew/.local/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/andrew/.local/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/home/andrew/.local/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/home/andrew/Documents/pets_backend/project/api_v1/views/social.py", line 77, in post
response = super().post(request, *args, **kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/dj_rest_auth/views.py", line 125, in post
self.serializer.is_valid(raise_exception=True)
File "/home/andrew/.local/lib/python3.10/site-packages/rest_framework/serializers.py", line 220, in is_valid
self._validated_data = self.run_validation(self.initial_data)
File "/home/andrew/.local/lib/python3.10/site-packages/rest_framework/serializers.py", line 422, in run_validation
value = self.validate(value)
File "/home/andrew/.local/lib/python3.10/site-packages/dj_rest_auth/registration/serializers.py", line 151, in validate
complete_social_login(request, login)
File "/home/andrew/.local/lib/python3.10/site-packages/allauth/socialaccount/helpers.py", line 151, in complete_social_login
return _complete_social_login(request, sociallogin)
File "/home/andrew/.local/lib/python3.10/site-packages/allauth/socialaccount/helpers.py", line 172, in _complete_social_login
ret = _process_signup(request, sociallogin)
File "/home/andrew/.local/lib/python3.10/site-packages/allauth/socialaccount/helpers.py", line 22, in _process_signup
url = reverse("socialaccount_signup")
File "/home/andrew/.local/lib/python3.10/site-packages/django/urls/base.py", line 86, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
File "/home/andrew/.local/lib/python3.10/site-packages/django/urls/resolvers.py", line 694, in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'socialaccount_signup' not found. 'socialaccount_signup' is not a valid view function or pa
ttern name.
"POST /api/v1/auth/google/ HTTP/1.1" 500 184486
I added to configs
SOCIALACCOUNT_EMAIL_VERIFICATION = "none"
SOCIALACCOUNT_EMAIL_REQUIRED = False
SOCIALACCOUNT_QUERY_EMAIL = False
but not worked.
I am calling the following code from a django view (taken from https://docs.celeryq.dev/en/latest/userguide/workers.html#inspecting-workers):
inspect_report = celery_app.control.inspect()
tasks_active = inspect_report.active()
It works correctly the first time but when I refresh the page i get a ValueError: not enough values to unpack (expected 2, got 1)
Stacktrace:
File "/venv_path/python3.9/site-packages/asgiref/sync.py", line 458, in thread_handler
raise exc_info[1]
File "/venv_path/python3.9/site-packages/django/core/handlers/exception.py", line 38, in inner
response = await get_response(request)
File "/venv_path/python3.9/site-packages/django/core/handlers/base.py", line 233, in _get_response_async
response = await wrapped_callback(request, *callback_args, **callback_kwargs)
File "/venv_path/python3.9/site-packages/asgiref/sync.py", line 423, in __call__
ret = await asyncio.wait_for(future, timeout=None)
File "/home/benjamin/.pyenv/versions/3.9.6/lib/python3.9/asyncio/tasks.py", line 442, in wait_for
return await fut
File "/venv_path/python3.9/site-packages/asgiref/current_thread_executor.py", line 22, in run
result = self.fn(*self.args, **self.kwargs)
File "/venv_path/python3.9/site-packages/asgiref/sync.py", line 462, in thread_handler
return func(*args, **kwargs)
File "/venv_path/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/venv_path/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/benjamin/project/administration/views.py", line 357, in dashboard
tasks_active = inspect_report.active()
File "/venv_path/python3.9/site-packages/celery/app/control.py", line 149, in active
return self._request('active', safe=safe)
File "/venv_path/python3.9/site-packages/celery/app/control.py", line 106, in _request
return self._prepare(self.app.control.broadcast(
File "/venv_path/python3.9/site-packages/celery/app/control.py", line 741, in broadcast
return self.mailbox(conn)._broadcast(
File "/venv_path/python3.9/site-packages/kombu/pidbox.py", line 344, in _broadcast
return self._collect(reply_ticket, limit=limit,
File "/venv_path/python3.9/site-packages/kombu/pidbox.py", line 386, in _collect
self.connection.drain_events(timeout=timeout)
File "/venv_path/python3.9/site-packages/kombu/connection.py", line 317, in drain_events
return self.transport.drain_events(self.connection, **kwargs)
File "/venv_path/python3.9/site-packages/kombu/transport/virtual/base.py", line 969, in drain_events
get(self._deliver, timeout=timeout)
File "/venv_path/python3.9/site-packages/kombu/transport/redis.py", line 526, in get
ret = self.handle_event(fileno, event)
File "/venv_path/python3.9/site-packages/kombu/transport/redis.py", line 508, in handle_event
return self.on_readable(fileno), self
File "/venv_path/python3.9/site-packages/kombu/transport/redis.py", line 504, in on_readable
chan.handlers[type]()
File "/venv_path/python3.9/site-packages/kombu/transport/redis.py", line 905, in _brpop_read
dest, item = dest__item
ValueError: not enough values to unpack (expected 2, got 1)
3rd page call is OK, 4th give same error, etc.
Why does it fail every 2 requests?
The idea
To make the code a bit more understandable, I will first explain what my code (from which the problem probably comes) is supposed to do in the first place: I save reports in my model. I give these reports their own ID or numbering, because this is absolutely necessary.This ID shall be structured as follows:
<year><ascending number with leading zeros>
Example: 2021001, 2021002, ..., 2022001
The code
I have developed the following code for this purpose. Since the value is to be calculated automatically, I use the #property decorator. To be able to use the ID later more easily as a field and simply for my REST Api, I use the computed_property package.
Extract from models.py:
einsatznummer = ComputedTextField(blank=True, compute_from="einsatznummer_calc")
#property
def einsatznummer_calc(self):
year_einsatz = self.einsatz_start.strftime('%Y')
last_number = EinsatzPublic.objects.filter(einsatznummer__isnull=False, einsatz_start__year=year_einsatz).values_list('einsatznummer', flat=True)
if EinsatzPublic.objects.filter('einsatznummer').count() >= 1:
# if last_number == None :
# last_number = 0
if last_number[:-1] != year_einsatz:
last_number = 0
einsatznummer_gen = year_einsatz + (last_number + 1)
return einsatznummer_gen
else:
einsatznummer_gen = (year_einsatz + 1)
return einsatznummer_gen
When I tried to add a record to the model (DeploymentPublic) I got the following error which I can't solve.
Internal Server Error: /super/einsatzverwaltung/einsatzpublic/add/
Traceback (most recent call last):
(...)
ValueError: too many values to unpack (expected 2)
Then I tried to see if it was the ComputedTextField and temporarily removed it. As a result, I got the following error when creating a new record:
Internal Server Error: /super/einsatzverwaltung/einsatzpublic/add/
File
(...)
"C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\db\models\base.py",
line 828, in _save_table
raise ValueError("Cannot force an update in save()
with no primary key.") ValueError: Cannot force an update in save() with no primary key.
Maybe someone here can help me because I'm really at a loss and can't find the issue.
Error Code after fixing Error 1
Commented ComputedTextField out:
Internal Server Error: /super/einsatzverwaltung/einsatzpublic/add/
Traceback (most recent call last):
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 616, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\sites.py", line 232, in inner
return view(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1657, in add_view
return self.changeform_view(request, None, form_url, extra_context)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1540, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1586, in _changeform_view
self.save_model(request, new_object, form, not add)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1099, in save_model
obj.save()
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\db\models\base.py", line 726, in save
self.save_base(using=using, force_insert=force_insert,
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\db\models\base.py", line 763, in save_base
updated = self._save_table(
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\db\models\base.py", line 828, in _save_table
raise ValueError("Cannot force an update in save() with no primary key.")
ValueError: Cannot force an update in save() with no primary key.
[09/Jun/2021 18:35:45] "POST /super/einsatzverwaltung/einsatzpublic/add/ HTTP/1.1" 500 133976
With the ComputedText Field
Traceback (most recent call last):
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 616, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\sites.py", line 232, in inner
return view(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1657, in add_view
return self.changeform_view(request, None, form_url, extra_context)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1540, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1586, in _changeform_view
self.save_model(request, new_object, form, not add)
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\contrib\admin\options.py", line 1099, in save_model
obj.save()
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\db\models\base.py", line 726, in save
self.save_base(using=using, force_insert=force_insert,
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\db\models\base.py", line 750, in save_base
pre_save.send(
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\dispatch\dispatcher.py", line 180, in send
return [
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\django\dispatch\dispatcher.py", line 181, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\computed_property\fields.py", line 61, in resolve_computed_field
setattr(instance, self.get_attname(), self.calculate_value(instance))
File "C:\Users\marce\.virtualenvs\backend-ZTyOc35O\lib\site-packages\computed_property\fields.py", line 73, in calculate_value
instance_compute_object = getattr(instance, self.compute_from)
File "D:\04-Dev\Projekt\feuerwehr-ensdorf-webapp-cms\backend\einsatzverwaltung\models.py", line 141, in einsatznummer_calc
if last_number >= 1:
TypeError: '>=' not supported between instances of 'QuerySet' and 'int'
[09/Jun/2021 18:44:05] "POST /super/einsatzverwaltung/einsatzpublic/add/ HTTP/1.1" 500 150838
EinsatzPublic.objects.filter('einsatznummer').count() >= 1 makes no sense, since you can not filter with a string.
You should work with a (or multiple) Q objects, and/or parameters like you did when filtering the line above. If it is the same as last_number, you can reuse this queryset:
#property
def einsatznummer_calc(self):
year_einsatz = self.einsatz_start.strftime('%Y')
last_number = EinsatzPublic.objects.filter(einsatznummer__isnull=False, einsatz_start__year=year_einsatz).values_list('einsatznummer', flat=True)
if last_number:
# if last_number == None :
# last_number = 0
if last_number[:-1] != year_einsatz:
last_number = 0
einsatznummer_gen = year_einsatz + (last_number + 1)
return einsatznummer_gen
else:
einsatznummer_gen = (year_einsatz + 1)
return einsatznummer_gen
I'm using Django-CMS and I created some custom plugins that I use in several pages but in one of the pages I can't publish nor I can't copy plugins that are nested and gives me the same error in both situations:
Internal Server Error: /en/admin/cms/page/copy-plugins/
Traceback (most recent call last):
File "lib\site-packages\django\core\handlers\base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "lib\site-packages\django\core\handlers\base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "lib\site-packages\django\utils\decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "lib\site-packages\django\views\decorators\cache.py", line 57, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "lib\site-packages\django\contrib\admin\sites.py", line 244, in inner
return view(request, *args, **kwargs)
File "lib\site-packages\django\utils\decorators.py", line 67, in _wrapper
return bound_func(*args, **kwargs)
File "lib\site-packages\django\views\decorators\http.py", line 42, in inner
return func(request, *args, **kwargs)
File "lib\site-packages\django\utils\decorators.py", line 63, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "lib\site-packages\django\views\decorators\clickjacking.py", line 39, in wrapped_view
resp = view_func(*args, **kwargs)
File "lib\site-packages\django\utils\decorators.py", line 184, in inner
return func(*args, **kwargs)
File "lib\site-packages\cms\admin\placeholderadmin.py", line 363, in copy_plugins
plugins, target_placeholder, target_language, target_plugin_id)
File "lib\site-packages\cms\utils\copy_plugins.py", line 24, in copy_plugins_to
old_parent_cache, no_signals))
File "lib\site-packages\cms\models\pluginmodel.py", line 319, in copy_plugin
new_plugin.save()
File "lib\site-packages\cms\models\pluginmodel.py", line 240, in save
self.parent.add_child(instance=self)
File "lib\site-packages\treebeard\mp_tree.py", line 970, in add_child
return MP_AddChildHandler(self, **kwargs).process()
File "lib\site-packages\treebeard\mp_tree.py", line 361, in process
newobj.save()
File "lib\site-packages\cms\models\pluginmodel.py", line 248, in save
super(CMSPlugin, self).save(*args, **kwargs)
File "lib\site-packages\django\db\models\base.py", line 708, in save
force_update=force_update, update_fields=update_fields)
File "lib\site-packages\django\db\models\base.py", line 736, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "lib\site-packages\django\db\models\base.py", line 820, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "lib\site-packages\django\db\models\base.py", line 859, in _do_insert
using=using, raw=raw)
File "lib\site-packages\django\db\models\manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "lib\site-packages\django\db\models\query.py", line 1039, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "lib\site-packages\django\db\models\sql\compiler.py", line 1060, in execute_sql
cursor.execute(sql, params)
File "lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "lib\site-packages\django\db\backends\mysql\base.py", line 117, in execute
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
File "lib\site-packages\django\db\backends\mysql\base.py", line 112, in execute
return self.cursor.execute(query, args)
File "build\bdist.win-amd64\egg\MySQLdb\cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "build\bdist.win-amd64\egg\MySQLdb\connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
IntegrityError: (1048, "Column 'position' cannot be null")
I've checked in my database and in the cms_cmsplugintable exists a column named position but there's no entry with position null. Do you have any idea what's going on?
I am creating the dynamic queryset using Q
while i am printing
build_query[:-1]
i am getting output
Q(owner_id=1)|Q(assigned_to=1)
but when using this in to
consultants = Consultant.objects.filter(*build_query[:-1])
getting an error too many values to unpack
i tried it with ** and without * still its not working.
when i check the type of
print type(build_query[:-1])
i am getting string type. Is the a main cause?
Traceback
Internal Server Error: /api/consultants/my_consultants/
Traceback (most recent call last):
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/rest_framework/viewsets.py", line 85, in view
return self.dispatch(request, *args, **kwargs)
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/rest_framework/views.py", line 451, in dispatch
response = self.handle_exception(exc)
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/rest_framework/views.py", line 448, in dispatch
response = handler(request, *args, **kwargs)
File "/home/jagmeet/consultadd_workspace/devenv/ckiller/consultants/api.py", line 170, in my_consultants
consultants = Consultant.objects.filter(*build_query[:-1])
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
Q(owner_id=1)|Q(assigned_to=1)
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/query.py", line 691, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/query.py", line 709, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/home/jagmeet/consultadd_workspace/devenv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1331, in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases)
consultants = Consultant.objects.filter(*build_query[:-1])
Did u try:
Consultant.objects.filter(*[build_query[:-1],])
args should be a list