Django postgresql foreign key
django, foreign-keys, postgresql, python
Solution
Code looks okay upon first glance. I suspect it's a database related issue.
As the `max_length`s provided are pretty huge, try reducing the `max_length`s to something <= 255 or use a `TextField` instead of a `CharField`.
Failing this, try renaming the field `service` in `Service` and/or `ServiceCheck`.
Problem
I have this models.py ``` from django.db import models from django.contrib.auth.models import User class Service(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=800, blank=False) service = models.CharField(max_length=2000, blank=False) def __unicode__(self): return self.name class ServiceCheck(models.Model): service = models.ForeignKey(Service) check_status = models.CharField(max_length=80) check_time = models.DateTimeField() ``` When i run syncdb against postgresql it ends up with error: ``` ~/dev-md> sudo python manage.py syncdb Creating tables ... Creating table monitor_service Creating table monitor_servicecheck DatabaseError: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. ```