Problems during commissioning:

Problems during commissioning:

  1. 启动出现错误 'Specifying a namespace in include() without providing an app_name ’
    django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the lis
    t of patterns and app_name instead.

Explanation: # django2.1 version urls because in this parameter must be repaired include ancestral
https://blog.csdn.net/a1007720052/article/details/82108994
Error writing:
the urlpatterns = [
URL ( '', include (( 'apps.urls',' Apps'), namespace = 'Apps-URLs')),
]
the correct wording:
the urlpatterns = [
URL (' ', the include ((' apps.urls', 'Apps'), namespace =' URLs-Apps')),
]

  1. After using runserver 0.0.0.0:8000 start, click on the browser prompts can not access, denied access:
    Solution: access with 127.0.0.1:8000, the default address is 0.0.0.0:8000 not visit it.

3. When you create a table error:
File "C: \ Pyxuexi \ GithubCode \ the Guest \ Sign \ models.py", Line 20, in the Guest
Event = models.ForeignKey (Event)
TypeError: the init () 1 Missing required Positional argument: ' on_delete '
analysis: event = models.ForeignKey (Event) after django2, emphasized the use ForeignKey must specify on_delete = models.CASCADE (cascading deletes, relational tables using cascading table)
correct wording:
class the Guest (models.Model) :
Event = models.ForeignKey (the Event, on_delete = models.CASCADE)

  1. 问题:
    django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Published 23 original articles · won praise 0 · Views 577

Guess you like

Origin blog.csdn.net/cbiexi/article/details/104471981