On 4 Lut, 21:25, garagefan <monkeygar...@gmail.com> wrote:
> check out django-tagging. It looks like they're using a custom Manager
> that is handling the creation of new tags based off of an object that
> is using "tags" listing new tags.

Will do.
Meantime, let's take a look again at the weirdest thing:

this DOES work (m2m relationship appear in DB):

class GamesAdmin(admin.ModelAdmin):
    def save_model(self, request, obj, form, change):
        super(GamesAdmin, self).save_model(request, obj, form, change)
        if not change:
            tag = Tags.objects.get(pk=2)
            obj.tag.add(tag)
            #the best part
            assert null

this DOESN'T work (m2m relationship doesn't appear in DB):

class GamesAdmin(admin.ModelAdmin):
    def save_model(self, request, obj, form, change):
        super(GamesAdmin, self).save_model(request, obj, 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, GeneralMean <marcin.wtorkow...@gmail.com> wrote:
>
> > >On 4 Lut, 20:52, koenb <koen.bierm...@werk.belgie.be> 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 :)
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to