-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Rowell wrote:
> class Varietal(models.Model):
>   name = models.CharField()
> 
> class Vineyard(models.Model):
>   name = models.CharField()
>   varietals = models.ManyToManyField(Varietal)
> 
> This site is devoted almost exclusively to Pinot Noir, so 90% of the
> Vineyards are planted to Pinot Noir, but some are also planted to
> Pinont Gris, Gamay Noir, etc.
> 
> 1. Is it possible to express a default for a ManyToMany field? How?
> Docs? Having a callable here (e.g., default=some_function) feels about
> right, but the problem is that it needs to be called when we are first
> creating the new object, which means it hasn't been saved yet, so it
> has no id, and therefore we don't have enough info to do a
> vineyard.varietals.add(<the object for Pinot Noir>)

> Am I missing something really obvious?

How about writing your own constructor that takes an argument of type
and has a default value assigned there?

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhGn78ACgkQw3vjPfF7QfWkIwCfZNY2LsS5Z7qmIQMRdW/7WMKn
MgUAoKZnclcxqr9cS7/NTxp6ywFrrhei
=1cLs
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to