On 13/12/2013 9:13pm, Hervé Edorh wrote:
Hi, I have a problem with a charfield foreign key. this my model
class Region(models.Model):
""" Class décrivant la table Region """
code_region = models.CharField(max_length=15, primary_key=True)
name = models.CharField(max_length=25,null=True,blank=True)
class Departement(models.Model):
""" Class décrivant la table Département """
code_dept = models.CharField(max_length=15, primary_key=True)
name = models.CharField(max_length=25,null=True,blank=True)
region = models.ForeignKey(Region, null=True,blank=True)
when i sync the database i have this error
django.contrib.contenttypes.models.DoesNotExist: ContentType
matching query does not exist.
what is the meaning of this error and how can i solve it?
It is generally unconventional to have primary keys which have business
meaning. To solve the problem remove 'primary_key=True' from both
classes and rely on Django to give them their primary keys. You will
have to migrate the tables accordingly or delete them and sync again.
If necessary you can add a unique constraint to the code_region and
code_dept columns to ensure duplicates don't happen. unique=True
hth
Mike
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/bbe488dd-d4c4-4940-8e2d-8d23adcc9b83%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/52AB7B85.9020305%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.