search
HomeBackend DevelopmentPython TutorialDetailed tutorial on using cookiecutter in Django

python video tutorialThe column introduces how to use cookiecutter

Detailed tutorial on using cookiecutter in Django

##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=0.12; python_version
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'.

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

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 name
  • domain_name: Website domain name
  • eamil: Email
  • version [0.1.0] Select open_source_license: Select whether to open source type
  • timezone: Time zone setting, Asia/Shanghai
  • windows: whether to use windows system development
  • use_pycharm: whether to use pycharm
  • use_docker: whether to use docker
  • Select 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: Default
  • Select 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 y
  • custom_bootstrap_compilation: Whether to customize bootstrap compression
  • use_compressor: technology used to compress js and css, you need to select y
  • use_celery: whether to use celery, use select y
  • use_mailhog: third party Email sending service
  • use_sentry: whether to use error log monitoring
  • use_whitenoise: used to deploy static files, with file compression function
  • use_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 y
  • debug: 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'

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!

Statement
This article is reproduced at:jb51. If there is any infringement, please contact admin@php.cn delete
Python vs. C  : Understanding the Key DifferencesPython vs. C : Understanding the Key DifferencesApr 21, 2025 am 12:18 AM

Python and C each have their own advantages, and the choice should be based on project requirements. 1) Python is suitable for rapid development and data processing due to its concise syntax and dynamic typing. 2)C is suitable for high performance and system programming due to its static typing and manual memory management.

Python vs. C  : Which Language to Choose for Your Project?Python vs. C : Which Language to Choose for Your Project?Apr 21, 2025 am 12:17 AM

Choosing Python or C depends on project requirements: 1) If you need rapid development, data processing and prototype design, choose Python; 2) If you need high performance, low latency and close hardware control, choose C.

Reaching Your Python Goals: The Power of 2 Hours DailyReaching Your Python Goals: The Power of 2 Hours DailyApr 20, 2025 am 12:21 AM

By investing 2 hours of Python learning every day, you can effectively improve your programming skills. 1. Learn new knowledge: read documents or watch tutorials. 2. Practice: Write code and complete exercises. 3. Review: Consolidate the content you have learned. 4. Project practice: Apply what you have learned in actual projects. Such a structured learning plan can help you systematically master Python and achieve career goals.

Maximizing 2 Hours: Effective Python Learning StrategiesMaximizing 2 Hours: Effective Python Learning StrategiesApr 20, 2025 am 12:20 AM

Methods to learn Python efficiently within two hours include: 1. Review the basic knowledge and ensure that you are familiar with Python installation and basic syntax; 2. Understand the core concepts of Python, such as variables, lists, functions, etc.; 3. Master basic and advanced usage by using examples; 4. Learn common errors and debugging techniques; 5. Apply performance optimization and best practices, such as using list comprehensions and following the PEP8 style guide.

Choosing Between Python and C  : The Right Language for YouChoosing Between Python and C : The Right Language for YouApr 20, 2025 am 12:20 AM

Python is suitable for beginners and data science, and C is suitable for system programming and game development. 1. Python is simple and easy to use, suitable for data science and web development. 2.C provides high performance and control, suitable for game development and system programming. The choice should be based on project needs and personal interests.

Python vs. C  : A Comparative Analysis of Programming LanguagesPython vs. C : A Comparative Analysis of Programming LanguagesApr 20, 2025 am 12:14 AM

Python is more suitable for data science and rapid development, while C is more suitable for high performance and system programming. 1. Python syntax is concise and easy to learn, suitable for data processing and scientific computing. 2.C has complex syntax but excellent performance and is often used in game development and system programming.

2 Hours a Day: The Potential of Python Learning2 Hours a Day: The Potential of Python LearningApr 20, 2025 am 12:14 AM

It is feasible to invest two hours a day to learn Python. 1. Learn new knowledge: Learn new concepts in one hour, such as lists and dictionaries. 2. Practice and exercises: Use one hour to perform programming exercises, such as writing small programs. Through reasonable planning and perseverance, you can master the core concepts of Python in a short time.

Python vs. C  : Learning Curves and Ease of UsePython vs. C : Learning Curves and Ease of UseApr 19, 2025 am 12:20 AM

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool