[Django] #32266: Inspectdb command shows ugly classnames from django-based tables

7 views
Skip to first unread message

Django

unread,
Dec 14, 2020, 4:23:18 PM12/14/20
to django-...@googlegroups.com
#32266: Inspectdb command shows ugly classnames from django-based tables
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
FJLendinez |
Type: | Status: new
Cleanup/optimization |
Component: Core | Version: 3.1
(Management commands) |
Severity: Normal | Keywords: inspectdb command
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Today I used the inspectdb command to test it. When it recovered the
models, I see that class names are "ugly" when these models are default-
created Django models.

For example:
** Original model**
{{{
class User(AbstractUser):
# ...
token = models.CharField(default=get_random_string, unique=True,
max_length=20)
}}}
**Generated model**

{{{
class UsersUser(models.Model):
token = models.CharField(unique=True, max_length=20)
# ...

class Meta:
managed = False
db_table = 'users_user'
}}}


----

UsersUser (or AppnameModel) could be counterintuitive, a simple flag
**--remove-appnames** is enough to indicate that the first word could be
removed (understanding that most of the app names are only a word).

Here we can check that the flag is active and remove the first word:
https://github.com/django/django/blob/master/django/core/management/commands/inspectdb.py#L43

**This improvement seems trivial but is useful enough to take it into
account because these table names need manual actions, avoiding sync
models automatically between projects automatically (for example)**

--
Ticket URL: <https://code.djangoproject.com/ticket/32266>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 15, 2020, 1:08:37 AM12/15/20
to django-...@googlegroups.com
#32266: Inspectdb command shows ugly classnames from django-based tables
-------------------------------------+-------------------------------------
Reporter: Francisco Javier | Owner: nobody
Lendínez Tirado |
Type: | Status: closed
Cleanup/optimization |
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution: duplicate

Keywords: inspectdb command | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* has_patch: 1 => 0
* resolution: => duplicate


Comment:

Duplicate of #31847.

--
Ticket URL: <https://code.djangoproject.com/ticket/32266#comment:1>

Reply all
Reply to author
Forward
0 new messages