I'm completely stumped as to why this isn't working:
flight = Flight.objects.get(pk=flight_id)
print "old", flight.route.pk ## `route` is a ForeignKey field to model Route
print "new", new_route.pk
flight.route=new_route # new_route is a newly created Route object
flight.save()
print "db", Flight.objects.get(pk=flight_id).route.pk
this is the output:
old 4800
new 7617
db 4800
Is there some special way I need to call save() on the flight to get it to actually save?
edit: my models look like this:
class Flight(models.Model):
route = models.ForeignKey(Route, blank=True, null=True, related_name="flight")
class Route(models.model):
# a bunch of CharFields and IntegerFields