I am having a problem installing my reusable Django-polls app following the “Advanced tutorial: How to write reusable apps”. It is a naming issue. In my project, the top level directory is Django-polls. Which is fine. But my original app as per the polls tutorial is called polls. However, my project directory inside my top-level directory is ALSO django_polls. So there is a name clash here. When I try and install it in my project, I threw an error. And then, when I tried to change django_polls to simply polls and install it, I get the following error:
Processing /Users/mariacam/Python-Development/packages/polls/dist/polls-0.1.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: django>=5.1.4 in ./venv/lib/python3.13/site-packages (from django-polls==0.1) (5.1.4)
Requirement already satisfied: asgiref<4,>=3.8.1 in ./venv/lib/python3.13/site-packages (from django>=5.1.4->django-polls==0.1) (3.8.1)
Requirement already satisfied: sqlparse>=0.3.1 in ./venv/lib/python3.13/site-packages (from django>=5.1.4->django-polls==0.1) (0.5.3)
ERROR: Will not install to the user site because it will lack sys.path precedence to django-polls in /Users/mariacam/Python-Development/django-polls/venv/lib/python3.13/site-packages
I @anefta. Thanks for responding! The structure of the project is not the problem. I changed the naming of the app back to the original polls name. May only problem now is that my label is the same as my app name. This really should have been done differently right from the beginning. The original structure of:
django-polls/ # top level directory where everything resides
django_polls/ # name of project
templates/
manage.py
requirements.txt
Was a problem waiting to happen. And of course in the beginning, when I followed the app tutorial, I didn’t know that I was going to do advanced one until I found out about it. And then the name of the app is autogenerated based on what we give it. if we give it according to “convention” using django-* for the name, and django_* for the name of the app used in the project itself, it WILL cause an issue. They should change the iinitial naming of the app to fit the structure of the whole project taking into account the advanced tutorial! But thanks anyway!
Hi @anefta I just wanted to clarify. I think they should not use dummy names for the project and the top level directory in the polls app tutorial. It should be more realistic. And if changes have to be made to make it work, then it should be done. Most people (including myself) don’t want to use dummy names like that. Sorry for any confusion!