Reputation: 87
when I makemigrations
i get the following error:
django.db.utils.OperationalError: no such table: django_site
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 338, in execute
django.setup()
File "C:\Python27\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Python27\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Users\KwanfahArunrerk\Desktop\Sinwattana_repo\trunk\sinwattana3_0\campaign\models.py", line 5, in <module>
from sinUser.models import sinUser, sinUserCategories
File "C:\Users\KwanfahArunrerk\Desktop\Sinwattana_repo\trunk\sinwattana3_0\sinUser\models.py", line 4, in <module>
from functionUtility.sendEmails import sendEmailFunctionIsError
File "C:\Users\KwanfahArunrerk\Desktop\Sinwattana_repo\trunk\sinwattana3_0\functionUtility\sendEmails.py", line 12, in <module>
HOSTNAME = Site.objects.get_current().domain
File "C:\Python27\lib\site-packages\django\contrib\sites\models.py", line 63, in get_current
return self._get_site_by_id(site_id)
File "C:\Python27\lib\site-packages\django\contrib\sites\models.py", line 35, in _get_site_by_id
site = self.get(pk=site_id)
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 374, in get
num = len(clone)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 232, in __len__
self._fetch_all()
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 894, in execute_sql
raise original_exception
django.db.utils.OperationalError: no such table: django_site
I am newbies python programming
some one can help me
thank you
Upvotes: 3
Views: 6604
Reputation: 53
python manage.py migrate
python manage.py makemigrations
Worked for me, had pending migrations.
Upvotes: 0
Reputation: 330
Change "django.contrib.admin"
in INSTALLED_APPS
to "django.contrib.admin.apps.SimpleAdminConfig"
and then run makemigrations
command. after that you can revert your changes.
Upvotes: 1
Reputation: 382
In this case some migrations are still pending so run python manage.py migrate
and python manage.py makemigrations app_name
Upvotes: 3
Reputation: 599956
Your sendEmails
module has a query at the top level: Site.objects.get_current()
. This is run when the module is imported, before migrations have had a chance to run.
You must not do any database actions at this level; put it into a method.
Upvotes: 8
Reputation: 4092
Add django.contrib.sites
in your INSTALLED_APPS and the run migrate command
python manage.py makemigrations
python manage.py migrate
Hope this helps you
Upvotes: 3