Hash: SHA256
On 01/12/10 12:48, Ferran wrote:
> I've thought maybe i can implement contacts and ns fields in both
> DomainOwned and DomainPending, using generic relationships, but it
> does not seems right to me.
Shame on me.
This is the right way to do it, the only way, in fact.
I really want django to solve it with his own magic, but... no.
My solution:
# class DomainUbi
change:
contacts = models.ManyToManyField(
contacts.Contact,
through='ContactType'
)
to:
contacts = GenericRelation('ContactType')
# class ContactType
change:
domain = models.ForeignKey(DomainUbi)
to:
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey()
change:
unique_together = ('contact', 'domain', 'role')
to:
unique_together = ('contact', 'role', 'content_type', 'object_id')
Thank you!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBCAAGBQJM9ncHAAoJEAWOKfEESaOwVYQP/1V6w8UZn1NkLWS3YC49QDkC
QRlLpzUNH13pkYOXYF+2kEL6x1ZGCyL2G33R86485Ea/KP8kLo0TJT+nEn2sjFaW
0adG13w6yoXsE0Khot9vqDwKzqBKhpt2SMXxs4nCGjE66D1bUjRutq/xMgIY8EM+
6DJr1B7u1/n5jH/TKOOmfn3xcpo16Fe3rYc5udVoxa6tWdbMHIakozI2pkec+AMU
kDOlQg3OROCSSzurcjCybN4YNRW6bEM+9auh/jPaRXTry9vfy7wZyCn0Oije9knL
8l0v2JUZbmZTlZpFTX+oM/sziKN8s6EhgDWBH3Ii3WwapMFcEMa9vo8Ejb7SQUPL
HlfCxjjkeOHP07Eb/OkpWO7uACA2SF2Z4XLLG3+kxT9fP6trwRa2N0/8pZ+JFDh2
/ujTtGCGQIfG5dbjXB3sZfmT6h191MKMhKSpxmGfpH1JqFVQ6NIc7Kd3OwnKYi99
bYlFb3O1j2MwslTxrMxhhMOizdo0QEIbUYIdHCYXyes4ibecD7ZufT2tF6D/Y4P+
BLzj5ASqyRrnfWHNq1NRjLHm0CT27iXhMjn4AQjXae9vp1gUNMwA6d5h0LQmahTG
2bQ8VOxWvHwbjbJpTjHIcGt4396hkTa/Zcca4JuD5MwdHGvc8tqgpM4JYv9vw4m4
JM8ncLHB8bem+UoiquGk
=BCc+
-----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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment