hi.
I have a many to many table in django, which I'm having troubles updating.
class Keyword( meta.Model ):
URL = meta.URLField(core=True)
pagetype = meta.ForeignKey( PageType, verbose_name="the type of page")
regex = meta.CharField(maxlength=250)
to_match = meta.BooleanField()
description = meta.CharField(maxlength=255)
what_testing = meta.TextField(verbose_name="What are you testing")
tags = meta.ManyToManyField(Tag,blank=True)
tagField = meta.CharField(maxlength=255,
blank=True,verbose_name="List of tags you would like to categorize
this
post as")
def _pre_save(self):
from django.models.conf import *
tagnames = self.tagField.split()
taglist = []
for tagname in tagnames:
try:
tag_ref = tags.get_object(name__exact = tagname.lower())
except tags.TagDoesNotExist,msg:
tag_ref = Tag(name=tagname.lower())
tag_ref.save()
taglist.append(tag_ref.id)
self.set_tags(taglist)
when I run the following from a python command line it works nicely.
>>> from django.models.conf import *
>>> a=keywords.get_object(id__exact=1)
>>> a.tagField="moo baa lah lah"
>>> a.save()
>>> a.get_tag_list()
[moo, baa, lah]
but when I use the generic update view from a web page it deletes the
reference (and it also removes the page-type Foreign key as well.
any hints would be appreciated.. this has me stuck ;(
--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti