My admin.TabularInline class returns exception: object has no attribute 'urls'
django, django-admin, django-urls, python
Solution
I had the same problem, Google led me to this thread and it didn't help. I solved it while I was about to post my question.
I don't even know if it's the same problem you had, but here it is:
class UserAnswerInline(admin.TabularInline):
model = UserAnswer
class UserQuestionAdmin(admin.ModelAdmin):
inlines = [UserAnswerInline]
admin.site.register(UserQuestion, UserAnswerInline)
The correct code:
class UserAnswerInline(admin.TabularInline):
model = UserAnswer
class UserQuestionAdmin(admin.ModelAdmin):
inlines = [UserAnswerInline]
admin.site.register(UserQuestion, UserQuestionAdmin)
Spot the difference? Yup, wrong class name. Took me 5 hours before I decided to create a new question here, then figured it out while explaining the problem.
Problem
So I've been Googling around and can't find a solution to my problem. I'm honestly quite puzzled, so thanks for taking a look. mysite/mysite/urls.py: ``` ... from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), ... ``` mysite/upgradelists/admin.py: ``` from django.contrib import admin from upgrademe.models import GPU, CPU class CPUAdmin(admin.TabularInline): model = CPU admin.site.register(CPU, CPUAdmin) ``` returned error: ``` AttributeError at /admin/ 'CPUAdmin' object has no attribute 'urls' ``` However, if I change admin.py to: ``` class CPUAdmin(admin.ModelAdmin): model = CPU ``` Then all is well. (although, irrelevant note: I believe the 'model = CPU' portion is redundant?) Any help/insight into this would be greatly appreciated. Google has left me stumped, and searches over StackOverflow have turned up nothing that I can see is related.