Python with Django is giving problem when migrating a model

Asked

Viewed 186 times

1

C: Python programs mysite>python Manage.py makemigrations polls Traceback (Most recent call last): File "Manage.py", line 22, in execute_from_command_line(sys.argv) File "C: Python27 lib site-Packages Django core management__init__.py", line 363, in execute_from_command_line Utility.execute() File "C: Python27 lib site-Packages Django core management__init__.py", line 337, 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: Python27 lib site-Packages Django contrib auth models.py", line 4, in from Django.contrib.auth.base_user import Abstractbaseuser, Baseusermanager File "C: Python27 lib site-Packages Django contrib auth base_user.py", line 52, in class Abstractbaseuser(models.Model): File "C: Python27 lib site-Packages Django db models base.py", line 124, in new new_class.add_to_class('_meta', Options(meta, app_label)) File "C: Python27 lib site-Packages Django db models base.py", line 330, in add_to_class value.contribute_to_class(cls, name) File "C: Python27 lib site-Packages Django db models options.py", line 214, in contribute_to_class self.db_table = truncate_name(self.db_table, Connection.ops.max_name_length()) File "C: Python27 lib site-Packages Django db__init__.py", line 33, in getattr Return getattr(Connections[DEFAULT_DB_ALIAS], item) File "C: Python27 lib site-Packages Django db utils.py", line 212, in getitem Conn = backend.Databasewrapper(db, alias) File "C: Python27 lib site-Packages sqlserver_ado base.py", line 184, in init super(Databasewrapper, self).init(*args, **kwargs) File "C: Python27 lib site-Packages Django db backends base base.py", line 97, in init self.Creation = self.creation_class(self) Typeerror: Error when Calling the metaclass bases 'Nonetype' Object is not callable

While issuing this error may be some problem with the connection?

Below are the database settings I’m using Django and the template I edited from polls.

py Settings.

DATABASES = {
    'default': {
        'NAME': 'MS_PYTHON',
        'ENGINE': 'sqlserver_ado',
        'HOST': 'UDILAN-PC\SQLEXPRESS',
        'USER': 'sa',
        'PASSWORD': 'vorlon',
        'PORT': '',
        'OPTIONS': {
            'provider': 'SQLOLEDB',
            'use_mars': True,
            }
    }
}

py.models

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
  • Probably the library you are using to connect to the database (sqlserver_ado) was made for an older version of Django, and does not work with the latest versions (which use Migrations). According to that answer in Soen this error usually happens when you try to touch the bank before Settings.py is fully loaded (which was no problem until 1.6, it became after 1.7). But from your traceback, I don’t think it’s your code that’s doing this, so I suspect it’s the library anyway...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.