Default to current/all sites in admin (updated!)

1
2
3
4
5
def get_default_sites():
    return [site.id for site in Site.objects.all()]

class MyModel(models.Model):
    sites = models.ManyToManyField(Site, default=get_default_sites)

More like this

  1. Creator/updater fields for admin by baumer1122 4 years, 10 months ago
  2. Bulk Insert - updated 5/9/2008 by coolie 5 years, 7 months ago
  3. Limit ManyToMany fields in forms by jedie 3 years, 9 months ago
  4. Add delete buttons to admin changelist by kylefox 6 years ago
  5. Admin App/Model Custom Ordering by stephen_mcd 3 years, 2 months ago

Comments

(Forgotten your password?)