Reference

django_model_info

Commands

modelinfo

class django_model_info.management.commands.modelinfo.Command(*args, **kwargs)[source]

A Django management command to list out the fields and methods for each model.

__init__(*args, **kwargs)[source]
add_arguments(parser)[source]

Add custom arguments to the command.

Parameters:

parser (CommandParser)

append_abstract_models()[source]

Retrieve abstract models.

For each model in the model list, we get MRO, and add any class in the MRO that is in the same app as the model.

create_parser(prog_name, subcommand, **kwargs)[source]

Create and return the ArgumentParser which will be used to parse the arguments to this command.

Reimplemented to allow new default verbosity of 2.

Parameters:
  • prog_name (str)

  • subcommand (str)

export_markdown(models)[source]

Generate markdown documentation for Django models.

Parameters:

models (list[Any])

Return type:

str

export_results()[source]

Handle export functionality.

filter_models()[source]

Get the list of filtered models based on user input.

get_clean_method_list(model)[source]

Clean method list by removing uppercase and non-callable methods.

get_model_list()[source]

Retrieve models based on filter option or return all models.

get_options(options)[source]

Get verbosity, filter, and export options.

Return type:

tuple

handle(*_, **options)[source]

Handle the command.

render_field_other_table(title, data_list)[source]

Render table for other fields.

render_field_relations_table(title, data_list)[source]

Render table for field relations.

render_field_reverse_relations_table(title, data_list)[source]

Render table for field reverse relations.

render_manager_table(model)[source]

Render manager information.

render_method_table(title, data_list)[source]

Render table for methods.

render_methods(method_info)[source]

Render tables for methods.

render_modelinfo(modelinfo)[source]

Render model information.

render_other_fields(fields_other)[source]

Render tables for fields.

render_relation_fields(fields_relation)[source]

Render tables for fields.

render_reverse_relation_fields(fields_reverse_relation)[source]

Render tables for fields.

modelfilters

class django_model_info.management.commands.modelfilters.Command(*args, **kwargs)[source]

Display model field relationships in tabular format.

__init__(*args, **kwargs)[source]
add_arguments(parser)[source]

Add command arguments.

Parameters:

parser (CommandParser)

Return type:

None

export_markdown(models, options)[source]

Export markdown content.

Parameters:
Return type:

str

export_results(models=None, options=None)[source]

Handle export functionality.

get_filtered_models(filters, prefix=None)[source]

Get models based on filter arguments.

Parameters:
Return type:

list[Any]

get_options(options)[source]

Get verbosity, filter, and export options.

Return type:

tuple

get_table_data(model, options)[source]

Get field data for a model.

Parameters:
Return type:

list[list[str]]

handle(*args, **options)[source]

Execute command.

Parameters:
Return type:

None

print_markdown(model, data)[source]

Print table in markdown format.

Parameters:
Return type:

None

print_table(model, data)[source]

Print table using rich.

Parameters:
Return type:

None

process_exclude_patterns(excludes)[source]

Process exclude patterns to handle both app and model exclusions.

Examples

  • ‘Permission’ -> [‘Permission’]

  • ‘auth.Permission’ -> [‘auth.Permission’]

  • ‘auth’ -> [‘User’, ‘Group’, ‘Permission’, …] (all auth models)

Parameters:

excludes (list[str])

Return type:

list[str]

modelgraph

class django_model_info.management.commands.modelgraph.Command(*args, **kwargs)[source]

Django management command to generate model relationship graphs.

Parameters:
__init__(*args, **kwargs)[source]
Parameters:
Return type:

None

add_arguments(parser)[source]

Add command arguments.

Parameters:

parser (CommandParser)

Return type:

None

handle(*args, **options)[source]

Handle the command execution.

Parameters:
Return type:

None

migrationgraph

class django_model_info.management.commands.migrationgraph.Command(*args, **kwargs)[source]

A management command to Visualize migrations and dependencies for applications in the project.

__init__(*args, **kwargs)[source]
add_arguments(parser)[source]

Add optional argument to specify apps to show migrations for.

handle(*args, **options)[source]

Handle the command.