Hey everyone, I wrote this form to displays all my Dog
models but it seems there’s no longer an object method.
def list_dogs(request):
dogs = Dog.objects.all() # <---
context = {"dogs": dogs}
return render(request, f"{settings.BASE_DIR}/templates/index.html", context)
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/dogs/list
Django Version: 5.1.3
Python Version: 3.11.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dogs']
Installed Middleware:
['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']
Traceback (most recent call last):
File "/home/redhawk/code/upload-exaple/.venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/home/redhawk/code/upload-exaple/.venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/redhawk/code/upload-exaple/src/dogs/views.py", line 21, in list_dogs
dogs = Dog.object.all()
^^^^^^^^^^
Exception Type: AttributeError at /dogs/list
Exception Value: type object 'Dog' has no attribute 'object'