Login

Tag "inspectdb"

Snippet List

inspectdb fixer

This snippet parses the output file of inspectdb and does some alterations. Mostly useful for people who regenerates models from constantly changing legacy databases. The snippet will: *Add quotes around foreign key classes, so the ordering is not significant *Append a related_name property to each foreign key with the value model class name + db_column name to evade collisions in reverse queries like: example.model: Reverse query name for field 'foreignkey' clashes with related field 'model2.foreignkey'. Add a related_name argument to the definition for 'foreignkey'. There's a slight performance degradation with using quotes class name instead of passing the class though.

  • models
  • inspectdb
  • database-import
Read More

A small script to rearranging the models generated from inspectdb command

`python manage.py inspectdb` allows you to generate the models from a legacy database. The generated model classes are not arranged by dependencies. When the number of tables is big, it becomes really painful to rearrange by hand. This small script should rearrange the models for you. It doesn't solve every problem with generated models, but it makes our the process easier

  • admin
  • inspectdb
  • arrangement
Read More

3 snippets posted so far.