Here’s an example of how to set a default value for a models.ForeignKey field:
class Foo(models.Model):
a = models.CharField(max_length=10)
def get_foo():
return Foo.objects.get(id=1)
class Bar(models.Model):
b = models.CharField(max_length=10)
a = models.ForeignKey(Foo, default=get_foo)
Hope this helps someone (I’ve been looking for this quite some time…). If anyone know a better/neater way, please let us know in the comments!!