Raza Rython 📜 Profile picture
May 14, 2021 22 tweets 10 min read Read on X
Beginning a thread🧵 about the basics in #Python you need to know for #Django👇

Django is a #webframework to build interactive #websites for Python and is great for fast #development
1/ 19 Variables are used to store information, so that they can be used later on in your code.
In Python a ‘string’ is text and a ‘integer’ or ‘float’ is a number
‘car_brand’ and ‘brand_type’ are variables in the example below

Variables can be stored inside other variables
2/19
No special signs are allowed to be used in the name of variables, except for ‘_’ like.
Numbers are allowed in the name of a variable, but not at the start
So ‘1car’ is not OK and ‘car1’ is OK.
3/19
Lists

Lists store multiple pieces of information in a specific order.
A list always starts and ends with a square bracket ‘[‘ ‘]’.
Python starts counting at 0.
So the position or index number of the first item in the list is 0.
to print the first item, use #Code1
We can add items to the list by using the ‘append’ function.
See #Code2
A ‘for loop’ or looping allows you to perform the same action for multiple items in a list or group of items
4/19
A Tuple contains multiple items like a list.
The big difference is that a Tuple is immutable.
Which basically means you can’t change the values in a tuple
Unlike a list which is mutable or changeable
5/19
A dictionary is similar to a list.
It contains a set of item, but each item is associated with a key.
See below
The part before the colon is the ‘key’ and the part after the colon is the ‘value’
Together they are called a ‘key-value pair’.
6/19
The if statement is used in python when the program has to consider conditions
And reply in a certain way depending on the condition
7/19
While loops

The while loop continues the loop as long as a condition is valid
This code will continue to print the variable number
Adding 1 to the value in every iteration
Until the value 5 is reached
8/19
Functions
A function is a block of code that is written for a specific job
The function can be called by using the name of the function
Here’s an example
9/19

Functions part two

A keyword argument is a name-value pair, which directly links the argument to the parameter inside a function allowing to ignore the order inside a function.
10/19

Classes

A class defines the type of information an object can store and what functions it can do
Here’s an example
11/19

A class can use attributes and methods from another class. This is called inheritance.
12/19
BASIC DJANGO - now let's get into django

Best practice is to install django in a virtual environment
A virtual environment is an isolated environment where you can develop safely without
13/19

Create a project
To start with django you need to create a project, app, database and server
14/19

Include the app in the settings.py file inside your project.
Django doesn’t know our app exists yet, this way we tell django that there is an app called ‘myfirstapp’
15/19 Django is structured as follows.
When a user types audi.com/about.

This is what happens:
Urls.py -> views.py -> Model(if there is one) -> template
The urls.py contains the location of the page
the views.py contains the content of the page
The models.py contains the data of the page
The template contains the structure and styling of the page

Create the content of your page in the views.py file inside your app
16/19
Create an ‘urls.py’ file inside your app and configure the links inside the app
17/19
Create a ‘templates’ folder inside your app. Create a home.html file inside your text editor with the following html tag: <h1> Hello </h1>. Put the file ‘home.html’ inside your templates folder.
18/19
This time go to the urls.py file in your project, not your app and include a reference to the urls.py file of your app. Don’t forget to write ‘include’ after ‘path’ on the import line.
19/19
you have learned how to create a basic django structure with one webpage

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Raza Rython 📜

Raza Rython 📜 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @razacodes

Mar 21, 2022
Start developing on the blockchain with Python

Web3 py enables you to interact with the Ethereum chain using python!

Let me show how to use it 👇 Image
First setup your develop environment.
We need a virtual environment and install the web3 py in it.
A virtual environment is a safe isolated environment, where you can develop and install python libraries, without affecting your pc if something goes wrong.
Create a virtual environment by typing this in the terminal:
python3 -m venv ./myenv

To activate the virtual environment, type this in the folder where you see the virtual environment. I called mine 'myv':
source ./myenv/bin/activate

Then install web3 py:
pip install web3 Image
Read 11 tweets
Dec 31, 2021
Start building in Web3 today!

Mint your NFT and sell it in YOUR coins(token) on YOUR marketplace!

Check out an easy to follow recipe!

You can pick Python, No-Code or even...ugh...javashit

Check it out 👇

Now go and code some Python
These are the 4 steps you need to follow.

To check out the recipe yourself, go here:
thirdweb.com/portal/learn/r…
If you haven't already...go to bit.ly/33CGbcu and get started with the dashboard.

Follow the steps:
1. connect your wallet
2. pick a network
3. create a project

Check out this guide on how to create projects and modules:
thirdweb.com/portal/learn/i…
Read 8 tweets
Nov 21, 2021
You can create your own coins on the blockchain with Python

Here is how 🧵
We will use the Python SDK build by thirdweb to create tokens.
We can use these tokens as currency or coins.

Before you start, make usre you have a MetaMask wallet.
If you don't have one, check out this guide:

thirdweb.com/portal/guides/…
Next head over to thirdweb.com/start, you will be guided through a setup process.

These steps are to get your metamask setup with the thirdweb interface.
Read 17 tweets
Nov 19, 2021
MINT AN NFT IN 15 LINES OF PYTHON

As promised, i'm bringing it to to y'all!

Using Python in the Web3 space.

Here's the code.

A thread 🧵 explaining the code and steps we need to take.

LET'S GO

Now go and code some Python Python code on how to mint an NFT
Minting an nft with the Python sdk developed by @thirdweb_ requires a couple of steps.
We need to create a project in the dashboard and create an NFT module inside our project. We also need to connect a wallet. So if you don't have one, sign up with MetaMask or CoinWallet.
For the first part we need to take some steps in the dashboard at thirdweb.com/dashboard
Right now these steps are not in the Python sdk yet, but the team @thirdweb_ is working hard to get it all in the SDK.
If you want early access to the thirdweb go to thirdweb.com
Read 21 tweets
Nov 15, 2021
What can you do in Web3?

How can you use blockchain?
Wait what exactly can you do with a blockchain?

These were also questions that I had!

Let's continue where we left of and dive in slightly deeper before we use Python to do some web3 stuff.

A (MEGA) thread🧵 👇
Here's my first thread, talking about the basics.
Check it out before reading this thread!

Remember I explained that a blockchain is a ledger.
A ledger comes from the accounting world.

In the olden days it was actually a book.
I think a red one.

But this book held all the transactions all the financial records of the company.

And this book has a rule.
Read 22 tweets
Nov 15, 2021
DON'T MISS OUT!

Do you guys know @kvncnls aka KavKav?

No!?

A thread👇
Kavkav is in the dev dao @developer_dao (just like me
This is Kavkav with a mask
Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(