Closed VoldemortGin closed 4 years ago
from django.urls import path, include import xadmin from xadmin.plugins import xversion xadmin .autodiscover() xversion.register_models()
urlpatterns =[ path('xadmin/', include(xadmin.site.urls)), ... ]
你的issue提醒了我应写清楚使用方式,我会尽快补充到README
谢谢及时的回复, 但是这样一来又报了个错: 没有"xadmin.plugins"这个包. 很奇怪的是源码里面有这个包, 而且我已经把父目录mark为source root了.
File "/home/linhan/PycharmProjects/DjangoBlog/DjangoBlog/urls.py", line 27, in
1.在django项目目录下建立extra_apps文件夹,将本仓库中xadmin文件夹拷贝到其中; 2.在django项目的settting.py 添加extra_apps目录:
import sys
...
sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
3.将'xadmin', 'crispy_forms', 'reversion', 'django.cong'添加到 INSTALLED_APPS
谢谢及时的回复, 但是这样一来又报了个错: 没有"xadmin.plugins"这个包. 很奇怪的是源码里面有这个包, 而且我已经把父目录mark为source root了.
File "/home/linhan/PycharmProjects/DjangoBlog/DjangoBlog/urls.py", line 27, in from xadmin.plugins import xversion ModuleNotFoundError: No module named 'xadmin.plugins'
另外,留意requirements
Thanks for your wonderful work! But after run the project it raises the error as above. Have you ever met this problem? 谢谢大神出色的工作. 但在运行项目后报了题目的错. 你有遇到过这个问题吗?
Exception in thread django-main-thread: Traceback (most recent call last): File "/home/linhan/anaconda3/envs/django3/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/home/linhan/anaconda3/envs/django3/lib/python3.7/threading.py", line 870, in run self._target(*self._args, *self._kwargs) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper fn(args, kwargs) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/core/management/base.py", line 395, in check include_deployment_checks=include_deployment_checks, File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/core/management/base.py", line 382, in _run_checks return checks.run_checks(kwargs) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/urls/resolvers.py", line 407, in check for pattern in self.url_patterns: File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/utils/functional.py", line 48, in get res = instance.dict[self.name] = self.func(instance) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/urls/resolvers.py", line 588, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/utils/functional.py", line 48, in get res = instance.dict[self.name] = self.func(instance) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/site-packages/django/urls/resolvers.py", line 581, in urlconf_module return import_module(self.urlconf_name) File "/home/linhan/anaconda3/envs/django3/lib/python3.7/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 "/home/linhan/PycharmProjects/DjangoBlog/DjangoBlog/urls.py", line 42, in
url(r'^xadmin/', xadmin.site.urls),
AttributeError: module 'xadmin' has no attribute 'site'