# makemigrations views imports problem

**URL:** <https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846>\
**Category:** Deployment\
**Created:** [July 16, 2022, 2:51pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846 "2022-07-16T14:51:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![julianov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/julianov/32/3502_2.png) [@julianov](https://forum.djangoproject.com/u/julianov)\
**Post date:** [July 16, 2022, 2:51pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/1 "2022-07-16T14:51:04Z")

</div>

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)

```auto
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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/5/563e9646eadc58a3a264d44b2bb51027cb44e4bb.png)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 16, 2022, 2:57pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/2 "2022-07-16T14:57:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![julianov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/julianov/32/3502_2.png) [@julianov](https://forum.djangoproject.com/u/julianov)\
**Post date:** [July 16, 2022, 3:27pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/3 "2022-07-16T15:27:06Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/e/e5ef01f1d34a6efc50ce24837c5391029c5e91cb.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/7/7696cc582a1236068c89c9298aa33a79a5ed346b.png)

Also, the django version are the same 3.2.13

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 16, 2022, 4:21pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/4 "2022-07-16T16:21:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![julianov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/julianov/32/3502_2.png) [@julianov](https://forum.djangoproject.com/u/julianov)\
**Post date:** [July 16, 2022, 11:57pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/5 "2022-07-16T23:57:54Z")

</div>

Thanks but the python version are the same. Im not using virtualenv and if I delete the imports the app can not find the functions. So, It’s a weird problem and also in the web I can not find a solution.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 16, 2022, 11:59pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/6 "2022-07-16T23:59:44Z")

</div>

> [@julianov](#):
>
> I delete the imports the app can not find the functions.

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.

---

<div class="post-metadata">

**Author:** ![julianov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/julianov/32/3502_2.png) [@julianov](https://forum.djangoproject.com/u/julianov)\
**Post date:** [July 17, 2022, 12:06am UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/7 "2022-07-17T00:06:27Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 17, 2022, 12:37am UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/8 "2022-07-17T00:37:45Z")

</div>

> [@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.

---

<div class="post-metadata">

**Author:** ![julianov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/julianov/32/3502_2.png) [@julianov](https://forum.djangoproject.com/u/julianov)\
**Post date:** [July 17, 2022, 1:25am UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/9 "2022-07-17T01:25:14Z")

</div>

> [@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.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 17, 2022, 1:33am UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/10 "2022-07-17T01:33:56Z")

</div>

So if makemigrations works without references to the callserviceapp/views.py file, I would think that the problem is in that file.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 17, 2022, 12:56pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/11 "2022-07-17T12:56:46Z")

</div>

So I’m curious - what did the problem turn out to be?

---

<div class="post-metadata">

**Author:** ![julianov](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/julianov/32/3502_2.png) [@julianov](https://forum.djangoproject.com/u/julianov)\
**Post date:** [July 17, 2022, 1:10pm UTC](https://forum.djangoproject.com/t/makemigrations-views-imports-problem/14846/12 "2022-07-17T13:10:29Z")

</div>

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.
