Python3 Integrated Installation Xadmin
1: Create a virtual environment
C:\users\adminstrator>mkvirtualenv-p C:\Python34\python.exe Mydjango
If the hint is not found, you can directly mkvirtualenv Mydjango
After the creation is successful, the terminal will display this:
(Mydjango) C:\Users\Adminstrator
2: Installation depends on, if not to install dependencies, when using Xadmin will be various error. The dependency list is as follows:
Djangopillowdjango-crispy-forms~=1.6. 0django-import-export>=0.5.1Django -reversion~=2.0. 0django-formtoolsfuture==0.15.2httplib2==0.9.2six==1.10 . 0django-pure-pagination==0.3. 0django-simple- CAPTCHAMYSQLCLIENTREQUESTSXLRDXLSXWRITERXLWT
Use Pip Install-i https://pypi.douban.com/simple Django Pillow. To install
Using a watercress source will be faster than a foreign download
The following error may occur in the installation of mysqlclient (this problem is primarily in the Windows environment):
Error:microsoft Visual C + + 10.0 is required. Get it with "Microsoft Windows S
DK 7.1 ": www.microsoft.com/download/details.aspx?id=8279
----------------------------------------
Failed Building Wheel for Mysqlclient
Workaround: Go to this path to download mysqlclient:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
Download the corresponding version according to the situation of each individual operating system, then place it under the installation path and install it. For example:
(Mydjango) C:\users\ccd>pip Install MYSQLCLIENT-1.3.12-CP34-CP34M-WIN32.WHL
Processing C:\USERS\CCD\MYSQLCLIENT-1.3.12-CP34-CP34M-WIN32.WHL
Installing collected Packages:mysqlclient
Successfully installed mysqlclient-1.3.12
After the installation is complete, you can use pip install under CMD to see if the installation is complete.
3: Create a new Django project named Djangolearn
We install xadmin through the source code, download the Xadmin source code, and then create a new folder in the project Extra_apps
Drag the Xadmin source folder directly to Extra_apps, because the new project defaults to admin, so we need to make some changes
The Installed_apps additions in the settings.py folder in the project Xadmin and crispy_forms,crispy-forms can be used to
Render our form.
Then modify our URL and need to right-click Extra_apps to set this path to source Root:mark Directory as source Root
Import= [Path ('xadmin/', Xadmin.site.urls),]
If the Django project does not have a configuration database, the database configuration is required and the database is configured as follows:
DATABASES = {'default': {'ENGINE':'Django.db.backends.mysql','NAME':"Testdjango",'USER':"Root",'PASSWORD':"123456",'HOST':"127.0.0.1",}}
Then click on the Tools column in the project
Select Run manage.py Task
Enter commands makemigrations and migrate for database creation:
If such an error occurs:
Failed to get real commands on module"Djangolearn": Python process died with code 1: Traceback (most recent): File"D:\Program files\jetbrains\pycharm 2017.2.3\helpers\pycharm\_jb_manage_tasks_provider.py", line 25,inch<module>django.setup () File"C:\Users\CCD\Envs\MyDjango\lib\site-packages\django\__init__.py", line 27,inchsetupapps.populate (settings. Installed_apps) File"C:\Users\CCD\Envs\MyDjango\lib\site-packages\django\apps\registry.py", line 85,inchPopulateapp_config=appconfig.create (entry) File"C:\Users\CCD\Envs\MyDjango\lib\site-packages\django\apps\config.py", Line 90,inchCreatemodule=import_module (entry) File"C:\Users\CCD\Envs\MyDjango\lib\importlib\__init__.py", line 109,inchImport_modulereturn_bootstrap._gcd_import (name[level:], package, level) File"<frozen importlib._bootstrap>", Line 2254,inch_gcd_importfile"<frozen importlib._bootstrap>", Line 2237,inch_find_and_loadfile"<frozen importlib._bootstrap>", Line 2224,inch_find_and_load_unlockedimporterror:no module named'Xadmin'
You need to add the following code to the setting:
Import Sys
Sys.path.insert (0,os.path.join (Base_dir, ' Extra_apps ')) so that the Extra_apps path can be placed in the path of the current module scan
To log in to Xadmin, you need to first create a user in Pycharm
Createsuperuser[email protected]>Createsuperuser"D:\Program files\jetbrains\pycharm 2017.2.3\bin\runnerw.exe"C:\Users\CCD\Envs\MyDjango\Scripts\python.exe"D:\Program files\jetbrains\pycharm 2017.2.3\helpers\pycharm\django_manage.py"Createsuperuser f:/pycharmprojects/djangolearnusername (leave blank to use'CCD'): Ccdemail address:123456789@qq. Comwarning:password input may echoed. Password:ABC123456Warning:Password input may echoed. Password (again): Abc123456superuser created successfully. Following files were affectedprocess finished with exit code 0
Then visit http://127.0.0.1:8000/xadmin/
You can log on to the backend management system.
Python3 Integrated Installation Xadmin