Hello :) (sorry I'm French)
When I create a ticket (for a blog), I select various tags.
I would save these with the save_model and save_tagged_items methods
below :
<code type="python">
class TicketAdmin(admin.ModelAdmin):
# ...
def save_model(self, request, ticket, form, change):
# Save the author if it's a new ticket
if not change:
ticket.author = request.user
ticket.save()
# Save tags
self.save_tagged_items(ticket, form)
def save_tagged_items(self, ticket, form):
for tag in form.cleaned_data['tags']:
print tag
ti = TaggedItem(tag=tag, item=ticket)
print ti
ti.save()
print ti.id
print TaggedItem.objects.all()
</code>
It seems to be a success :
http://nsa03.casimages.com/img/2008/12/23/08122311171655683.png
But in ma table (django_tagged_item), there is nothing ! It's empty.
I don't understand why, have you a solution ?
Thanks !
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---