Skip to content

Instantly share code, notes, and snippets.

View Flexonze's full-sized avatar

Félix Gravel Flexonze

View GitHub Profile

django autocomplete filtering

Context

If you need to override an autocomplete's behaviour based on its use in a django form, it is how I managed to do it.

Normally you would use formfield_for_foreignkey but when using autocomplete_fields is not taken in account by django admin.

Note: this is not dynamic based based on the values in the form

static file to add

@jrobichaud
jrobichaud / django_naming_things.md
Last active March 7, 2024 00:32
An attempt to create a class naming style for django

Premise

Django code style is well documented however the documentation has no statement on how to name classes. When digging the documentation we can find various examples that does not follow an obvious standard.

Abstract base class documentation

from django.db import models

class CommonInfo(models.Model):
    name = models.CharField(max_length=100)
 age = models.PositiveIntegerField()