I’m trying to set up piston on my Django project. I ran into a brick wall when I tried to POST (create) a new entry on a model that contains a ForeignKey: location.
Here is the exact error I receive:
Cannot assign “u’1′”: “Fest.location” must be a “Location” instance.
In the above example, I tried to send over location=1 in the POST.
What am I doing wrong here? Surely Foreign Keys are supported on CREATEs…
Update:
To be clear, I’m using PISTON to handle these REST API requests. My Handler currently looks like this:
class FestHandler(BaseHandler):
model = Fest`
You need to assign an actual object. Something like the following should work:
where
objis the model you’re trying to save which has location as a foreign key.