C:\Users\Dell\PycharmProjects\pyshop>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run
self._target(*self._args, self._kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, *kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(args, kwargs)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django__init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\apps.py", line 24, in ready
self.module.autodiscover()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\init.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\importlib\init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\Users\Dell\PycharmProjects\pyshop\products\admin.py", line 9, in
admin.sites.register(Products, ProductAdmin)
AttributeError: module 'django.contrib.admin.sites' has no attribute 'register'
--admin.py--
from django.contrib import admin
from products.models import Products
class ProductAdmin(admin.ModelAdmin):
list_display = ('name', 'price', 'stock')
C:\Users\Dell\PycharmProjects\pyshop>python manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner self.run() File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run self._target(*self._args, self._kwargs) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, *kwargs) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception raise _exception[1] File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management__init__.py", line 337, in execute autoreload.check_errors(django.setup)() File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper fn(args, kwargs) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django__init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 122, in populate app_config.ready() File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\apps.py", line 24, in ready self.module.autodiscover() File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\init.py", line 26, in autodiscover autodiscover_modules('admin', register_to=site) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules import_module('%s.%s' % (app_config.name, module_to_search)) File "C:\Users\Dell\AppData\Local\Programs\Python\Python37\lib\importlib\init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\Users\Dell\PycharmProjects\pyshop\products\admin.py", line 9, in
admin.sites.register(Products, ProductAdmin)
AttributeError: module 'django.contrib.admin.sites' has no attribute 'register'
--admin.py--
from django.contrib import admin from products.models import Products
class ProductAdmin(admin.ModelAdmin): list_display = ('name', 'price', 'stock')
admin.sites.register(Products, ProductAdmin)