[BUG]: Projects can't be created in django admin
Closed this issue · 0 comments
c0rydoras commented
Description
Can't create projects in django admin
Steps to Reproduce
- open django admin
- click projects
- receive error
Expected Behavior
no error
Attachments
stacktrace
Environment:
Request Method: GET
Request URL: https://timed.local/admin/projects/project/add/
Django Version: 4.2.11
Python Version: 3.12.2
Installed Applications:
['timed.apps.TimedAdminConfig',
'django.contrib.humanize',
'multiselectfield.apps.MultiSelectFieldConfig',
'django.forms',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'hurricane',
'rest_framework',
'django_filters',
'djmoney.apps.MoneyConfig',
'mozilla_django_oidc',
'django_prometheus.apps.DjangoPrometheusConfig',
'corsheaders',
'nested_inline',
'timed.employment',
'timed.projects',
'timed.tracking',
'timed.reports',
'timed.redmine',
'timed.subscription',
'timed.notifications',
'django_extensions']
Installed Middleware:
['django_prometheus.middleware.PrometheusBeforeMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django_prometheus.middleware.PrometheusAfterMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware']
Traceback (most recent call last):
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/contrib/admin/options.py", line 688, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/views/decorators/cache.py", line 62, in _wrapper_view_func
response = view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/contrib/admin/sites.py", line 242, in inner
return view(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/nested_inline/admin.py", line 231, in add_view
formset = FormSet(instance=self.model(), prefix=prefix,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/timed/projects/admin.py", line 83, in __init__
if project.tasks.count() == 0:
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/django/db/models/fields/related_descriptors.py", line 718, in get_queryset
raise ValueError(
^
Exception Type: ValueError at /admin/projects/project/add/
Exception Value: 'Project' instance needs to have a primary key value before this relationship can be used.
Additional Context
No response
Version
v4.1.8
Required
- I have checked past issues to see if this bug has already been reported.