python video tutorialThe column introduces how to use cookiecutter
##Related free learning recommendations: python video tutorial
1. Installation
Import:
pipenv install cookiecutter
Problem: An error may be reported during the import process:
pkg_resources.VersionConflict: (importlib-metadata 3.1.0 (/Users/apple/.local/share/virtualenvs/testProject-h0hp04R9/lib/python3.6/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"')).
Cause and solution: This problem occurs mainly because the pipenv version is not supported. Pipenv needs to be updated. Use the command: pip3 install -U pipenv, and then re-import it.
2. Create a project
Run cookiecutter
Problem: Report an error directly
zsh: command not found: cookiecutter
Solution: Use pipenv --py to obtain the installation directory of the python environment, and run cookiecutter
in this directory. The error will continue to be reported after running: Template
Usage: cookiecutter [OPTIONS] TEMPLATE [EXTRA_CONTEXT]...
Try 'cookiecutter -h' for help.
Error: Missing argument 'TEMPLATE'.
Copy after login
is missing. Find pydanny/cookiecutter in github- Django, assign the github address, write the address after the python operating environment, run again
/Users/apple/.local/sha~~~~re/virtualenvs/testProject-h0hp04R9/bin/cookiecutter https://github.com/pydanny/cookiecutter-django.git
Copy after login
Successfully enter the configuration options, and perform specific configuration
3. Specific configuration
project_name: project name project_slug: the default is the same as the name of the project, no need to fill in description: a brief description of the project author_name: author's Name, format namedomain_name: Website domain nameeamil: Emailversion [0.1.0] Select open_source_license: Select whether to open source typetimezone: Time zone setting, Asia/Shanghaiwindows: whether to use windows system developmentuse_pycharm: whether to use pycharmuse_docker: whether to use dockerSelect postgresql_version: Select the version of postgresql, the default is the latest version, and Mysql is not inherited by default~~~~Select js_task_runner: js runner, use the default Select cloud_provider: DefaultSelect mail_service: Select the email service use_async: whether to use asynchronous programming use_drf: whether to use django rest_framework, if the front and back ends are separated, select ycustom_bootstrap_compilation: Whether to customize bootstrap compressionuse_compressor: technology used to compress js and css, you need to select yuse_celery: whether to use celery, use select yuse_mailhog: third party Email sending serviceuse_sentry: whether to use error log monitoringuse_whitenoise: used to deploy static files, with file compression functionuse_heroku: a famous foreign pass platform , if you want to deploy it above, select y and the corresponding configuration will be automatically generated Select ci_tool: Select tool (None/Travis/Gitlab/Github) keep_local_envs_in_vcs: Whether to use it in local environment variables Version configuration, select ydebug: whether to use debug, select y
4. Question:
project is undergoing data migration An error may be reported:
File "/Users/apple/.local/share/virtualenvs/django-pro-7n8-wfJY/lib/python3.6/site-packages/django_celery_beat/models.py", line 60, in crontab_schedule_celery_timezone
choice[0].zone for choice in timezone_field.TimeZoneField.CHOICES
AttributeError: type object 'TimeZoneField' has no attribute 'CHOICES'
Copy after login
Cause: django-celery-beat setup.py has a https://github.com/celery/django-celery-beat/blob/master/requirements/default.txt dependency According to the requirement, django-timezone-field can only be used with >=4.0 and Solution: pipenv install django-timezone-field==4.0, just re-execute the data migration
Summary
This concludes this tutorial on the use of cookiecutter in django This concludes the article.
If you want to know more about programming learning, please pay attention to the php training column!
The above is the detailed content of Detailed tutorial on using cookiecutter in Django. For more information, please follow other related articles on the PHP Chinese website!