First look at the Admin interface (default, no settings)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/54/4B/wKioL1R-hzfBRFW_AAFeC6-wTqs701.jpg "title=" QQ picture 20141203114209.jpg "alt=" Wkiol1r-hzfbrfw_aafec6-wtqs701.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/54/4C/wKiom1R-hsyxJ8p-AAIlDobRqDc811.jpg "title=" 2.jpg " alt= "Wkiom1r-hsyxj8p-aaildobrqdc811.jpg"/>
All said Xadmin very hanging, hanging fried days, I took over to a piece, found that the fact is not so, I can only say that the most suitable for their own is the best, or their own, occasionally draw the next or can be ~ do not too addicted to these frameworks ~
Start ~
Xadmin Official Address http://xadmin.io/
Xadmin GitHub Address:https://github.com/sshwsfc/django-xadmin
Xadmin Document Description:https://xadmin.readthedocs.org/en/latest/index.html
Installation Instructions:
Django >=1.4
Django-crispy-forms >=1.2.3 (for xadmin crispy forms)
Django-reversion ([OPTION] for object history and reversion feature, please select Right version by your Django, see Chang Elog)
XLWT ([OPTION] for export xls files)
Xlsxwriter ([OPTION] for export xlsx files)
Personal advice:
Recommended to use django==1.5 version, high or low are bug, pro-Test
There is a bug, please submit, for xadmin contribution, of course, can fix the bug and submit, the best
Thank the Author ~
This article is just a simple installation, no real application involved, so~
Steps:
Create a virtual environment
[[email protected] ~]# pythonbrew venv create djcreating ' DJ ' Environment into/root/.pythonbrew/venvs/ Python-2.7.6already using interpreter/root/.pythonbrew/pythons/python-2.7.6/bin/pythonnew Python executable in/root /.pythonbrew/venvs/python-2.7.6/dj/bin/pythoninstalling Setuptools............done. Installing Pip...............done. [[email protected] ~]# pythonbrew venv use dj# Using ' DJ ' environment (found in/root/.pythonbrew/venvs/python-2.7.6) # to Leave an environment, simply run ' deactivate ' (DJ) [[email protected] ~]# ls
2, Installation django==1.5
(DJ) [[email protected] ~]# pip install ' django==1.5 ' downloading/unpacking django== 1.5 downloading django-1.5.tar.gz (8.0MB): 8.0mb downloaded running setup.py egg_info for package django warning: no previously-included files matching ' __pycache__ ' found under directory ' * ' warning: no previously-included files matching ' *.py[co] ' found under directory ' * ' installing collected packages: django Running setup.py install for django changing mode of build/scripts-2.7/django-admin.py from 644 to 755 warning: no previously-included files matching ' __pycache__ ' found under directory ' * ' warning: no previously-included files matching ' *.py[co] ' found under directory ' * ' changing mode of /root/.pythonbrew/venvs/python-2.7.6/dj/bin/django-admin.py to 755successfully installed djangocleaning up ... (DJ) [[email protected] ~]#
3. Create a project named blog
(DJ) [Email protected] ~]# django-admin.py startproject Blog (DJ) [[email protected] ~]# CD blog/(DJ) [[email protected] blog]# L Sblog manage.py (DJ) [[email protected] blog]# tree. ├──blog│├──__init__.py│├──settings.py│├──urls.py│└──wsgi.py└──manage.py1 directory, 5 files
4. Create an app called polls
(DJ) [email protected] blog]# python manage.py startapp Polls (DJ) [[email protected] blog]# lsblog manage.py Polls (DJ) [Email Protected] blog]# lltotal 12drwxr-xr-x 2 root root 4096 Dec 2 03:29 blog-rw-r--r--1 root root 247 Dec 2 03:28 manage. Pydrwxr-xr-x 2 root root 4096 Dec 2 03:29 polls
Installing Xadmin
(DJ) [[email protected] blog]# pip install django-xadmindownloading/unpacking django-xadmin downloading django-xadmin-0.5.0.tar.gz (1.0MB): 1.0mb downloaded Running setup.py egg_info for package django-xadmin Requirement already satisfied (use --upgrade to upgrade): setuptools in /root/.pythonbrew/venvs/python-2.7.6/dj/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg (from django-xadmin) requirement already satisfied (use --upgrade to Upgrade): django>=1.5 in /root/.pythonbrew/venvs/python-2.7.6/dj/lib/python2.7/site-packages (from django-xadmin) downloading/unpacking django-crispy-forms>=1.4.0 (from Django-xadmin) Downloading django-crispy-forms-1.4.0.tar.gz (47kB): 47kb Downloaded running setup.py egg_info for package django-crispy-forms warning: no files found matching ' * ' under directory ' Crispy_forms/static ' Installing collected packages: django-xadmin, django-crispy-forms Running setup.py install for django-xadmin running setup.py install for django-crispy-forms warning: no files found matching ' * ' under directory ' crispy_ Forms/static ' Successfully installed django-xadmin django-crispy-formscleaning up ... (DJ) [[email protected] blog]#
Adjust relevant parameters so that xadmin can be accessed normally
Add the polls that we just created in the settings file
databases = { ' Default ': { ' ENGINE ': ' django.db.backends.sqlite3 ', # add ' postgresql_psycopg2 ', ' MySQL ', ' sqlite3 ' or ' Oracle '. # Set database using sqlite3 ' NAME ': ' db.sqlite3 ', # Or path to database file if using sqlite3. # database name is db.sqlite3 # the following settings are not used with sqlite3: ' USER ': ', ' PASSWORD ': ', ' HOST ': ', # Empty for localhost through domain sockets or ' 127.0.0.1 ' for localhost through TCP. ' PORT ': ', # set to empty string for default. }}
Installed_apps = (' Django.contrib.auth ', ' django.contrib.contenttypes ', ' django.contrib.sessions ', ' django.co Ntrib.sites ', ' django.contrib.messages ', ' Django.contrib.staticfiles ', # uncomment the next line to enable the ad Min: # ' Django.contrib.admin ', # uncomment the next line to enable admin documentation: # ' Django.contrib.admindo CS ', ' polls ', # Add the line ' Xadmin ', # Add the line)
2. Set URLs file
from django.conf.urls import patterns, include, urlimport xadmin # Add the line Xadmin.autodiscover () # Add the line # uncomment the next two lines to enable the admin:# from django.contrib import admin# admin.autodiscover () from xadmin.plugins import xversion # Add the line xversion.registe_models () # Add the line urlpatterns = patterns (', # examples: # url (R ' ^$ ', ' blog.views.home ', name= ' home '), # url (R ' ^blog/', include (' Blog.foo.urls ')), # Uncomment the admin/doc line&nBsp;below to enable admin documentation: # url (R ' ^admin/doc/', include (' Django.contrib.admindocs.urls ')), # uncomment the next line to enable the admin: # url (R ' ^admin/', include (Admin.site.urls)), url (R ' ^xadmin/', include (xadmin.site.urls)), # Add this line)
3. Collect media information
(DJ) [email protected] blog]# python manage.py Collectstaticyou has requested to collect static files at the Destinationlocat Ion as specified in your settings. This would overwrite existing files! Is you sure your want to does this? Type ' yes ' to continue, or ' no ' to cancel:yes0 static files copied. (DJ) [Email protected] blog]#
4. Synchronizing the database
(DJ) [[email protected] blog]# python manage.py syncdbcreating tables Creating table auth_permissioncreating table auth_group_permissionscreating table auth_groupcreating table auth_user_groupscreating table auth_user_user_ Permissionscreating table auth_usercreating table django_content_typecreating table django_sessioncreating table django_siteyou just installed django ' S auth system, which means you don ' t have any superusers defined. would you like to create one now? (yes/no): yesUsername (leave blank to use ' root '): zhuimaemail address: password: password ( Again): superuser created successfully. INSTALLING CUSTOM SQL&NBSP, ..... INSTALLING INDEXES&NBSP, ..... Installed 0 object(s) from 0 fixture (s) (DJ) [[email protected] blog]#
5, open the service, the front desk login test
(DJ) [email protected] blog]# python manage.py runserver 0.0.0.0:80validating models ... 0 Errors Founddecember, 2014-20:59:40django version 1.5, using Settings ' blog.settings ' development server is running At Http://0.0.0.0:80/Quit the server with Control-c.
6. Error occurred
attributeerror at /xadmin/' module ' object has no attribute ' Atomic ' Request method:getrequest url:http://192.168.58.21/xadmin/django version:1.5exception type: Attributeerrorexception value: ' module ' object has no attribute ' Atomic ' Exception location:/root/.pythonbrew/venvs/python-2.7.6/dj/lib/python2.7/site-packages/reversion/admin.py in versionadmin, line 384python executable:/root/.pythonbrew/venvs/python-2.7.6/dj/bin/ pythonpython version:2.7.6python path:['/root/blog ', '/root/.pythonbrew/venvs/python-2.7.6/dj/ Lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg ', '/root/.pythonbrew/venvs/python-2.7.6/dj/lib/ Python2.7/site-packages/pip-1.2.1-py2.7.egg ', '/root/.pythonbrew/pythons/python-2.7.6/lib ', '/root/. Pythonbrew/venvs/python-2.7.6/dj/lib/python27.zip ', '/root/.pythonbrew/venvs/python-2.7.6/dj/lib/ python2.7 ', '/root/.pythonbreW/venvs/python-2.7.6/dj/lib/python2.7/plat-linux2 ', '/root/.pythonbrew/venvs/python-2.7.6/dj/lib/ Python2.7/lib-tk ', '/root/.pythonbrew/venvs/python-2.7.6/dj/lib/python2.7/lib-old ', '/root/. Pythonbrew/venvs/python-2.7.6/dj/lib/python2.7/lib-dynload ', '/root/.pythonbrew/pythons/python-2.7.6/lib/ python2.7 ', '/root/.pythonbrew/pythons/python-2.7.6/lib/python2.7/plat-linux2 ', '/root/.pythonbrew/ Pythons/python-2.7.6/lib/python2.7/lib-tk ', '/root/.pythonbrew/venvs/python-2.7.6/dj/lib/python2.7/ Site-packages ']server time:mon, 1 dec 2014 21:29:24 -0600
6. Solutions (personal solutions, not recommended)
Comment out '/root/.pythonbrew/venvs/python-2.7.6/dj/lib/python2.7/site-packages/reversion/admin.py in VersionAdmin, The line 384 ' file containsthe word ' atomic ' and then restart the service
7. Front-end display
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/54/4B/wKioL1R-ikjBUQAoAAGHqUNQBq0740.jpg "title=" 52da3eee-108d-48c9-af93-85d23b8bad67.jpg "style=" Float:none; "alt=" Wkiol1r-ikjbuqaoaaghqunqbq0740.jpg "/>650" this.width=650, "src=" http://s3.51cto.com/wyfs02/M00/54/4C/wKiom1R-ibzyfebgAAFmclWG8-I589.jpg "style=" Float:none ; "title=" 6f990423-dce4-4132-b17e-b146659bf5f1.jpg "alt=" Wkiom1r-ibzyfebgaafmclwg8-i589.jpg "/>
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "name=" wizimgdragresize_name "style= "Border:1px solid RGB (221,221,221); background-position:50% 50%; alt=" Spacer.gif "/>
Thanks again to the author of xadmin ~
This article is from the "Chasing Horses" blog, please make sure to keep this source http://lovelace.blog.51cto.com/1028430/1585864
Django Learning xadmin Background Management deployment