Search code examples
djangopython-3.xubuntu-18.04

Getting Django error (models.E028). for 6 different models after moving from the Desktop folder to the var/www folder on Ubuntu Server


I recently moved my django project files from a laptop to a web server. After moving the files I ran the django dev server to test things and everything was fine. After moving the project files once to the var/www folder I attempted again to see if everything still worked before finishing the process of launching the project.

I am now getting a django error (models.E028) and don't know how to solve it.

I have looked through the models.py folder where these models are and everything appears the same as before. Also the second model that the error message lists is not in my models.py file at all, for example in teh first line it lists "auth.Group". I am unable to locate this model at all.

Also I have yet to destroy the copies of the project on the laptop so I tried to launch it there and it works with no errors.

Unfortunately the Django docs don't give further explanation of the error, or where to start looking for the cause.

I'm sure the error has to do with moving the files from one location to another on the server, but I can't think of why it would affect the models. They have to be in the folder they are located in now, so moving them back isn't a solution. I moved the folder with the following command:

sudo mv file/I/needed/to/move /var/www/

Here is the full error I am getting when I attempt to launch the dev server from django using the runserver command:

Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in 
  _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/cpcadmin/.local/lib/python3.6/site- 
packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/cpcadmin/.local/lib/python3.6/site- 
packages/django/core/management/commands/runserver.py", line 117, in 
inner_run
    self.check(display_num_errors=True)
  File "/home/cpcadmin/.local/lib/python3.6/site- 
packages/django/core/management/base.py", line 436, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: 
System check identified some issues:

ERRORS:
auth_group: (models.E028) db_table 'auth_group' is used by multiple 
models: Final.AuthGroup, auth.Group.
auth_permission: (models.E028) db_table 'auth_permission' is used by 
multiple models: Final.AuthPermission, auth.Permission.
auth_user: (models.E028) db_table 'auth_user' is used by multiple 
models: Final.AuthUser, auth.User.
django_admin_log: (models.E028) db_table 'django_admin_log' is used 
by multiple models: Final.DjangoAdminLog, admin.LogEntry.
django_content_type: (models.E028) db_table 'django_content_type' is 
used by multiple models: Final.DjangoContentType, 
contenttypes.ContentType.
django_session: (models.E028) db_table 'django_session' is used by 
multiple models: Final.DjangoSession, sessions.Session.

System check identified 6 issues (0 silenced).

I don't have a lot of experience with django beyond a couple small sites and have never encountered this particular error. Any help is greatly appreciated as I'm at a loss. Thanks in advance!


Solution

  • Change manage variable to False for DjangoContentType class in your application's model.py

    For Example

        class DjangoContentType(models.Model)
            app_label = models.CharField(max_length=100)
            model = models.CharField(max_length=100)
            
            class Meta:
                managed = False
                db_table = 'django_content_type'
                unique_together = (('app_label', 'model'),)