This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------some_app/admin.py------------- | |
from django.contrib import admin | |
from django.contrib.auth.admin import UserAdmin | |
from .models import User | |
class CustomUserAdmin(UserAdmin): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some_app/__init__.py | |
# some_app is the name of the app. | |
default_app_config = 'some_app.apps.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load my_template_tag %} <!-- Loading the file we defined our template tags in --> | |
{% for pdt in products %} | |
<tr> | |
<td>{{pdt.name}}</td> | |
<td>{{pdt.price}}</td> | |
<td>{{pdt.sold_by}}</td> | |
<td>{% n_reviews pdt.id %}</td> | |
<!-- our template tag, pdt.id is passed as argument in n_reviews function --> | |
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<title>Tweets page</title> | |
<head></head> | |
<body> | |
{% for tweet in tweets %} | |
{{ tweet.tweet }} | |
{{ tweet.likes }} | |
<button data-tweet="{{ tweet.id }}" data-action='like'>Like</button> | |
<br><br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from .models import Post | |
@admin.register(Post) | |
class PostAdmin(admin.ModelAdmin): | |
class Media: | |
js = ('tinyInject.js',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker pull redis // can be found from docker hub | |
docker images // all existing images | |
docker run redis:4.0 // pulls image and starts container | |
docker run redis // starts the image in a container | |
docker run -p6000:6379 redis // starts container at 6000 laptop port -> 6379 container port. | |
docker run -d redis // runs container in detached (bg) mode, and only returns id of container | |
docker stop <id> // stops a running container | |
docker start <id> // starts a previously stopped container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- \l gives the details of databases in psql. | |
// create a database | |
CREATE DATABASE test; | |
//close the prompt and start again. | |
// enter db name to be test | |
// to create a table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.js | |
import React from 'react' | |
import './App.css' | |
const App = () => { | |
return ( | |
<> | |
<img className='img' src='./images/1.jpg'/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// some of the most commonly used status codes. | |
const status_code = { | |
'OK': 200, | |
'CREATED': 201, | |
'NO_CONTENT': 204, | |
'NOT_MODIFIED': 304, | |
'BAD_REQUEST': 400, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x = 10; | |
if(x & 1) cout<<"odd"; | |
else cout<<"even"; | |
cout<<endl; |