[Cloud9] Try to build an environment with django 1.11 of Python 3.4 without understanding even 1 mm

Purpose of this article

Python? django? Environment construction? Correct understanding?

komakai.jpg

** I want to use django for the time being! !! !! !! (ˇΩˇ) **

Even though I am motivated, I can't stumble when building an environment! So, I will send you the environment construction without understanding even 1 mm from me on the first day of Python history and django history.

If you read the correct document

https://docs.djangoproject.com/en/1.11/intro/tutorial01/ At the moment, 1.11 is the latest in django, but if it's updated in the future, change the URL above to something like 1.12 and that's the latest documentation. that's all.

Building a local environment?

If you read the document, you'll understand it, it's too much to throw at you, so let's explain it. But I won't go into the details. I can not do it! !! Python formula or ANACONDA You can create an environment to run Python locally, but

--Heavy ――Unexpectedly, it takes time ――I don't really understand

People who are new to Python will surely be like this. mayoi.jpg

For the time being, let's start from the place where you register with Cloud9

--No installation required --Just register ――Various environments are in place --Easy to deploy!

** So let's use Cloud9 ! !! ** **

django, make a workspace

When you log in to Cloud9, you will access the following page. Let's create a workspace with [Create a new workspace]. cloud9.JPG

Then you will be taken to the following page, so select the Workspace Name ** "mysite" ** from the template below, ** "django" ** from the template below, and press [Create workspace]. .. workspace.png

Check Python and django versions

Once the workspace is created, the screen will change to the one shown below. start.JPG

Well, the first thing to do is to check the version. The official documentation assumes ** Python 3.4 or higher and django 1.11 **. Let's check the version by entering the following in bash.

bash


python --version
python -m django --version

Execution result version.jpg Yes old, yes sieve. So I will raise the version.

Raise the version of Python and django

Let's do the following in bash without thinking.

Symbolic link to Python3

bash


sudo mv /usr/bin/python /usr/bin/python2
sudo ln -s /usr/bin/python3 /usr/bin/python
python --version

Execution result python-version-up.JPG

Reinstall django

bash


sudo pip3 install django
python -m django --version

Execution result django-version-up.JPG The prerequisites are now in place! Next, let's create an application.

Creating an application

Run the following to create an application called "polls".

bash


python manage.py startapp polls

Execution result application.jpg As mentioned above, a folder called "polls" and various files are created directly under it. This completes the application creation!

Rewrite View

This also follows the official documentation and modifies views.py as follows:

polls/views.py


from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

view.JPG This is all you need for the view part!

Rewrite urls.py

Just follow the official documentation! Even so, why don't you read it through to Tekito? So let's read the document properly!

Create urls.py directly under polls folder

Right-click on the polls folder to display various context menus, so select [New File] in it. polls-urls.jpg Since a new file will be created, name it [urls.py] and copy and paste the following

polls/urls.py


from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
]

polls-urls-code.jpg

Rewrite urls.py on the project side

mysite/urls.py


from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

mysite-urls.JPG

Try to run

If you can do it so far, let's actually move it. Click [Run Project] in the upper right. RunProject.jpg

The following log should be spit out running.JPG

The URL is output when the project is executed. In this case, it is the following URL. Please try to access it. https://mysite-karimata.c9users.io

When I fly ... that? can not fly? page-not-found.JPG

That should be it. This time I made a page called "polls". Try adding "polls" to the end of the URL (https://mysite-karimata.c9users.io/polls/). Then ...! polls.JPG Yes, I was able to display it! For the time being, the minimum environment has been created! We did it, Tae-chan! You can do Python!

Summary

If you follow the above flow, you can build an environment using django without really understanding even 1 mm. As I will learn the details one by one, ** I can move it first! Let's enter from ** and lower the psychological barrier!

Have a good Python life!

Recommended Posts

[Cloud9] Try to build an environment with django 1.11 of Python 3.4 without understanding even 1 mm
An example of cloudbuild.yaml when auto-deploying Django to App Engine with Cloud Build
[Django] Memo to create an environment of Django + MySQL + Vue.js [Python]
[Python] Build a Django development environment with Docker
Quickly build a Python Django environment with IntelliJ
How to build an environment for using multiple versions of Python on Mac
I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4
How to build a Django (python) environment on docker
[No need to build local environment] Deploy Python bottle application made with Cloud9 to Heroku
I tried to build an environment for machine learning with Python (Mac OS X)
Build python3 environment with ubuntu 16.04
Build python environment with direnv
Try running python in a Django environment created with pipenv
Build an Ubuntu python development environment on Google Cloud Platform
Try to automate the operation of network devices with Python
How to build a python2.7 series development environment with Vagrant
Create a Todo app with Django ① Build an environment with Docker
Build python virtual environment with virtualenv
Try to operate Facebook with Python
Build Mysql + Python environment with docker
Try to create a python environment with Visual Studio Code & WSL
Try to extract a character string from an image with Python3
Easy-to-understand explanation of Python Web application (Django) even for beginners (5) [Introduction to DB operation with Django shell]
Build and try an OpenCV & Python environment in minutes using Docker
How to build Python and Jupyter execution environment with VS Code
Build an environment to execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people)
[TCP / IP] After studying, try to make an HTTP client-like with Python
Send an email to a specific email address with python without SMTP settings
Try to image the elevation data of the Geographical Survey Institute with Python
Prepare an environment to touch grib2 format files with python (Docker edition)
Try to build python and anaconda environment on Mac (by pyenv, conda)
Try to solve a set problem of high school math with Python
I tried to build a Mac Python development environment with pythonz + direnv
Summary of how to build a LAMP + Wordpress environment with Sakura VPS
How to build an application from the cloud using the Django web framework
Easy-to-understand explanation of Python Web application (Django) even for beginners (1) [Environment construction]
Steps to build a Django environment with Win10 WSL Ubuntu18.04 + Anaconda + Apache2
[Python] Building an environment with Anaconda [Mac]
Try to reproduce color film with Python
Try logging in to qiita with Python
Change Python 64bit environment to 32bit environment with Anaconda
Build an environment for Blender built-in Python
Build Jupyter Lab (Python) environment with Docker
Method to build Python environment in Xcode 6
Note when creating an environment with python
I want to build a Python environment
Try using Python with Google Cloud Functions
Try to prepare each environment of kivy
Build Python environment with Anaconda on Mac
Build a python virtual environment with pyenv
Build a Python + OpenCV environment on Cloud9
Build a modern Python environment with Neovim
Try to generate an image with aliasing
Build AI / machine learning environment with Python
I'm an amateur on the 14th day of python, but I want to try machine learning with scikit-learn
How to build an environment when you want to use python2.7 after installing Anaconda3
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
I want to send Gmail with Python, but I can't because of an error
Building an environment to comply with the Python coding standard (PEP8) with Eclipse + PyDev
Build a python environment to learn the theory and implementation of deep learning
WEB scraping with python and try to make a word cloud from reviews