In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "django build an asset management system". In daily operation, I believe many people have doubts about building an asset management system in django. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "django build an asset management system". Next, please follow the editor to study!
Centos7.4 yum install python3.6
Then install mysql (mariadb)
Yum install-y mariadb mariadb-libs mariadb-devel mariadb-server
Nginx
Yum install epel-releaseyum install-y nginx
Reinstall django2.2.0
Pip install django==2.2.0
-- updated on 2019.10.24 Murray-
Modify settings first
Put
ALLOWED_HOSTS = [] is modified to ALLOWED_HOSTS = ['*',] that is, all hosts are allowed to access
Put the entire folder of the project just managed by IP on the server, and the one I choose here is under / data
Try to start the service with the web server that comes with django.
Cd / data/samspython manage.py run server 0:8000
Found that there was a mistake.
RuntimeError: Model class login.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
However, after a round of Baidu, I still couldn't solve it, so I decided to upgrade the django version.
[root@sm-manage220 sams] # pip install Django==2.2.1Collecting Django==2.2.1 Using cached https://files.pythonhosted.org/packages/b1/1d/2476110614367adfb079a9bc718621f9fc8351e9214e1750cae1832d4090/Django-2.2.1-py3-none-any.whlRequirement already satisfied: pytz in / usr/lib/python3.6/site-packages (from Django==2.2.1) (2019.2) Requirement already satisfied: sqlparse in / usr/lib/python3.6/site-packages (from Django==2.2.1) (0.3.0) ) Installing collected packages: Django Found existing installation: Django 2.2 Uninstalling Django-2.2: Successfully uninstalled Django-2.2Successfully installed Django-2.2.1 [root@sm-manage220 sams] # pip listPackage Version--Django 2.2.1 pip 19.3.1 PyMySQL 0.9.3 python-nmap 0.6.1 pytz 2019.2 setuptools 39.0.1 Sqlparse 0.3.0 [root@sm-manage220 sams] #
Then I was performing python manage.py runserver, and I made a fucking mistake again.
Django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
This solution is a little easier.
File "/ usr/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 36, in raise ImproperlyConfigured ('mysqlclient 1.3.13 or newer is required; you have% s.'% Database.__version__) django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
Just comment out this line.
Okay, after the comment was dropped, there was a second exception.
File "/ usr/lib/python3.6/site-packages/django/db/backends/mysql/operations.py", line 146, in last_executed_query query = query.decode (errors='replace') AttributeError: 'str' object has no attribute' decode'
Change the decode of line 146to encode.
If query is not None: query = query.encode (errors='replace') return query
Then execute python manage.py runserver 0virtual 8000 to start the service (that is, allow all machines to be accessible through port 8000)
Then execute pip install uwsgi, or report an error
Install gcc again.
Yum install-y gcc
Just execute pip install uwsgi again, and then start configuring it
Create a new script directory and a new uwsgi.ini file under the root of the project. The file name can be arbitrary, but the suffix must be ini.
Write the following configuration content in it:
[uwsgi] chdir = / data/sams # the path to the entire project module = sams.wsgi # the name of the project. Wsgimaster = trueprocesses = 3socket = 0.0.0.0data/sams 8001 # if you want to use nginx as a reverse proxy, enter this http = 0.0.0.0data/sams 8000 # enter this without nginx This is mainly to test whether there is any problem with the current configuration vacuum = truepidfile = / data/sams/script/uwsgi.piddaemonize = / data/sams/script/uwsgi.log
Note that direct copy will report an error and cannot find the project path. In fact, it is best to delete the text of the comments by yourself, including spaces.
You can access it directly through port 8000. Next we will configure nginx.
Then we stop the uwsgi, comment out the http line, and use nginx as the proxy instead
[root@sm-manage220 nginx] # ps-ef | grep uwsgiroot 14200 1 0 19:01? 00:00:00 uwsgi-- ini uwsgi.iniroot 14202 14200 0 19:01? 00:00:00 uwsgi-- ini uwsgi.iniroot 14203 14200 0 19:01? 00:00:00 uwsgi-- ini uwsgi.iniroot 14204 14200 0 19:01? 00:00:00 uwsgi-- ini uwsgi.iniroot 14205 14200 0 19:01? 00:00:00 uwsgi-- ini uwsgi.iniroot 14532 13144 0 19:16 pts/0 00:00:00 grep-- color=auto uwsgi [root@sm-manage220 nginx] # pkill-f uwsgi-9 [root@sm-manage220 nginx] # ps-ef | grep uwsgiroot 14543 13144 0 19:16 pts/0 00:00:00 grep-- color=auto uwsgi [root@sm-manage220 nginx] # vim / data/sams/script/ uwsgi.ini [uwsgi] chdir = / data/samsmodule = sams.wsgimaster = trueprocesses = 3socket = 0.0.0.0:8001#http = 0.0.0.0:8000vacuum = truepidfile = / data/sams/script/uwsgi.pid#daemonize = / data/sams/script/uwsgi.log # this way exists as a guardian process It will cause the failure of setting systemctl later logto = / data/sams/script/uwsgi.log # it is recommended to record log server {listen 80 in this way Server_name localhost; access_log / data/sams/script/sams_access.log; error_log / data/sams/script/sams_error.log; client_max_body_size 75M; location / {include uwsgi_params; uwsgi_pass 127.0.0.1 purl 8001 Uwsgi_param UWSGI_SCRIPT sams.wsgi; uwsgi_param UWSGI_CHDIR / data/sams;} location / static {alias / data/sams/static;}}
Configure static resources
Cd / data/samsmkdir staticvim / data/sams/sams/settings.py add a line STATIC_ROOT = os.path.join (BASE_DIR, 'static') at the end and then cd / data/samspython manage.py collectstatic
Then start nginx and uwsgi and set the self-startup of the service
[root@sm-manage220 nginx] # systemctl restart nginx [root@sm-manage220 nginx] # cd / data/sams/script/ [root@sm-manage220 script] # uwsgi-- ini uwsgi.ini [uWSGI] getting INI configuration from uwsgi.ini [root@sm-manage220 ~] # systemctl enable nginxCreated symlink from / etc/systemd/system/multi-user.target.wants/nginx.service to / usr/lib/systemd/system/nginx.service.# set uwsgi as a service Easy to manage vim / usr/lib/systemd/system/ uwsgi.service [Unit] Description=uWSGI instance to serve myprojectAfter=network.target [Service] [Unit] Description=uWSGI instance to serve myprojectAfter=network.target [Service] WorkingDirectory=/data/samsExecStart=/usr/local/bin/uwsgi-- ini / data/sams/script/uwsgi.iniExecStop=/usr/local/bin/uwsgi-- stop / data/sams/script/uwsgi.pidExecReload=/usr/local/bin/uwsgi-- reload / data/sams/script/ uwsgi.pid [install] WantedBy=multi-user.target# Then execute the command to set to boot self-boot systemctl enable uwsgi
-Segmentation line-
Ps: in this way, you can use systemctl start/stop/reload/enable/disable for management. The way I used to boot uwsgi was to write the startup command / usr/local/bin/uwsgi-- ini / data/sams/script/uwsgi.ini in rc.local, and I used daemonize to record log instead of logto in the uwsgi.ini file, which caused it to get stuck in the interface when restarting the server. Always prompt a stop job is running for / etc/rc.d/rc.local, can only be forced to shut down, and then forced to power on.
-Segmentation line-
Restart verification has been ok~
At this point, the study on "django to build an asset management system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.