#30794: Automatic solution for “Add a related_name argument to the definition 
for
'XXX'.” for inspectdb.py
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  mingwugmail                        |
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  2.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  related_name
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 https://stackoverflow.com/a/52872876

 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.4214ff2f0a0cab380d39f927e15f22e4%40djangoproject.com.

Reply via email to