E:\virtualenv\nowamagic_venv>virtualenv proj_env1 --python=C:\Python36\python.exe Running virtualenv with interpreter C:\Python36\python.exe Using base prefix 'C:\\Python36' New python executable in E:\virtualenv\nowamagic_venv\proj_env1\Scripts\python.exe Installing setuptools, pip, wheel...done.
(proj_env1) E:\virtualenv\nowamagic_venv\proj_env1\Scripts>piplist DEPRECATION: The default format will switchto columns in the future. You can use --format=(legacy|columns) (or define a ection) to disable this warning. pip (9.0.1) setuptools (38.5.1) wheel (0.30.0)
有时安装的pip版本太低,用pip安装软件时会报
1
pip._vendor.distlib.DistlibException: Unable to locate finder for 'pip._vendor.distlib'
from __future__ import absolute_import, unicode_literals import os from celery import Celery
# set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_celery_beat_test.settings')
app = Celery('django_celery_beat_test')
# Using a string here means the worker doesn't have to serialize # the configuration object to child processes. # - namespace='CELERY' means all celery-related configuration keys # should have a `CELERY_` prefix. app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs. app.autodiscover_tasks()
#: Only add pickle to this list if your broker is secured #: from unwanted access (see userguide/security.html) CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_RESULT_BACKEND = 'redis://:[email protected]:6379/1'
(django_celery_beat_env) e:\code\git\source\my\django_celery_beat_test>python ma nage.py migrate System check identified some issues:
WARNINGS: ?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default' HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, s uch as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2. 0/ref/databases/#mysql-sql-mode Operations to perform: Apply all migrations: admin, auth, contenttypes, django_celery_beat, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying django_celery_beat.0001_initial... OK Applying django_celery_beat.0002_auto_20161118_0346... OK Applying django_celery_beat.0003_auto_20161209_0049... OK Applying django_celery_beat.0004_auto_20170221_0000... OK Applying sessions.0001_initial... OK
\4. 启动celery beat的时候指定–scheduler
1
celery -A django_celery_beat_test beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
django admin
创建superuser
1 2 3 4 5 6 7
(django_celery_beat_env) e:\code\git\source\my\django_celery_beat_test>pythonma nage.py createsuperuser Username (leave blank to use 'zq'): admin Email address: zq@126.com Password: Password (again): Superuser created successfully.