Giter Site home page Giter Site logo

my_site's Introduction

my_site

My first blog site

django_project

Pre-requisites

Python (basics)

Step 1:- Installation of Pip(if not installed)

To install the pip make sure python is installed in system if not then first setup the python from https://www.python.org/downloads/

1. To download get-pip.py Run this command
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2. After downloading run this command
python get-pip.py
3. :) be happy you pip is installed.

Step 2:- Installation of Django

To install the Django you just need to run this command,
 pip install Django

Step 3:- Start a project

You have to decide the path of your project to start the project, I like want to make it ease for myself so I prefered here to make it on desktop
   

After it when you look at your path the you find a folder with projectname as you specified but in
my case folder is on desktop with name "itsalok"



When go inside that folder you will find as, there is a folder(name same as the parent folder) and a file name as manage(it helps to run the server for you



When you move into the folder inside folder you will find the 4 files named as
__init__ ,settings, urls, wsgi



Step 4:- Start the server

To start the server you have to run that command



After executing that command you have to your browser and search for http://127.0.0.1:8000/ then you will get as below


Step 5:- Creating the blog application

To create the application you have run the command written below:

Now my updated project directory is seems like:

Step 6:- Register the blog app

Now you have to open the settings.py file which is located at in your case

---\---\----\projectname\projectname
and in my case it is

C:\Users\HP\Desktop\itsalok\itsalok

and you have find the INSTALLED_APPS block of code


and add 'blog', (as highlighted below in image) as given below and you will add same as you named your app during Step 5



Step 7:- Specify the database

Now in the same file you have to find the block named as DATABASES and
add the command given below or highlighted in the image:-

'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

Step 8:Change the time zone

If you are from India then you have to change the time to 'Asia/Kolkata' and it is done in same setting.py file you can see below,


Ready to make models

To make models we need some basics related to models, relationships among objects, Foreign keys and some other concepts.

Foreign key:- When an attribute of one table refer to the primary key of another table, then that attribute
is said as Foreign key.

Relationship:- When the tables are connected to each other.

1 to 1 relationship:- When one row in a table may be linked with only one row in another table and vice versa.

1 to m relationship:- When one row in the table may linked with many rows in another table.

m to 1 relationship:- When many rows from a table is linked with single row of another table.

m to m relationship:- When many rows from a table are linked with many rows of another table.

Total participation:- It specifies that each entity in the entity set must compulsorily participate in at least one relationship instance in that relationship set.

Partial participation:- It specifies that each entity in the entity set may or may not participate in the relationship instance in that relationship set.

And most important we have know about notations:-

There is a description video link below of UML class diagrams please check it first before going into deep of creating code for your own specific model
https://www.youtube.com/watch?v=UI6lqHOVHic

# I have to add model here

As we make the model according to it we have to code into models.py


# Create tables for models in your database
To create the tables for the models you have to goto your command line as run the given command(highlighted one) below:-

Now Django created the migration file you to apply to your database for this type and run the highlighted command below:-

Django Admin

To add, edit and delete the posts we've just modeled, we will use Django admin.
Let's open the blog/admin.py file in the code editor and replace its contents with this:

.

As you can see, we import (include) the Post model defined in the previous chapter. To make our model visible on the admin page, we need to register the model with admin.site.register(Post). OK, time to look at our Post model. Remember to run python manage.py runserver in the console to run the web server. Go to your browser and type the address http://127.0.0.1:8000/admin/. You will see a login page like this:

To Log in into it we have to create the Superuser- a user who have control over everything on the site. Go back to command line and type the following command

python manage.py createsuperuser

Return to your browser. Log in with the superuser's credentials you chose; you should see the Django admin dashboard.

my_site's People

Contributors

i-m-alok avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.