Skip to content

Instantly share code, notes, and snippets.

@0xMrCats0x
0xMrCats0x / models.py
Created May 20, 2021 07:14 — forked from jacobian/models.py
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
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 __unicode__(self):
@0xMrCats0x
0xMrCats0x / python_emails.py
Created February 12, 2021 20:47 — forked from brayvasq/python_emails.py
Send emails with Python and Gmail SMTP server
# main.py
# Import section ....
import os
import sys
from dotenv import load_dotenv
from smtplib import SMTP, SMTPException # Import SMTP module
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
import email.encoders