Hello,

I am new to Django and am trying to design a chemistry database in
Django and am stuck with creating the relations between the tables.

Below are my models. When I try to validate I get an error stating
that the reverse query name for field 'species2ID' clashes with m2m
fileID 'Compunds.reactions'. Add a related_name argument to the
definition for 'species2ID'. The same is repeated for species1ID.

I basically want to create two foreign keys in the reactions table
which correspond to my compounds table have a manytomany relationship
between compounds and reactions table at the same time. Can anyone
please guide me with respect to this. I can provide the schema if
needed.

Thank you.


from django.db import models

class Elements(models.Model):
    name = models.CharField(max_length = 20)
    atomicNumber = models.IntegerField(blank=True,null=True)
    atomicSymbol = models.CharField(max_length =5)
    freezingPointKelvin = models.FloatField(blank=True,null=True)
    boilingPointKelvin = models.FloatField(blank=True,null=True)
    mass = models.FloatField(blank=True,null=True)
    density = models.FloatField(blank=True,null=True)
    radiusAtomic = models.FloatField(blank=True,null=True)
    radiusIonic = models.FloatField(blank=True,null=True)
    compounds = models.ManyToManyField('Compounds')

class Compounds(models.Model):
    name= models.CharField(max_length = 30)
    mass = models.FloatField(blank=True,null=True)
    radius = models.FloatField(blank=True,null=True)
    reactions = models.ManyToManyField('Reactions')
    simulations = models.ManyToManyField('Simulations')


class Reactions(models.Model):
    species1ID = models.ForeignKey(Compounds)
    species2ID = models.ForeignKey(Compounds)
    reactionid= models.CharField(max_length = 20)

class Productsets(models.Model):
    energyReleased = models.FloatField(blank=True,null=True)
    reactions = models.ManyToManyField('Reactions')
    compounds= models.ForeignKey(Compounds)

class Simulations(models.Model):
    number = models.IntegerField(blank=True,null=True)
    name = models.TextField()
    species = models.ManyToManyField('Compounds')

class Lessons(models.Model):
    number = models.IntegerField(blank=True,null=True)
    name = models.TextField()
    simulations = models.ForeignKey(Simulations)

class Units(models.Model):
    number = models.IntegerField(blank=True,null=True)
    name = models.CharField(max_length = 40)
    lessons=models.ForeignKey(Lessons)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to