Subscribe Us

header ads

How to build a website with Django



Python web language
Hey, welcome to the first tutorial on the blog, in this tutorial am going to teach you how to start building a website using django.

What is Django ?
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It's free and open source. Ridiculously fast.

Django makes it easy to start web development with python.
So lets dive into the coding part 

Step 1
Open up your terminal and type
pip install django
so what this those is it install django for us.


Step 2
After installing, create a folder and cd into the folder using your terminal
Then type in 
django-admin startproject mysite
check the folder, it should be like this
mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py
These files are:
  • The outer mysite/ root directory is a container for your project. Its name doesn’t matter to Django; you can rename it to anything you like.
  • manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin and manage.py.
  • The inner mysite/ directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g. mysite.urls).
  • mysite/__init__.py: An empty file that tells Python that this directory should be considered a Python package. If you’re a Python beginner, read more about packages in the official Python docs.
  • mysite/settings.py: Settings/configuration for this Django project. Django settings will tell you all about how settings work.
  • mysite/urls.py: The URL declarations for this Django project; a “table of contents” of your Django-powered site. You can read more about URLs in URL dispatcher.
  • mysite/asgi.py: An entry-point for ASGI-compatible web servers to serve your project. See How to deploy with ASGI for more details.
  • mysite/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project. See How to deploy with WSGI for more details.
now cd into mysite and type
python manage.py runserver
you should be seeing
Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

May 27, 2020 - 15:50:53
Django version 3.0, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
So by now when you open up the browser and type http://127.0.0.1:8000, you should be seeing the django home page

Amazing, so we got our server running, stay tuned for the more tutorials on django.
Have any questions? the comment below

Post a Comment

0 Comments