Tutorial on the use of cookiecutter in django
- 2021-08-12 03:08:33
- OfStack
Step 1 Install
Import:
pipenv install cookiecutter
Problem: Errors may be reported during import:
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 is mainly due to the fact that pipenv version does not support it, so it is necessary to update pipenv, use the command: pip3 install-U pipenv, and then import it again.
2. Create a project
Run cookiecutter
Problem: Direct error reporting
zsh: command not found: cookiecutter
Solution: Use pipenv-py to get the installation directory of the python environment and run cookiecutter in that directory
After running, it will continue to report errors: missing Template
Usage: cookiecutter [OPTIONS] TEMPLATE [EXTRA_CONTEXT]...
Try 'cookiecutter -h' for help.
Error: Missing argument 'TEMPLATE'.
Find pydanny/cookiecutter-django in github, assign the github address, write the address behind the python running environment, and run again
/Users/apple/.local/sha~~~~re/virtualenvs/testProject-h0hp04R9/bin/cookiecutter https://github.com/pydanny/cookiecutter-django.git
Successfully entered the configuration option for specific configuration
3. Specific configuration
project_name: Project name
project_slug: Default and project name keep 1 straight, do not need to fill in
description: Brief description of the project
author_name: Author name, format name
domain_name: Website domain name
eamil: Mailbox
version [0.1. 0] Select open_source_license: Choose open source type
timezone: Time Zone Settings, Asia/Shanghai
windows: Do you use windows system development
use_pycharm: Use pycharm
use_docker: Use docker
Select postgresql_version: Select the version of postgresql, default to the latest version, and default does not inherit Mysql ~ ~ ~ ~
Select js_task_runner: Runner for js, using the default
Select cloud_provider: Default
Select mail_service: Select the service of email
use_async: Use asynchronous programming
use_drf: Whether to use django rest_framework, select y if front and rear ends are separated
custom_bootstrap_compilation: Do you want to customize bootstrap compression
use_compressor: The technology for compressing js and css requires y
use_celery: Whether to use celery, use select y
use_mailhog: Third Party Mail Delivery Service
use_sentry: Do you use error log monitoring
use_whitenoise: Used to deploy static files with file compression
use_heroku: The famous foreign pass platform, if you want to deploy to the top, select y will automatically generate the corresponding configuration
Select ci_tool: Selection Tool (None/Travis/Gitlab/Github)
keep_local_envs_in_vcs: Whether to use version configuration in the local environment variable, select y
debug: Whether to use debug, select y
4. Issues:
The project may report errors during data migration:
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'
Reason: django-celery-beat setup. py has an https://github. com/celery/django-celery-beat/blob/master/requirements/default. field can only be used > = 4.0 and < In version 5.0, the developer pushed a version 4.1. 1 of django-timezone-field, which interrupted the data migration process.
Solution: pipenv install django-timezone-field==4. 0, just re-perform the data migration