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.
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.
You can't register a tabular admin class directly with the admin site. TabularAdmin is a subclass of InlineAdmin, and as such is only for use in the inlines
attribute of a full ModelAdmin.
I have the same problem like this.
You can try this to fix this problem:
class CPUInline(admin.TabularInline):
model = CPU
class CPUAdmin(admin.ModelAdmin):
inlines = [CPUInline]
admin.site.register(CPU, CPUAdmin)
This error happens to be coming from the part you expect least.
You can’t register InlineModelAdmin or it’s subclasses in the admin site. You can only use them in attributes of ModelAdmin classes.
This is the the most common cause of such error and it’s quite difficult to spot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With