I have a problem with an Error I dont quite understand.. when i execute the code below, i get the following Message:
ValueError: Cannot assign "[<Location: somename>]": "Event.location" must be a "Location" instance.
It clearly states that "somename" is of the type Location, but complains that its the wrong type.. what should I do? Unfortunately the interpreter doesnt give me to many hints :(
if location is not None:
location = location.group(1)
l=Location.objects.filter(name=location)
if not l:
l = Location(name=location)
l.save()
if price is not None:
price = price.group(1)
if starttime is not None:
starttime = extract_time_from_string(starttime.group(1))
if name is not None:
name = name.group(1)
if edate is not None and name is not None and l is not None:
if not Event.objects.filter(name = name, eventdate=edate,
location = l):
e= Event(location = l, name = name,
eventdate=edate, starttime=starttime,
price=price)
l=Location.objects.filter(name=location)that only one object is returned?