J'utilise le cadre Django. J'ai créé un projet à l'école à l'aide de Pycharm et je voulais créer un autre projet. Cependant, lorsque vous essayez d'exécuter mon serveur, tout à coup, je commence à obtenir l'erreur suivante dans mon invite de commande:
C:\Users\Johnny\PycharmProjects\DJango Tutorial V2\mysite>python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 368, in execute
self.check()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = checks.run_checks(
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Johnny\PycharmProjects\DJango Tutorial V2\mysite\mysite\urls.py", line 20, in <module>
path('polls/', include('polls.url')),
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.url'
3 Réponses :
Tout d'abord, vérifiez si vous avez des noms de fichiers incorrects pour les applications dans puis, redémarrez le serveur, si tout est bon et ne fonctionne toujours pas. P> Dans certains cas, l'erreur est également affichée car de migration. Essayez de faire des migrations. Comme: p> Vous devez être prêt à partir maintenant. P> p> applications installées code> dans paramètres.py code>. Votre application devrait être STHG comme:
Cela n'a fini pas de travailler. J'ai essayé d'ajouter 'sondols.apps.pollsconfig', code> à mon installé_apps mais qui n'a pas fonctionné.
Qu'en est-il de la migration?
J'ai essayé ça aussi et il vient d'avoir jeté une erreur qui semble très similaire à celle avant
Similaire. Mais pas exact ?? Si alors, montre que la trace
Génial, je viens de le faire.
Créez un nom de fichier appelé urls.py code> dans votre interrogations code> app.
trouvé. Au lieu de sondages.url, j'ai écrit Poll.url à l'intérieur de l'URL.py pour le forfait mysite. Regardez votre orthographe! P>
mon dossier dans l'application était URL.py p>
et dans le cadre du projet, j'écris le chemin ('', inclure ('loginaccounts.urls')). P>
sur Chemin lorsque j'ai changé en URL des URL, cela a fonctionné car il n'a pas été capable de cartographier le chemin. P>
Même solution que dans la réponse acceptée.