添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello. I’m having problem when I set the command python manage.py makemigrations.

I get this console output:

File “/home/jaodev/ftp/files/CallServiceBackEnd/callservices/urls.py”, line 23, in
from callserviceapp.views import homeCliente, homeClientePedirDatos, proveedorUbicacion
ImportError: cannot import name ‘homeCliente’

Why can not import the function homeCliente in server? I have not this problem at the localhost (in my computer)

from django.conf.urls import url
from django.contrib import admin
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from callserviceapp.views import homeCliente, homeClientePedirDatos, proveedorUbicacion
urlpatterns = [
    path('admin/', admin.site.urls),
    path('home/cliente/<lat>/<long>', homeCliente),
    path('home/cliente/pedirdatos/<email>/<rubro>/<tipoPedido>/<lat>/<long>', homeClientePedirDatos),
    path('proveedor/ubicacion/<email>/<lat>/<long>', proveedorUbicacion),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

this is the folder structure

First step would be to verify your files and directory structure on the server. Make sure that all the files needing to be there have been properly created and that they are complete and correct.

Then verify that there are no permissions issues related to your directory structure - that the files and directories have the right permissions on them for the account being used to access them.

Happy Birthday Ken. Yes, the directory structure is the same. The permission are OK

image836×372 29.8 KB image692×380 27 KB

Also, the django version are the same 3.2.13

How about Python versions? Are you using the same version of Python in both locations? Are you using a virtual environment on the server? Have you verified it?

Have you checked your settings file to ensure there are no path issues?

Have you tried removing the urls and the import to determine if this is the only issue or an indication of a larger problem?

So comment out those as well.

This is all part of the diagnostic process. The intent is to identify what is different between the two environments to determine what’s wrong. Without any clear indication of an error, then you need to just start removing where errors are being identified until you find out what is causing the problem.

If I delete the imports I get:

File “/home/jaodev/ftp/files/CallServiceBackEnd/callservices/urls.py”, line 13, in
path(‘home/cliente//’, homeCliente),
NameError: name ‘homeCliente’ is not defined

Everything would indicate that it can and does find the functions (methods defined in views.py) but for some reason it is block.

Traceback (most recent call last):
File “manage.py”, line 21, in
main()
File “manage.py”, line 17, in main
execute_from_command_line(sys.argv)
File “/usr/local/lib/python3.6/dist-packages/django/core/management/init.py”, line 419, in execute_from_command_line
utility.execute()
File “/usr/local/lib/python3.6/dist-packages/django/core/management/init.py”, line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/usr/local/lib/python3.6/dist-packages/django/core/management/base.py”, line 354, in run_from_argv
self.execute(*args, **cmd_options)
File “/usr/local/lib/python3.6/dist-packages/django/core/management/base.py”, line 393, in execute
self.check()
File “/usr/local/lib/python3.6/dist-packages/django/core/management/base.py”, line 423, in check
databases=databases,
File “/usr/local/lib/python3.6/dist-packages/django/core/checks/registry.py”, line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File “/usr/local/lib/python3.6/dist-packages/django/core/checks/urls.py”, line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File “/usr/local/lib/python3.6/dist-packages/django/core/checks/urls.py”, line 57, in _load_all_namespaces
url_patterns = getattr(resolver, ‘url_patterns’, )
File “/usr/local/lib/python3.6/dist-packages/django/utils/functional.py”, line 48, in get
res = instance.dict[self.name] = self.func(instance)
File “/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py”, line 602, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “/usr/local/lib/python3.6/dist-packages/django/utils/functional.py”, line 48, in get
res = instance.dict[self.name] = self.func(instance)
File “/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py”, line 595, in urlconf_module
return import_module(self.urlconf_name)
File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/home/jaodev/ftp/files/CallServiceBackEnd/callservices/urls.py”, line 23, in
from callserviceapp.views import homeCliente, homeClientePedirDatos, proveedorUbicacion
ImportError: cannot import name ‘homeCliente’

KenWhitesell:

Have you tried removing the urls and the import to determine if this is the only issue or an indication of a larger problem?

If you remove the imports, you need to remove the urls referencing those imported functions as well.

KenWhitesell:

If you remove the imports, you need to remove the urls referencing those imported functions as well.

If I delete the imports and the urls referencing, there is not problem. But the problems is with all referencing. Because to make the makemigrations only it runs with none of the referencing.

Everything indicates that for some reason there was an error in the views.py data pull from the code repository. The last views.py code lines were missing. First time this happens to me I didn’t fully review the code until the end (because I never saw it as a possibility).

Cloning the repository again fixed it.