Giter Site home page Giter Site logo

badripaudel77 / blogs-web-app-django Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 71 KB

A fully functional django and python blog website with blogs CRUD functionalities, pagination, comments on particular post, using django, postgreSQL, bootstrap 5 etc.

Python 59.10% HTML 40.90%
bootstrap5 django-project postgresql python django django-admin djangorestframework

blogs-web-app-django's Introduction

This is a full stack application that has complete web blogs application with following features :

  • Home Page lists all the posts with paginated result
  • On clicking post, leads to the details page with author details, category, tags etc.
  • Clicking on author name, takes to the page where all the blogs posts written by that author will be dispalyed.
  • Clicking on category will do very similar as above but category related posts.
  • User can comment on this blog post, only three recent comments of the post have been fetched.
  • Also , rest api for Post models [related to blogs] , all the CRUD functionality have been implemented.

  • Install Python

  • Create Virtual Environment and activate

    virtualenv env
    source env/bin/activate
    
  • Install django

    pip install django==4.2
    
  • Create Django Project

    django-admin startproject django_blog
    

    cd django_blog where manage.py is located.

  • Migrate [syncs db with models ]

    python manage.py migrate
    
  • Run the django Project

    python manage.py runserver
    

    Create the django app [app is complete module]

    python manage.py startapp blog

  • To Create superuser in python use [for admin access in the url /admin]:

    python manage.py createsuperuser
    

    To render the template, use either render as follows :returnrender(request, 'blog/index.html', data_dict) where data_dict is key value pair dictionary that we want to pass and access in the template called index.html

    or we can use this as :

  • To render the template, use either render as follows :returnrender(request, 'blog/index.html', data_dict) where data_dict is key value pair dictionary that we want to pass and access in the template called index.html

    return render(request, 'blog/index.html', data_dict)
    

    or use :

    blog_template = template.loader.get_template('blog/index.html').render(data_dict)

    return HttpResponse(blog_template)

  • To include template in another page or location, we can use the following syntax :

    {% include 'path_to_template_same_as_rendering' %}
    
  • Django ORM :

  • To save object to the db,obj.save()

  • To delete the object from db,obj.delete()

    Django by default adds a manager called objects to every model class. The objects manager helps us to interact with the database in complicated ways. The objects manager is the most common way Django developers interact with the database. ModelClass.objects

    Author.objects.all()

    To enter into interactive shell, type :python manage.py shell

    To generaterequirements.txt : pip freeze > requirements.txt

    To install dependencies inside of requirments.txt, use :pip install -r requirements.txt

    To Run this project, clone this repository and go to the main directory and runpython manage.py runserver

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.