第一个Django Demo

About Django

Django is a opensourced python-based web framework.

Step 1. Do some preparation works before we begin

First, if you don’t have Homebrew (the package manager for your mac), you can see how to set up homwbrew on your mac.

Now, you got Homebrew on your laptop.
Then you can use this command to install Python3 on your mac(If you don’t have it)

brew install python3

After install python3, you can check your Python version by execute the command:

python3 --version

Step2 install pipenv

Install the pipenv for Django. Pipenv is a virtual environment for Python.

pip3 install pipenv
pipenv --version

Homebrew allow you to install pip3 and python3, pip3 is also a package manager, but it’s only for python packages, including pipenv.

Here, pip3 is a package manager for Python, if you installed Python3, it also should be installed along with it.

Anyway, after this process, you actually ready to create your first project with Django.

Step3 Install Django with pipenv

Virtual environment specifies which version of Django you want to use.

create a folder and run install command to install particular Django version.

cd ~/Desktop
mkdir foldername
cd foldername
pipenv install django==2.1

在这里插入图片描述

We can see, after the installation of the django, there is two files in the distination directory.
Pipfile and Pipfile.lock

Step4 Run the project

pipenv shell

this command to activate this project’s virtual environment.
在这里插入图片描述

Step 5. create a Django project

django-admin startproject editdojo_project .

.(dot) represents current directory in UNIX.
This will create a new Django project for us.
在这里插入图片描述

Step 6. Start up our django server

After this, let’s start up our django server, type the command below:

python manage.py runserver

We can see the output like below:
在这里插入图片描述
Then, we can see we set up Django successfully.
在这里插入图片描述
The End~
If you like this blog, please press the like button, I’ll be very appreciate for that.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值