join - DJANGO: many-to-many relationship with additional fields -


new programming , confusing me... have 2 models. department , crossfunctionalproject. relationship between 2 models creates join table called department_crossfunctionalproject.

i have model called employee. want add employees department_crossfunctionalproject table. how can this?

i've been following tutorial: https://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships. can not on automatically created department_crossfunctionalproject join table django creates?

i keep getting following error:

commanderror("one or more models did not validate:\n%s" % error_text)  django.core.management.base.commanderror: 1 or more models did not validate: companydatabase.membership:"department_crossfunctionalproject" has relationship model <class 'companydatabase.models.department_crossfunctionalproject'>,  has either not been installed or abstract. 

models:

class crossfunctionalproject(models.model):     nameofproject = models.charfield(max_length=50)     def __unicode__(self):         return self.nameofproject  class department(models.model):     name = models.charfield(max_length=100)     project = models.manytomanyfield(crossfunctionalproject, null=true, blank=true)  class employee(models.model):     employeenumber = models.charfield(max_length=50)     fname = models.charfield(max_length=50, verbose_name='first name')     mname = models.charfield(max_length=50, null=true, blank=true, verbose_name='middle name')     lname = models.charfield(max_length=50, verbose_name='last name')     email = models.emailfield(null=true, blank=true, verbose_name='email')     phone = models.charfield(max_length=50, null=true, blank=true, verbose_name='phone')     title = models.charfield(max_length=50, null=true, blank=true, verbose_name='position')  # db table created django, wrote out model, trying add columns* class department_crossfunctionalproject(models.model):     department = models.foreignkey(department)     crossfunctionalproject = models.foreignkey(crossfunctonalproject)     membership = models.manytomanyfield(employee, through="membership")  class membership(models.model):     employee = models.foreignkey(employee)     department_crossfunctionalproject = models.foreignkey(department_crossfunctionalproject)         whytheyjoined = models.charfield(max_length=100) 

the problem define department_crossfunctionalproject before 'employee'. try providing name of employee model string:

membership = models.manytomanyfield('employee', through="membership") 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -