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
{ | |
"paintings": { | |
"painting": [ | |
{ | |
"title": "Boardwalk 5", | |
"artist": "Arnie Palmer", | |
"image": "ap1.jpg", | |
"price": 850 | |
}, | |
{ |
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
{ | |
"current_page": 1, | |
"data": [ | |
{ | |
"book_ids": [ | |
"a_century_of_spies", | |
"citizen_espionage", | |
"double_eagle_a01", | |
"double_eagle_a02", | |
"games_of_intelligence", |
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
pip install django-debug-toolbar | |
# Debug toolbar | |
Add to settings.py | |
def show_toolbar(request): | |
return True | |
DEBUG_TOOLBAR_CONFIG = { | |
"SHOW_TOOLBAR_CALLBACK": show_toolbar, |
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 os import getenv | |
from os.path import abspath, dirname, join | |
import dj_database_url | |
from dotenv import load_dotenv | |
load_dotenv() | |
DATABASE_URL = getenv("DATABASE_URL") |
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
#!/usr/bin/env python | |
""" | |
Install a package from your local pip download cache without having to touch | |
the 'net at all. | |
You'll need to be using a pip download cache; that is, you'll need the | |
following in your ~/.pip/pip.cfg: | |
[install] |
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
import csv | |
from django.core.management.base import BaseCommand | |
from expenditures.models import Salary | |
class Command(BaseCommand): | |
help = "Insert N Rows of Salaries" |
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.db import models | |
class Person(models.Model): | |
name = models.CharField(max_length=200) | |
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people') | |
class Meta: | |
ordering = ['name'] | |
def __str__(self): |
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.postgres.search import SearchVector | |
from django.core.management import BaseCommand | |
from myapp.models import Article | |
class Command(BaseCommand): | |
# Provide help at command prompt for user | |
help = "Add search vector articles" | |
# A command must define handle() |
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
{% extends "base.html" %} | |
{% block content %} | |
<form method="post">{% csrf_token %} | |
{{ forms.subscription }} | |
<input type="submit" value="Subscribe"> | |
</form> | |
<form method="post">{% csrf_token %} | |
{{ forms.contact }} | |
<input type="submit" value="Send"> |
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 datetime import datetime | |
from random import randint | |
import pytz | |
from django.contrib.auth import get_user_model | |
from django.core.management.base import BaseCommand | |
from django.utils import timezone | |
from faker import Faker | |
fake = Faker(["en_CA"]) |
OlderNewer