17

Example:

class Route(models.Model):
    last_waypoint_visited = models.ForeignKey('WayPoint')

class WayPoint(models.Model):
    route = models.ForeignKey(Route)

Since WayPoint already has a reference to Route through the route field, I don't really need the field last_waypoint_visited to generate a back reference to Route.

Is it possible do just disable the back reference creation for the "last_waypoint_visited" field?

1 Answer 1

24

Yes, disabling backward relations is a documented feature:

last_waypoint_visited = models.ForeignKey('WayPoint', related_name='+')
2
  • 2
    None ...or even - would make more sense.
    – Matt
    Oct 27, 2018 at 16:17
  • 1
    None make sense, please make a pull request in django.
    – suhailvs
    Nov 30, 2018 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.