2017-03-02 17 views
0
# settings.py 

MEDIA_URL = '/media/' 
MEDIA_ROOT =os.path.join(BASE_DIR,'media/') 


#urls.py outer 

from django.conf.urls import url, include 
from django.contrib import admin 
from django.conf import settings 
from django.conf.urls.static import static 

urlpatterns = [ 
    url(r'^admin/', admin.site.urls), 
    url(r'', include('webapp.urls')), 

] 

if settings.DEBUG: 
    urlpatterns += static(settings.MEDIA_URL, 
          document_root = settings.MEDIA_ROOT) 

#admin.py of webapp 
from django.contrib import admin 
from .models import Profile 


class ProfileAdmin(admin.ModelAdmin): 
    list_display = ['user', 'birthday', 'photo'] 

admin.site.register(Profile, ProfileAdmin) 

#models.py of webapp 

class Profile(models.Model): 
    user = models.OneToOneField(settings.AUTH_USER_MODEL) 
    birthday = models.DateField() 
    photo=models.ImageField(upload_to='users/%Y/%m/%d',blank=True) 

    def __str__(self): 
     return 'Profile for user {}'.format(self.user.username) 

フル・エラーのトレースバックはジャンゴ追加し、管理部門のエラー

Traceback (most recent call last): 
    File "./manage.py", line 8, in <module> 
    from django.core.management import execute_from_command_line 
    File "/home/peterkim/PycharmProjects/bravepeach_web/.venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 13, in <module> 
    from django.core.management.base import (
    File "/home/peterkim/PycharmProjects/bravepeach_web/.venv/lib/python3.5/site-packages/django/core/management/base.py", line 13, in <module> 
    from django.core import checks 
    File "/home/peterkim/PycharmProjects/bravepeach_web/.venv/lib/python3.5/site-packages/django/core/checks/__init__.py", line 11, in <module> 
    import django.core.checks.caches # NOQA isort:skip 
    File "/home/peterkim/PycharmProjects/bravepeach_web/.venv/lib/python3.5/site-packages/django/core/checks/caches.py", line 14, in <module> 
    @register(Tags.caches) 
TypeError: register() missing 1 required positional argument: 'kwargs' 

私が把握することはできません。助けてください。前もって感謝します!

+0

を各モデルを登録してみますProfile''をインポートし、それが助けかどうwebapp.modelsから完全修飾輸入 ''に行うことができますしてみてください。 –

答えて

0

は別途

admin.site.register(Profile) 
admin.site.register(ProfileAdmin) 
+0

'admin.site.register(ProfileAdmin)'を行うのは意味がありません - 'ProfileAdmin'はモデルではなく、モデル管理クラスです。 – Alasdair

関連する問題