Python 1: Setup & Requirement

  1. Download Python, and install like a software.
  2. Download “Visual Studio Code” text editor, and install it.
  3. Open Command terminal (window+r, type cmd and press enter).
  4. type py –version this will show your python version

Website in python

Now we will install django, django is a web framework like CodeIgniter in PHP.

  1. Go to Terminal ant type

    this will install django on your system

Set Up a Django Project

After you’ve successfully installed Django, you’re ready to create the scaffolding for your new web application. The Django framework distinguishes between projects and apps:

  • A Django project is a high-level unit of organization that contains logic that governs your whole web application. Each project can contain multiple apps.
  • A Django app is a lower-level unit of your web application. You can have zero to many apps in a project, and you’ll usually have at least one app. You’ll learn more about apps in the next section.

With your virtual environment set up and activated and Django installed, you can now create a project:

This tutorial uses setup as an example for the project name:

Running this command creates a default folder structure, which includes some Python files and your management app that has the same name as your project:

In the code block above, you can see the folder structure that the startproject command created for you:

  • setup/ is your top-level project folder.
  • setup/setup/ is your lower-level folder that represents your management app.
  • manage.py is a Python file that serves as the command center of your project. It does the same as the django-admin command-line utility.

The nested setup/setup/ folder contains a couple more files that you’ll edit when you work on your web application.

Take a moment to explore the default project scaffolding that the django-admin command-line utility created for you. Every project that you’ll make using the startproject command will have the same structure.

When you’re ready, you can move on to create a Django app as a lower-level unit of your new web application.

 

Start a Django App

Every project you build with Django can contain multiple Django apps. When you ran the startproject command in the previous section, you created a management app that you’ll need for every default project that you’ll build. Now, you’ll create a Django app that’ll contain the specific functionality of your web application.

You don’t need to use the django-admin command-line utility anymore, and you can execute the startapp command through the manage.py file instead:

The startapp command generates a default folder structure for a Django app. This tutorial uses example as the name for the app:

Remember to replace example with your app name when you create the Django app for your personal web application.

Once the startapp command has finished execution, you’ll see that Django has added another folder to your folder structure:

The new folder has the name you gave it when running the command. In the case of this tutorial, that’s example/. You can see that the folder contains a couple of Python files.

This Django app folder is where you’ll spend most of your time when creating your web application. You’ll also need to make some changes in the management app, setup/, but you’ll build most of your functionality inside the Django app, example/.

You’ll get to know the generated Python files in more detail when working through a tutorial or building your own project. Here are three notable files that were created in the app folder:

  1. __init__.py: Python uses this file to declare a folder as a package, which allows Django to use code from different apps to compose the overall functionality of your web application. You probably won’t have to touch this file.
  2. models.py: You’ll declare your app’s models in this file, which allows Django to interface with the database of your web application.
  3. views.py: You’ll write most of the code logic of your app in this file.

At this point, you’ve finished setting up the scaffolding for your Django web application, and you can start implementing your ideas. From here on out, it’s up to you what you want to build to create your own unique project.

Source: https://realpython.com/django-setup/

 

View django Project in Browser

Go tyo your ‘project’ folder in ‘Visual Studio’ right click on ‘manage.py’ click on ‘open in integrated terminal’ and type python manage.py runserver

this will show you server URL where you can see your django first setup

Leave a Reply

Your email address will not be published. Required fields are marked *