Re: Optional m2m relationships in Admin

2009-02-04 Thread GeneralMean
bj, form, change) if not change: tag = Tags.objects.get(pk=2) obj.tag.add(tag) #the best part - not asserting anything #assert null What's going on behind the scene? I'm runnin' out of ideas, please, help. > On Feb 4, 3:04 pm,

Re: Optional m2m relationships in Admin

2009-02-04 Thread GeneralMean
>On 4 Lut, 20:52, koenb wrote: > Shouldn't this be obj.tags.add(tag) ? (your m2mfield is called tags > not tag) Typo... It actually should say obj.tag.add(tag) - I wasn't pasting this code, wrote it by hand ;) Actual code has no syntax errors :) --~--~-~--~~~---~--~--

Re: Optional m2m relationships in Admin

2009-02-04 Thread GeneralMean
On 4 Lut, 20:24, garagefan wrote: > From my limited understanding of Django... > > the admin.py stuff should not contain any save function. > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a... Hmm, take a look at this then: http://docs.djangoproject.com/en/dev/ref/contrib

Re: Optional m2m relationships in Admin

2009-02-04 Thread GeneralMean
Thanks for the answer, I modified my Game model according to your suggestion, and also, simplified whole thing. I can create new game without having to choose any tags - that's correct. Now, take a look at the save_model() method in GamesAdmin - I try to associate newly created Game with some tag

Optional m2m relationships in Admin

2009-02-04 Thread GeneralMean
This is a huge one: I want to implement an optional m2m realtionship in django admin application, so it is possible to create a new Game (model description below) without choosing any tags associated with it. By default django form validation returns an error when I try to do such thing. So I cre