Reputation: 131
Here is a brief sample of the model setup and the query I am trying. This didn't give me any errors in Django 1.6, but in 1.7 it gives me an exception. The "implicit" foreign key is not available on the Interface queryset, it seems. I tried both select_related('gwportprefix') and prefetch_related('gwportprefix') with no luck.
class Interface(models.Model):
# Several fields here that are not related.
pass
class GwPortPrefix(models.Model):
interface = models.ForeignKey('Interface', db_column='interfaceid')
for gwport in Interface.objects.filter(gwportprefix__isnull=False):
gwport_matches.add(gwport)
This gives the following FieldError:
Cannot resolve keyword 'gwportprefix' into field. Choices are (Everything directly on Interface. No implicit foreignkeys)
Upvotes: 0
Views: 239
Reputation: 3806
in django 1.7 many changes occurred in the QuerySet / Manager implementation. Have you tried ?
Interface.objects.filter(gwportprefix_set__isnull=False)
Upvotes: 1