Man Is Slave Of Circumstances

This week I passed through a turbulent situation. It has been a hard time to find a balance between traditional culture and youth. Both are right in there own perspective. But the prudent being is one who makes his way finding a balance between the two. We are in the age where body and mind tend to part with each other. We fail to see or feel the world as youth sees it. At the same time youth is completely unaware of the limitations and insecurity that old generation landed them selves due to mental and physicals weakness. All we pray that the decisions made by the young are far sighted and safe. We should trust in almighty and hope future will be bright and bring peace and prosperity to all.

Recovered lost django site

I am very pleased to get back my django blog site. I reinstalled the server by repeating whole process by watching CoreyShafer's video on django deployment. Each and every word of the video is 100% correct. I have rarely seen video made with so much care and dedication. I am a novice still I could complete this project (some what difficult to complete if you loss concentration). Big Thanks to corey Schafer. Link:

First Blog

The learning is an enjoyment. Moreover if you enjoy more you will learn more. And if you learn more you enjoy more To day I am writing about ternary operator in python. How it writes a code in a single line instead of writing 4- 5 lines of code. ✔ Consider a if statement : ##CODE## condition = True if condition: ....x = 1 else: ....x=0 print(x) ##endcode## Above code can be rewritten in python as : x=1 if condition else 0 print(x) ✌ Some times it is difficult to read large numbers we can use '_' without effecting the result num1 = 10000000000 num2 = 100000000 total = num1 + num2 print(total) num1 = 10_000_000_000 num2 = 10_000_000 total = num1 + num2 print(total) Both the code will give same result irrespective of placing an '_' in between If we want result to be formatted with '_' separator we can do so as: print(f'{total: ,}') *************************************** ::actvating venv in windows:: python3 -m venv venv venv\Scripts\activate.bat :::Building todo app indjango::: pip install django django-admin startproject todo cd todo python runserver ctr c python migrate python createsuperuser username email password password python runserver # Open website at local server # Enter username and password and we can ligin as user created # ctrl C to go to cmd prompt python startapp tasks # in file add 'tasks' in installed_app # from def index(requests): return HttpResponse('Hello World') create file in tasks tasks/ from django.urls import path from . import views urlpatterns = [ path('', views.index) ] #in todo/ file todo/ from django.urls import path, include urlpatterns = [ .......... path('', include('tasks.urls') ] # In cmd prompt python runserver # local host at 8000 will serve file # create folder templates in tasks folder and then create a tasks folder in templates ie >> tasks/templates/tasks make a file list.html in tasks folder templates/tasks/list.html <h3>To Do</h3> # from django.db import models class = Task(models.Model): ........title = models.CharField(max_length = 200) ........complete = models.BooleanField(default = False) ........created = models.DateTimeField(auto_now_add = True) ........def __str__(self): ..............return self.title # Make migration and migrate #in commd prompt python makemigrations python migrate # Register in admin so that we access Task from admin from .models import * ##Goto admin panel add tasks from . models import * def index(request): ....tasks = Task.objects.all() ....context = {'tasks' : 'tasks'} ....return render(request, 'task/list.html', context) #task/list.html <h3>To Do</h3> {% for task in tasks %} ....<div> ......<p>{{ task }}</p> ....<div> {% endfor %}

First Previous 2 3 4