Cannot define model in django -


i trying build first django app using common posts test. unfortunately server keeps returning errors such postmodel admin not defined. have tried migrating new changes doesnt work, modifying views, seems need explicitly define model. point me in right direction

heres how admin.py looks like

from django.contrib import admin  # register models here. .models import posts import views  admin.autodiscover()  class postsmodeladmin(admin.modeladmin):      list_display = ('title', 'updated', 'timestamp')     list_display_links = ('updated')     list_editable = ('title')     list_filter = ('updated', 'timestamp')     search_fields = ("title", 'content')       class meta:         model = posts      admin.site.register(posts)     admin.site.register(postmodeladmin) 

try this...

from .models import posts  django.contrib import admin  class postsmodeladmin(admin.modeladmin):      list_display = ('title', 'updated', 'timestamp')     list_display_links = ('updated')     list_editable = ('title')     list_filter = ('updated', 'timestamp')     search_fields = ("title", 'content')      class meta:         model = posts  admin.site.register(posts, postsmodeladmin) 

the register method takes model , class. error because you're passing class, never allowed unless it's passed after model.

also had typo in code. you're missing s when registering @ bottom.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -