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: https://coreyms.com/development/python/python-django-tutorials-full-series

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 manage.py runserver ctr c python manage.py migrate python manage.py createsuperuser username email password password python manage.py runserver # Open website at local server 127.0.0.1:8000/admin # Enter username and password and we can ligin as user created # ctrl C to go to cmd prompt python manage.py startapp tasks # in sttings.py file add 'tasks' in installed_app # view.py from def index(requests): return HttpResponse('Hello World') create urls.py file in tasks tasks/urls.py from django.urls import path from . import views urlpatterns = [ path('', views.index) ] #in todo/urls.py file todo/urls.py from django.urls import path, include urlpatterns = [ .......... path('', include('tasks.urls') ] # In cmd prompt python manage.py runserver # local host at 8000 will serve views.py 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> # models.py 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 manage.py makemigrations python manage.py migrate # Register in admin so that we access Task from admin admin.py from .models import * admin.site.register(Task) ##Goto admin panel add tasks #views.py 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