Skip to content

Instantly share code, notes, and snippets.

@austincollinpena
austincollinpena / Command Line
Created March 5, 2020 16:52
Dump Django Data excluding User Data
./manage.py dumpdata --exclude auth.permission --exclude contenttypes > db.json
@austincollinpena
austincollinpena / Terminal.py
Created March 5, 2020 16:43
Set Up PostgresDjango (When it's already installed)
psql -U postgres # "postgres" is the username. You'll be prompted to put in a password like "admin"
# You'll be presented with the postgres shell
# Create your new user and table
CREATE USER <name> WITH PASSWORD '<password>'; # Remove the "<>" symbols
CREATE DATABASE <db_name> WITH OWNER <name>; # Remove the "<>" symbols
@austincollinpena
austincollinpena / request.py
Created February 27, 2020 06:49
Make a curl request that requires authentication in python
numbersJSON = requests.get(
# Start with the URL
f'https://api.twilio.com/2010-04-01/Accounts/{self._account_sid}/AvailablePhoneNumbers/US/local.json?AreaCode={self.area_code}',
# Pass through your credentials like this
auth=(self._account_sid, self._auth_token))
@austincollinpena
austincollinpena / graphql.py
Created February 23, 2020 06:14
Pass an argument to a function via a graqphql mutation and return a new value
# Packages: Django-graphene, django
from graphene_django.types import DjangoObjectType
import graphene
class FetchTwilioToken(graphene.Mutation):
# Define the arguments that are passed from the client in the mutation
class Arguments:
identity = graphene.String(required=True)
# Define the arguments that might be returned that are not defined
# elsewhere. Give them a graphene type