removing model fields from third party apps in django - django

I had installed dj-places app into my django project to have PlacesField() to autocomplete the locations field in my model. It did not work as expected. I uninstalled the app and changed the field to models.CharField().
The problem is whenever I am trying to make further migrations I am getting an error.
posts\migrations\0007_auto_20200709_1445.py", line 4, in <module>
import places.fields
ModuleNotFoundError: No module named 'places'
How can I resolve this?

If you pip install the app then you can run makemigrations and migrate then pip uninstall the app again. This should work.

Related

Receiving "No Module named ''taggit" in Django3

New to django, attempting to add tagging functionality to a blog application.
This is a debian environment.
Installed using pip3 install django-taggit
validated using pip freeze
Django==3.
django-taggit==1.2.0
Then added taggit to Installed_APPS in settingss.py
Django then responds with ModuleNotFoundError: No module named 'taggit
'

Django Rest Framework — no module named rest_framework. Rest_framework is installed and venv is active

I clone repository from github on my second computer, runserver does works but when typing
python manage.py makemigrations
Bash notice about 'no module name rest_framework'
This situation is a second time. Lately I install again rest_framework but then I had install other modules. Finally I create new project but now I want resolve this problem.

Installing django also creates migrations

To make a long story short: when I install django it comes with migrations that I deleted in the past.
Here is what I do:
$ mkvirtualenv foo
$ (foo) pip install django
Collecting django
Using cached Django-1.11.5-py2.py3-none-any.whl
Collecting pytz (from django)
Using cached pytz-2017.2-py2.py3-none-any.whl
Installing collected packages: pytz, django
Successfully installed django-1.11.5 pytz-2017.2
Now when I look in the directory where the venv is created I can see migrations in the default django apps (admin, user, ect.) I also see migrations in a brand new project.
This problems started after I tried to reset my migrations. I deleted the migrations from each app and dropped all the tables. Then I removed the migrations in the venv, while doing this I accidentally removed a django app. The missing app forced me to uninstall and install django.
Even when I tell pip not to use the cache --no-cache-dir, I still get the migrations.
This is by design. The default apps that come with Django need the tables created by those migrations.
If you don't need those apps, remove them from INSTALLED_APPS in settings.py.

PTVS Django Data Base Migration

Im testing Python Tools For Visual Studio, I create a django project, make a SyncDB and install django admin with no problems, but now Im trying to make Data Base migration like: Django 1.7 Migrations. the point is that i cant figuer out how to do that. I serched in google and find this: How to run django database migrations with PTVS?. So the migration command is not wraped. I tried using Windows Command Prompt and install C:\Python34\;C:\Python34\Scripts; PATHS but when i type a django command like python manage.py runserver appears No module named 'django'. It seems that i am not pointing to my django project virtual env, but i dont know how to do that.
Execute command in my django app env path does not work neither.
Image:
Thanks a lot!
Before using of virtual env you should activate it. Execute env\activate or env\bin\activate. Not a windows guy so I'm not sure which path virtualenv uses on Windows :-)
You have to activate virtualenv. Go to env/Scripts directory and run activate.bat. Then go to your main project directory and try again python manage.py runserver. If you still see No module named 'django' make sure that django is installed in this environment try pip install django.

ImportError: No module named apps from django-grappelli

I was working on one django project on my old machine and it was working fine.
Now I am trying to shift my django development environment to new machine (Linux). As a dependency in my project, I am using django-grappelli in it.
I have installed the django-grappelli using following command
sudo pip install --upgrade django-grappelli
It is installed successfully, but now I am trying to run my application and it is giving me following error.
File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/__init__.py", line 1, in <module>
from grappelli.dashboard.dashboards import * File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/dashboards.py", line 13, in <module>
from grappelli.dashboard import modules File "/usr/local/lib/python2.7/dist-packages/grappelli/dashboard/modules.py", line 11, in <module>
from django.apps import apps as django_apps ImportError: No module named apps
I have search around and tried many suggestions, but didn't work. If I am uninstalling the grappelli, It is goving me error for
No module named grappelli
Can anyone suggest where am I doing mistake?
Django version is 1.6
I have tried different things based on my older setup in which all is working fine.
Downgrading the grappelli to version 2.5.3 worked form me. It was not working with 2.6.1 (latest varsion). Not very sure about if is this the issue with 2.6.1 grappelli version or is there any prerequisite for it.
I have uninstalled the 2.6.1 and installed 2.5.3 grappelli, and it resolved my issue.
The problem isn't with grapelli, that is being installed correctly. The problem is that django 1.6 does not have the apps folder, or at least your instance of django 1.6 and my instance of django 1.6 (I looked into 1.6.5) both don't have the apps folder.
I'm not sure what you're using the apps namespace for, but that's where the problem is.
django-grappelli 2.6 is not compatible with Django 1.6.
The apps folder was created in 1.7 alpha stage in this commit:
https://github.com/django/django/commit/860c2c8bc5c77194c41464655851379bf512a052