Tag Archives: django

[Solved] RuntimeError An attempt has been made to start a new process

1、 Exception 1: runtimeerror: an attempt has been made to start a new process

Reason: multiple processes need to run in the main function

Solution 1:

Add the main function and call it in main.

if __name__ == '__main__':
	main()

Solution 2:

num_workers changed to 0, single process loading

Ers changed to 0, single process loading

[Solved] SyntaxError: Generator expression must be parenthesized (widgets.py, line 152)

Run Django with pycharm, python manage Py runserver error

Checked the Internet and said to put widgets Delete the comma in line 152 of Py, which may be a compatibility problem between Python and Django. Try it. You can click the hyperlink above. Pycharm can quickly open the document, and then find the widgets under admin Py file is OK, because the prompt says form Django contrib. Admin import helpers, widgets, and options The PY file is in the admin directory.

[Solved] Python Django error: error: (1146, “Table ‘mydb.django_session’ doesn’t exist”)

error: (1146, "Table 'mydb.django_session' doesn't exist")

Because there is no Django in the database table_session.

Execute the command at the terminal to migrate the data structure

$ python manage.py migrate

After executing the above command, the output results are all OK. You can see that many tables have been added to the database table, The details are as follows

# By default 10 tables are automatically created in our database, as follows.
MariaDB [mydemo]> show tables;
+----------------------------+
| Tables_in_mydemo           |
+----------------------------+
| auth_group                 |
| auth_group_permissions     |
| auth_permission            |
| auth_user                  |
| auth_user_groups           |
| auth_user_user_permissions |
| django_admin_log           |
| django_content_type        |
| django_migrations          |
| django_session             |
| stu                        |
+----------------------------+
11 rows in set (0.00 sec)

Then it was solved

Exception occurred when Django created app: from exc ^ syntaxerror: invalid syntax

Execute command Python   manage.py   startapp   Myjango

  App reports an error: file “manage. Py”, line 16) from exc ^ syntax error: invalid syntax

reason:

Python 3 is installed, but Python is used for execution

solve:

Change Python to python3 and execute the above command

python3 manage.py   startapp   myjango

[Solved] Django Error: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.

1. Background

Because you want to change the default database of Django to MySQL, the following error is reported when starting the project

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.

2. Solution

From the above results, it can be seen that the corresponding module cannot be identified, so the corresponding module needs to be modified __ init__.Py file

import pymysql
pymysql.install_as_MySQLdb()

Just start the service again

Resolution of internal server error problem in diango project

Resolution of internal server error problem in diango project

Project scenario:

Django project
using uwsgi deployment
internal server error is found after packaging and running


Problem Description:

internal server error appears on the website of the project. Check the log and find no Python application found

Solution:

Delete uwsgi_ Log restart uwsgi open the uwsgi log file and constantly try to modify it. Open the uwsgi log to check the problem

Cause analysis:

the existing problems are as follows:

    when using pyinstaller to package, do not add – F. the packaged files are still run in the original directory


    Solution:

      put the packaged files in the original directory. Do not use pyinstaller – F manage.spec when running the packaged application
      use pyinstaller manage.spec; Make sure that the python path of the project directory in uwsgi.ini is correct