the solution is here:
#Original inspectdb
121 if rel_to in known_models:
122 field_type = 'ForeignKey(%s' % rel_to
123 else:
124 field_type = "ForeignKey('%s'" %
rel_to
#Modified inspectdb
121 if rel_to in known_models:
122 field_type = 'ForeignKey(%s' % rel_to
123 else:
124 field_type = "ForeignKey('%s'" %
rel_to
125 extra_params["related_name"] = '%s_%s' %
(table2model(table_name),column_to_field_name[column_name])
to be added to:
https://github.com/django/django/blob/master/django/core/management/commands/inspectdb.py#L131
--
Ticket URL: <https://code.djangoproject.com/ticket/30794>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Claude Paroz):
I'm not sure it is a change wanted by everyone. This can save some work in
some configurations, and add a burden in other situations where the user
don't need nor want to have related_name set.
--
Ticket URL: <https://code.djangoproject.com/ticket/30794#comment:1>
* status: new => closed
* type: Uncategorized => New feature
* version: 2.2 => master
* resolution: => duplicate
Comment:
Duplicate of #11179.
--
Ticket URL: <https://code.djangoproject.com/ticket/30794#comment:2>
--
Ticket URL: <https://code.djangoproject.com/ticket/30794#comment:3>
* status: closed => new
* resolution: duplicate =>
Comment:
Well, the problem is the models.py is generated by the utility `python
manage.py inspectdb`, then when it's loaded e.g. `python manage.py
runserver`, the system report hundreds of such errors.
If you think this feature may not be needed by everyone, at least add an
option for people who *actually* need it; otherwise, these users have to
do hundreds of modification on the *generated* file.
--
Ticket URL: <https://code.djangoproject.com/ticket/30794#comment:4>
* status: new => closed
* resolution: => duplicate
Comment:
Please don't reopen tickets closed as duplicates. You can leave your
comments in the original ticket but also don't reopen it.
[https://docs.djangoproject.com/en/stable/internals/contributing/triaging-
tickets/#closing-tickets Follow triaging guidelines with regards to
wontfix tickets.]
--
Ticket URL: <https://code.djangoproject.com/ticket/30794#comment:5>