How to reset Django admin password?

Open console using. python manage.py shell then use following script in shell from django.contrib.auth.models import User User.objects.filter(is_superuser=True) will list you all super users on the system. if you recognise your username from the list: usr = User.objects.get(username=’your username’) usr.set_password(‘raw password’) usr.save()        

Continue Reading →

How to download Files from the Web with the requests Module

The requests module lets you easily download files from the Web without having to worry about complicated issues such as network errors, connection problems, and data compression. The requests module doesn’t come with Python, so you’ll have to install it first. From the command line, run pip3 install requests. Next, do a simple test to make sure the requests module…

Continue Reading →

web scraping using python

webbrowser Comes with Python and opens a browser to a specific page. Requests Downloads files and web pages from the Internet. Beautiful Soup Parses HTML, the format that web pages are written in. Selenium Launches and controls a web browser. Selenium is able to fill in forms and simulate mouse clicks in this browser. webbrowser Module The webbrowser module’s open()…

Continue Reading →

Python Programming/Strings Tutorial

String There are three ways you can declare a string in Python: single quotes (‘), double quotes (“), and triple quotes (“””). You can use quotation marks within strings by placing a backslash directly before them, so that Python knows you want to include the quotation marks in the string, instead of ending the string there. Placing a backslash directly…

Continue Reading →

Errors and Exceptions in python

Catching exceptions Whenever a runtime error occurs, it creates an exception object. The program stops running at this point and Python prints out the traceback, which ends with a message describing the exception that occurred. Ex→ dividing by zero creates an exception: >>> print(55 / 0) Traceback (most recent call last): File “<pyshell#0>”, line 1, in <module> print(55 / 0)…

Continue Reading →

Working with files in Python

Files Note: Take care of Indentation in codes. While a program is running, its data is stored in random access memory (RAM). RAM is fast and inexpensive, but it is also volatile, which means that when the program ends, or the computer shuts down, data in RAM disappears. To make data available the next time the computer is turned on…

Continue Reading →

Introduction to NumPy

Numpy NumPy is the fundamental package for scientific computing with Python. It contains among other things: a powerful N-dimensional array object sophisticated (broadcasting) functions tools for integrating C/C++ and Fortran code useful linear algebra, Fourier transform, and random number capabilities Why NumPy? The standard Python data types are not very suited for mathematical operations. EX-→ Suppose we have a list.…

Continue Reading →

How to counts the number of decimal digits in a positive integer in Python

The following snippet counts the number of decimal digits in a positive integer: n = 40265 count = 0 while n != 0: count = count + 1 n = n // 10 print(count) This snippet demonstrates an important pattern of computation called a counter. The variable count is initialized to 0 and then incremented each time the loop body…

Continue Reading →

Creating an administration site for your models in Django

Django comes with a built-in administration interface that is very useful for editing content. The Django admin site is built dynamically by reading your model metadata and providing a production-ready interface for editing content. You can use it out-of-the-box, configuring how you want your models to be displayed in it. Remember that django.contrib.admin is already included in the INSTALLED_APPS setting…

Continue Reading →

Creating an application in Django

Let’s create your first Django application. I am going to show you how to create a blog App. From your project’s root directory, run the following command: python3 manage.py startapp blog admin.py : This is where you register models to include them into the Django administration site. Using the Django admin site is optional. migrations : This directory will contain…

Continue Reading →