In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to install Django in Conda. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Create the Django project conda create-n ll_env python=3.6activate ll_envconda install Djangodjango-admin.py startproject learning_log .dir learning_log
Create a virtual environment called ll_env with version 3.6 of python installed
Activate the environment
Install Django in the active environment
Create a learning_log project file with the command of django
View the contents of the project file learning_log
Create a database
Django stores most of the project-related information in a database, so we need to create a database for Django to use.
Python manage.py migratedir
Create a database
Dir views the contents of the virtual environment ll_nv
Check to see if the project was created successfully
Django starts a server that allows you to view projects in the system and see how they work. When you type URL into a browser to request a web page, the Django server will respond by generating the appropriate web page and sending it to the browser.
Python manage.py runserverctrl+c # shut down the server
After entering the above code, you will be prompted with a URL and enter the red URL in the browser to complete the installation.
Create an application
The Django project consists of a series of applications that work together to make the project a whole. For the time being, we will only create one application, which will do most of the work of the project. In the future, we will add another application to manage user accounts.
Create an application learning_logs in a ll_env environment
Python manage.py startapp learning_logs
Be careful
Project learning_log, application learning_logs, juxtaposed, all under the environment ll_env, you can use dir learning_log to view their respective content. We can modify and improve our own application, and then put the written application into the project through the settings.py in the project.
Define the model
From the screenshot above, we find that the learning_logs location of the application is in the directory c:\ Users\ Administrator.
Open the file models.py for editing
From django.db import models# Create your models here.class Topic (models.Model): text = models.CharField (max_length=200) data_added = models.DateTimeField (auto_now_add=True) def _ str__ (self): return self.text
Activate the model
a. Open the setting.py under the project to make changes
In INSTALLED_APPS = []
Add the application we wrote, 'learning_logs'.
b. The command makemigrations lets Django determine how to modify the database so that it can store the data associated with the new question type that we define. The output shows that Django created a migration file called 0001 initial.py, which will create a table for the model Topic in the database.
Python manage.py makemigrations learning_logs
c. Apply this migration and ask Django to modify the database for us.
Python manage.py migrate
Whenever you need to modify the data managed by Learning Notes, take the following three steps: modify models.py; to learning_ logs call makemigrations; to Django to migrate the project.
This is the end of this article on "how to install Django in Conda". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.