Changes between Initial Version and Version 1 of Ticket #17167
- Timestamp:
- Nov 5, 2011, 12:22:44 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #17167 – Description
initial v1 2 2 3 3 The tables contain these rows: 4 4 {{{ 5 5 employee 6 6 username | department_id … … 11 11 1 | 'Dept1' 12 12 2 | 'Dept2' 13 13 }}} 14 14 15 15 The models are as follows: 16 16 {{{ 17 #!python 17 18 class Department(models.Model): 18 19 name = models.CharField(max_length=32) … … 29 30 class Meta: 30 31 model = Employee 31 32 }}} 32 33 33 34 In a view: 35 {{{ 36 #!python 34 37 emp = Employee.objects.using('my_employee').get(id=1) 35 38 … … 40 43 41 44 print frm 42 45 }}} 43 46 This generates a DatabaseError Exception, relation 'department' does not exist. It exists in the secondary database, but not in the default database. 44 47 … … 46 49 47 50 In default database: 51 {{{ 48 52 department 49 53 department_id | name … … 51 55 2 | 'DefaultDBDept2' 52 56 53 57 }}} 54 58 55 59 No employee table exists in default database. The view below: 56 60 61 {{{ 62 #!python 57 63 emp = Employee.objects.using('my_employee').get(id=1) 58 64 … … 63 69 64 70 print frm 65 71 }}} 66 72 This 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.