#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
     Reporter:  Matthew Schinckel  |                    Owner:  oliver
         Type:  Bug                |                   Status:  assigned
    Component:  Migrations         |                  Version:  2.0
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by oliver):

 Current code generating that error message is as follows when using
 makemigraions command.
 {{{
        # Make sure the app they asked for exists
         app_labels = set(app_labels)
         bad_app_labels = set()
         for app_label in app_labels:
             try:
                 apps.get_app_config(app_label)
             except LookupError:
                 bad_app_labels.add(app_label)
         if bad_app_labels:
             for app_label in bad_app_labels:
                 self.stderr.write("App '%s' could not be found. Is it in
 INSTALLED_APPS?" % app_label)
             sys.exit(2)
 }}}

 and below is the part that checks the validity of the app name when using
 startapp and createproject command

 {{{
         if not name.isidentifier():
             raise CommandError(
                 "'{name}' is not a valid {app} name. Please make sure the
 "
                 "name is a valid identifier.".format(
                     name=name,
                     app=app_or_project,
                 )
             )
 }}}


 How about using the code validating app name to current code as follows?
 https://github.com/django/django/pull/10051

 {{{
        # Make sure the app they asked for is a valid app name and exist.
         app_labels = set(app_labels)
         bad_app_labels = set()
         for app_label in app_labels:
             try:
                 apps.get_app_config(app_label)
             except LookupError:
                 bad_app_labels.add(app_label)
         if bad_app_labels:
             for app_label in bad_app_labels:
                 if not app_label.isidentifier():
                     self.stderr.write(
                         "'%s' is not a valid app name. Please make sure
 the "
                         "name is a valid identifire."% app_label
                     )
                 else:
                     self.stderr.write("App '%s' could not be found. Is it
 in INSTALLED_APPS?" % app_label)
             sys.exit(2)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29469#comment:7>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.0016e552314b7d9ae86f84f48e57334b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to