Skip to content

Instantly share code, notes, and snippets.

View manfre's full-sized avatar

Michael Manfre manfre

View GitHub Profile
class ItemGroup(models.Model):
name = models.CharField(max_length=10)
group_type = models.CharField(max_length=10, default='test')
class Item(models.Model):
group = models.ForeignKey(ItemGroup,
related_name='items',
limit_choices_to={
'group_type__in': ('test'),
@manfre
manfre / manager.py
Created January 6, 2014 15:45
Django model manager that allows access and easy querying against read-only (computed) database fields.
class ComputedFieldsManager(models.Manager):
"""
Manager that can account for computed fields and fetch those fields, but
ensure they are not writeable.
Example usage:
objects = ComputedFieldsManager(computed_fields=['my_computed_field'])
objects = ComputedFieldsManager(computed_fields=[('my_computed_field', models.BooleanField())])

Keybase proof

I hereby claim:

  • I am manfre on github.
  • I am manfre (https://keybase.io/manfre) on keybase.
  • I have a public key whose fingerprint is 50A3 DAC5 25A5 7C63 27EB 1E3E 74DE D158 BAD0 EDF8

To claim this, I am signing this object:

@manfre
manfre / Caddyfile
Last active October 2, 2022 10:38
Authentik forward auth to microbin
{$MICROBIN_EXTERNAL_DNS:paste.myapp.local} {
# always forward outpost path to actual outpost
reverse_proxy /outpost.goauthentik.io/* {$AUTHENTIK_CONTAINER_NAME:authentik-server-1}:{$AUTHENTIK_PORT:9000}
# forward authentication to outpost
forward_auth {$AUTHENTIK_CONTAINER_NAME:authentik-server-1}:{$AUTHENTIK_PORT:9000} {
uri /outpost.goauthentik.io/auth/caddy
# capitalization of the headers is important, otherwise they will be empty