Commit f3de643
committed
Support for custom tables names
Currently, the history table name is hardcoded (APP_historicalMODEL).
This pull request add support for custom tables names by adding a
`db_history_table` option.
As Django reject all unknown option in `Meta` inner class, I've added an
`History` inner class to store this option (and possibly others future
options).
```
class Organization(models.Model):
name = models.CharField(_('Organization or Name'), max_length=25)
address = models.CharField(_('Address'), max_length=250)
zipcode = models.CharField(_('Postal code'), max_length=10, null=True)
city = models.CharField(_('City'), max_length=50)
country = models.CharField(_('Country'), max_length=2, \
choices=COUNTRIES_CHOICES)
def __str__(self):
return self.name
class History:
db_history_table = 'organizations_history'
class Meta:
db_table = 'organizations'
```
TODO: Documentation.1 parent 089c5d4 commit f3de643
3 files changed
+40
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| |||
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
228 | 252 | | |
229 | 253 | | |
230 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
0 commit comments