here is the relevant view
class GDBUpdateView(LoginRequiredMixin, edit.FormView):
form_class = UploadGDB
template_name = 'db_update.html'
success_url = reverse_lazy('g_list')
def get(self, request):
form = self.form_class()
return render(request, self.template_name, {'form': form})
def post(self, request):
form = self.form_class(request.POST, request.FILES)
if form.is_valid():
print("json submitted successfully!")
parse_out_data_into_g(request.FILES['jdoc'])
return redirect(success_url)
else:
return render(request, self.template_name, {'form': form})
def form_valid(self, form):
return super().form_valid(form)
def parse_out_data_into_g(json_file):
data = json.load(json_file)
for item in data:
if not GMod.objects.filter(title=item['title_listing']):
gmod = GMod(
title = item['title_listing'],
summary = item['overview'],
genre_tags = item['game_tags'],
ref_url = item['url'],
)
gmod.save()
else:
continue
and here is the trackback
Environment:
Request Method: POST
Request URL: http://localhost:8000/dbupdate/
Django Version: 5.1.1
Python Version: 3.12.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'games',
'news',
'reviews',
'comm',
'peeps',
'apis',
'rest_framework',
'corsheaders',
'martor',
'compressor',
'allauth_ui',
'allauth',
'allauth.account',
'allauth.socialaccount',
'widget_tweaks',
'slippers',
'crispy_forms',
'crispy_tailwind',
'tagulous',
'imagekit']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'allauth.account.middleware.AccountMiddleware']
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/related_descriptors.py", line 239, in __get__
rel_obj = self.field.get_cached_value(instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/mixins.py", line 37, in get_cached_value
return instance._state.fields_cache[self.cache_name]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
During handling of the above exception ('engine'), another exception occurred:
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/__init__.py", line 2123, in get_prep_value
return int(value)
^^^^^^^^^^
The above exception (invalid literal for int() with base 10: 'Other') was the direct cause of the following exception:
File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/contrib/auth/mixins.py", line 73, in dispatch
return super().dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/games/views.py", line 72, in post
parse_out_data_into_g(request.FILES['jdoc'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/games/views.py", line 102, in parse_out_data_into_g
gmod.save()
^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 891, in save
self.save_base(
^
File "/usr/local/lib/python3.12/site-packages/django/db/models/base.py", line 977, in save_base
pre_save.send(
^
File "/usr/local/lib/python3.12/site-packages/django/dispatch/dispatcher.py", line 189, in send
response = receiver(signal=self, sender=sender, **named)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tagulous/signals/post.py", line 22, in __call__
manager = descriptor.get_manager(instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tagulous/models/descriptors.py", line 91, in get_manager
manager = SingleTagManager(self, instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tagulous/models/managers.py", line 46, in __init__
self.tag_cache = self.get_actual()
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tagulous/models/managers.py", line 78, in get_actual
value = self.descriptor.descriptor.__get__(self.instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/related_descriptors.py", line 257, in __get__
rel_obj = self.get_object(instance)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/related_descriptors.py", line 220, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 635, in get
clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1476, in filter
return self._filter_or_exclude(False, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1494, in _filter_or_exclude
clone._filter_or_exclude_inplace(negate, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/query.py", line 1501, in _filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1609, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1641, in _add_q
child_clause, needed_inner = self.build_filter(
File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1468, in build_filter
return self._add_q(
File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1641, in _add_q
child_clause, needed_inner = self.build_filter(
File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1555, in build_filter
condition = self.build_lookup(lookups, col, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/sql/query.py", line 1385, in build_lookup
lookup = lookup_class(lhs, rhs)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/lookups.py", line 30, in __init__
self.rhs = self.get_prep_lookup()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/lookups.py", line 369, in get_prep_lookup
return super().get_prep_lookup()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/lookups.py", line 88, in get_prep_lookup
return self.lhs.output_field.get_prep_value(self.rhs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/__init__.py", line 2125, in get_prep_value
raise e.__class__(
^^^^^^^^
Exception Type: ValueError at /dbupdate/
Exception Value: Field 'id' expected a number but got 'Other'.