Friday, December 1, 2017

Problem when trying to display field name on admin panel

Hello.
It gives error when I click on my app name in admin panel because of the "ratings" field. Without it, it loads fine. 
Error: 

KeyError at /admin/photo/photo/

'manager'

Error during template rendering

In template C:\Users\Root\Desktop\PhotashBackend\sanal\lib\site-packages\django\contrib\admin\templates\admin\change_list.html, error at line 82

The mentioned line is this  {% result_list cl %}


My model:

class Photo(models.Model):
photo = models.IntegerField(primary_key=True, verbose_name='Photo id')
photoItself = ResizedImageField(upload_to='photopool/', default='blog/static/manzara.jpg', verbose_name='Photo')
...
...
...
...
ratings = GenericRelation(Rating, related_query_name='photos')


And this is my admin.py:

from django.contrib import admin
from .models import Photo

class PhotoAdmin(admin.ModelAdmin):
list_display = ['photo', 'contest', 'ownername', 'howmany_votes_gotten', 'ratings']
list_display_links = ['photo']
list_filter = ['contest']
search_fields = ['ownername']

class Meta:
model = Photo


admin.site.register(Photo, PhotoAdmin)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/366ad944-6aac-4bc0-9241-a54dc774b034%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment