Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import sys
import requests
def get_info(terrible_key, cluster, product=None):
if product:
url = 'https://terrible.sanomaservices.nl/env/list/{}/{}'.format(cluster, product)
else:
@ddaan
ddaan / used_in.py
Last active June 8, 2016 09:25
Add this method to your django model to quickly retrieve every object that links to it.
def used_in(self):
"""
Method to return all objects where this object is linked from by
a foreign key or many-to-many relationship
Be aware that:
- Calling this method wil result in as many queries as there are
relations, so use this carefully.
- It will only see the models linking directly to this model. So watch
out for inherited models. Calling used_in on a childobject will