Solutions to common problems encountered during Django deployment and installation

1. Deployment environment description

#Update uname -a
Linux VM_0_2_centos 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
#Updatecat /etc/redhat-release
CentOS Linux release 7.5.18 04 (Core)

2. Problem summary

2.1 Django compilation and installation error

错误信息:ImportError: libffi.so.5: cannot open shared object file: No such file or directory

Solution: libffi has been compiled and installed and has the library file. You need to add the export LD_LIBRARY_PATH=$prefix_path/lib64/ path to the environment variable.

2.2 Error when opening Django interface document

Error message: AttributeError: 'AutoSchema' object has no attribute 'get_link'
Solution: Add
REST_FRAMEWORK = { 'DEFAULT_SCHEMA_CLASS':'rest_framework.schemas.AutoSchema' } in the setting file

2.3 Non-root user source code installation python3.7

Error message: Error_ctype is not found, but the system and the yum intsall -y libbfi-devel package are installed, and the error is still reported.
Solution: Install the source code through the root user.

2.4 Data migration and synchronization issues

2.4.1 Django报错:(fields.E304) Reverse accessor for ‘User.groups’ clashes with reverse access

Running Django in pycharm: When executing the command: python manage.py makemigrations, an error is
Insert image description here
reported. Solution: Add AUTH_USER_MODEL = 'user.User'
to the settings.py file . The specific reason is not clear.

2.4.2 django.db.utils.InternalError: (1005, u"Can’t create table ‘dev_scrcu.#sql-1e3c_1e52821’ (errno: 150)")

The reason is: caused by the version of pymysql

Insert image description here
Solution: Reinstall the pymysql version.

2.4.3 Django reports an error after starting data synchronization (python manage.py migrate)

Error message: FROM unnest(c.conkey) WITH ORDINALITY co…

Reason: The database uses pg11.4, and the location of the environment variable initdb is the system default database version, that is, the environment variable does not take effect. When creating the database and initializing it, the system itself has version pg9, which results in version 9 when initdb -D datadir is executed, causing the database and database service versions to be built to be inconsistent, resulting in an error.

Solution: Write the pg11.4 version into the corresponding user environment variable and re-initialize it.

2.4.4 Data migration issues (django.db.utils.InternalError: (1050, "Table 'tb_content' already exists"))

Solution

First delete the generated files such as:
Insert image description here
Then enter:
python manage.py makemigrations --fake
python manage.py migrate --fake

The specific effect is as follows:
Insert image description here
Finally, perform the migration operation:
#Generate migration file
python manage.py makemigrations
#Execute migration command
python manage.py migrate

Supongo que te gusta

Origin blog.csdn.net/weixin_40012925/article/details/128305225
Recomendado
Clasificación