#17167: ModelForm model=class not honoring reference fields with secondary 
database
-------------------------------------+-------------------------------------
     Reporter:  furbeenator@…        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Forms                |                  Version:  1.3
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  ModelForm, using(),  |             Triage Stage:
  foreign key, reference field       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by anonymous):

 Thank you for your help, Karen. The issue is that everything is honored up
 to the point that I use the employee as an instance to a ModelForm. This
 works fine and the employee's department name is printed:
 {{{
 #!python
 employee = Employee.objects.using('my_employee').get(id=1)
 print employee.department.name
 }}}

 As soon as I assign a ModelForm:

 {{{
 #!python
 frm = EmployeeForm(instance=employee)
 print frm
 }}}
 The DatabaseError Exception is raised. What I was explaining in the
 original post was that if I have a table in the default database that has
 the name department, it works to attach the employee from 'my_employee' to
 the corresponding department from default. Perhaps I added TOO much detail
 in the original description. I have been trying to nail down exactly what
 the behavior is.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17167#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to