*What's been done so far:*

   - I was on Django 1.5 and upgraded to 1.6 (cannot go higher as we are on 
   Python 2.6) and this did not solve the problem.
   - I have researched this issue to death and cannot seem to find a 
   definite answer. Looking through the Django Project Bug Tracker, I have 
   seen similar issues but none seem to fit my particular case
   - I have resolved the problem in the past using a raw SQL call to 
   replace for example affpart.damage_types.all() with a custom function 
   but this is starting to happen more frequently now and is becoming a real 
   pain.

*Description:*

I have two Django apps under one project. One of the apps makes use of 
models in another app using a many-to-many relationship.

This has been working smoothly for months, and in fact it works fine on my 
production machine but fails on my development machine. The scenario lately 
has been that I am asked to add a new feature and when I start to work on 
it I get a FieldError in related code which I haven't even touched.

The offending line of code for this latest issue is: for dt in 
affpart.damage_types.all()

The error is:

Cannot resolve keyword u'affectedpart' into field. Choices are: 
cgs_damage_code, description, id, reg_exp, sti

The error occurs in the bowels of Django in the query.py module.

>From a high-level, this error occurs when I am trying to use a Many-to-many 
between models in different Django apps. For example, an affected part can 
have more than one type of damage and a damage type can be found on 
different affected parts.

The two apps are: trending and sitar

sitar was built first and has the models that I want to use from trending.

In trending, my models.py file has an AffectedPart model something like 
this:

from sitar.models import (Part, DamageType, Aircraft)
class AffectedPart(models.Model):
...

    occurrence_date = models.DateField()
    partnumber = models.ForeignKey(Part)
    damage_types = models.ManyToManyField(DamageType, null=True, blank=True)
    repair_types = models.ManyToManyField(RepairType, null=True, blank=True)

.If anyone has a solution to this or knows of best practices for models in 
one application having many-to-many relationships with models in another 
application I would love to hear it.

Thanks

-- 
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/beba2cda-7beb-4d1b-896a-497366759b58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to