﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11448	Defining relationships after querying a model does not add a reverse lookup to the referenced model	Dennis Kaarsemaker	nobody	"Ok, that sounds vague but I don't know how to better describe it. Basically it boils down to having this in models.py:

{{{
from django.db import models
import os

class c1(models.Model):
    name = models.CharField(""Name"", max_length=30)

default_c1 = c1.objects.get(name=""non_existant"")

class c2(models.Model):
    other = models.ForeignKey(c1, default=default_c1)
}}}

Querying c1 later with `c1.objects.filter(c2__pk=0)` will fail: 
{{{
FieldError: Cannot resolve keyword 'c2' into field. Choices are: id, name
}}}
Minimal testcase project attached (models.py is slightly bigger than above). You can reproduce the problem with:

{{{
# Create the database (clobbers test.db in the current dir)
./manage.py syncdb
# See that without querying in between it works
echo -e ""from proj1.app1.models import c1\nc1.objects.filter(c2__pk=0)"" | ./manage.py shell
# See that with querying in between it fails
echo -e ""from proj1.app1.models import c1\nc1.objects.filter(c2__pk=0)"" | BREAK_ME=1 ./manage.py shell
}}}

Found on 1.0.2, confirmed with trunk (fresh checkout, less than 30 minutes ago)"	Bug	new	Database layer (models, ORM)	dev	Normal			dennis.kaarsemaker@… jrose@… Anton Strogonoff	Accepted	1	0	0	1	0	0
