Copyright description
I have recently found many articles reposted by the author without explaining the author and the source, so I have made some special statements.
All content in this blog is allowed by Creative Commons licenses. When referencing this content, keep itZhu Tao,SourceAndNon-commercial.
Summary
As the most fluent Web framework in the python community, Django emphasizesQuick Development,Reuse,ReadableThis article mainly introduces the knowledge required to use Django for development. It also includes some guiding principles and some experiences from the author.
Contents
Basic knowledge familiar with Python and Django
Django is based on python, so you need to be familiar with related technologies before development.
Python recommends several good books, including:
- Learning Python
- Python cookbook
Familiar with Django official documents and related books, these are required. Good books include:
- Django book
- Pro Django
- Practical Django Projects
For more information, see Django related resources.
Other related technologies
As a web development programmer, you also need to understand other related technologies, including:
- Html
- CSS
- JavaScript (jquery, etc)
- Ajax
- Network Knowledge and standards, such as HTTP protocol and TCP/IP network architecture.
Available resources
After mastering the Basic Knowledge mentioned above, we are familiar with python, Django, and web development technologies, and have a certain understanding of the philosophy of Python and Django, suchDon't repeat yourself,Keep it simple, stupid,Don't reinvent wheelsAnd so on.
Therefore, before starting a project, we need to know which resources are available.
Among the available resources, pinax is the most important project to be tracked. It provides some common functions required by the site, and the method used is to provide someReusable appsSo that we can easily integrate into our environment, or perform secondary development based on pinax.
In addition, you also need to know resources in specific fields, such:
- Store Satchmo
- Geodjango
- Openid Django-openid
- And so on.
After obtaining resources in a specific field, it will greatly improve the development efficiency and reduce the cost.
Advanced knowledge
Mastering the technology mentioned above is basically a qualified Django programmer, but you also need to know some advanced knowledge.
Use virtualenv + Pip to build an independent development environment
Virtualenv is used to create an independent virtual environment (similar to other modules), so that programs in different virtual environments can depend on different versions of modules, for example, a Django project is based on 0.96, and another project is based on 1.1. Therefore, different virtual environments must be created. For more information, see Pip and virtualenv.
Use PipCopyExisting dependencies. Pip is used to replace easy_install. In addition, we can also easily use PipCopyOur current work environment. For exampleRequirements.txtFile to record the relevant dependencies in our current work environment, and then enterPIP install-r/path/to/requirements.txtThe dependent software is automatically installed. The premise is that your system has installed Pip.
In addition, when you need to deploy a Django project, you can use wsgi for convenient deployment. For details, see virtualenv and wsgi.
Deploy with fabric
Refer to deploying Python web applications
In addition, we can also use the powerful functions of python to implement path self-adaptation of configuration files, and use the debugging status to set specific attributes.
Recommended Development Process
You can use the following development process to develop Django (assuming that a new project is started ):
- Use virtualenv to create an independent environment
- Install the corresponding dependency modules using easy_install and Pip
- When multiple developers develop, all the current modules can beCopyTo colleagues (PipYesFeezeCommand to output all the dependent modules and versions in the current environment to ensure that all developers use the same code library)
- Create an independent environment for the server and use fabric for automatic deployment.
- Finally, we use wsgi and web servers to publish products.
Conclusion
Using Django'sReuse,Quick DevelopmentIn addition to some development knowledge (skills) described above, if you find a process cumbersome during development, at this time, you should consider whether there are related solutions. instead of simply taking time to complete.
References
- Notes on using Pip and virtualenv with Django
- Woodpecker community
- Django-related resources