Changes between Initial Version and Version 1 of Ticket #17167


Ignore:
Timestamp:
Nov 5, 2011, 12:22:44 PM (13 years ago)
Author:
Karen Tracey
Comment:

Fixed formatting. PLEASE use WikiFormatting and preview before posting.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17167 – Description

    initial v1  
    22
    33The tables contain these rows:
    4 
     4{{{
    55employee
    66username | department_id
     
    11111 | 'Dept1'
    12122 | 'Dept2'
    13 
     13}}}
    1414
    1515The models are as follows:
    16 
     16{{{
     17#!python
    1718class Department(models.Model):
    1819    name = models.CharField(max_length=32)
     
    2930    class Meta:
    3031        model = Employee
    31 
     32}}}
    3233
    3334In a view:
     35{{{
     36#!python
    3437emp = Employee.objects.using('my_employee').get(id=1)
    3538
     
    4043
    4144print frm
    42 
     45}}}
    4346This generates a DatabaseError Exception, relation 'department' does not exist. It exists in the secondary database, but not in the default database.
    4447
     
    4649
    4750In default database:
     51{{{
    4852department
    4953department_id | name
     
    51552 | 'DefaultDBDept2'
    5256
    53 
     57}}}
    5458
    5559No employee table exists in default database. The view below:
    5660
     61{{{
     62#!python
    5763emp = Employee.objects.using('my_employee').get(id=1)
    5864
     
    6369
    6470print frm
    65 
     71}}}
    6672This generates a form as normal, but the Department details from the default database are included instead of details from the secondary database. So, two select options are created with the labels 'DefaultDBDept1' and 'DefaultDBDept2' and the selected one is correctly 'DefaultDBDept1.' If I update the secondary table so that employee 'mark' has department_id 2, the selected option is 'DefaultDBDept2.' If I remove the default department table, the DatabaseError exception, relation 'department' does not exist, returns.
Back to Top