简体   繁体   中英

db_type in Django (attempting to install pootle w/ mysql)

Similar query that was posed to here: Getting db_type() error while using django-facebook connect for DjangoApp

I'm attempting to install Pootle on a CentOS box with the following details:

[root@localhost pootle]# cat /etc/redhat-release<br>
CentOS release 6.2 (Final)
<br>
[root@localhost pootle]# PootleServer --version<br>
Pootle 2.1.6<br>
Translate Toolkit 1.9.0<br>
Django 1.4<br>
[root@localhost pootle]# python -V<br>
Python 2.6.6

I was getting the following error:

Creating tables ...
Traceback (most recent call last):
  File "/usr/lib64/python2.6/wsgiref/handlers.py", line 94, in run
    self.finish_response()
  File "/usr/lib64/python2.6/wsgiref/handlers.py", line 134, in finish_response
    for data in self.result:
  File "/usr/lib/python2.6/site-packages/django/http/__init__.py", line 710, in next
    chunk = self._iterator.next()
  File "/usr/lib/python2.6/site-packages/pootle_misc/dbinit.py", line 134, in staggered_install
    yield syncdb()
  File "/usr/lib/python2.6/site-packages/pootle_misc/dbinit.py", line 76, in syncdb
    call_command('syncdb', interactive=False)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 91, in handle_noargs
    sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
  File "/usr/lib/python2.6/site-packages/django/db/backends/creation.py", line 44, in sql_create_model
    col_type = f.db_type(connection=self.connection)
TypeError: db_type() got an unexpected keyword argument 'connection'

After I edit /usr/lib/python2.6/site-packages/django/db/backends/creation.py to a way I thought would rectify the issue, I'm still getting the following output from my PootleServer screen when I attempt to load the webpage:

Creating tables ...
Traceback (most recent call last):
  File "/usr/lib64/python2.6/wsgiref/handlers.py", line 94, in run
    self.finish_response()
  File "/usr/lib64/python2.6/wsgiref/handlers.py", line 134, in finish_response
    for data in self.result:
  File "/usr/lib/python2.6/site-packages/django/http/__init__.py", line 710, in next
    chunk = self._iterator.next()
  File "/usr/lib/python2.6/site-packages/pootle_misc/dbinit.py", line 134, in staggered_install
    yield syncdb()
  File "/usr/lib/python2.6/site-packages/pootle_misc/dbinit.py", line 76, in syncdb
    call_command('syncdb', interactive=False)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 91, in handle_noargs
    sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
  File "/usr/lib/python2.6/site-packages/django/db/backends/creation.py", line 45, in sql_create_model
    col_type = f.db_type(self.connection)
TypeError: db_type() takes exactly 1 argument (2 given)

The webpage displays:

Error: "(1146, "Table 'p2.siteconfig_siteconfiguration' doesn't exist")" while attempting to access the Pootle database, will try to initialize database.

The line in question is number 44, and looks like this:

    col_type = f.db_type(connection=self.connection)

Which I have commented out, and added a line underneath it to look like this:

    #col_type = f.db_type(connection=self.connection)
    col_type = f.db_type(self.connection)

Previously running the server rendered this error, however it was preceded by a number of successful creation notices, as we can see here:

mysql> show tables;

+-----------------------------------------------+
| Tables_in_p2                                  |
+-----------------------------------------------+
| auth_group                                    |
| auth_group_permissions                        |
| auth_permission                               |
| auth_user                                     |
| auth_user_groups                              |
| auth_user_user_permissions                    |
| django_admin_log                              |
| django_content_type                           |
| django_session                                |
| django_site                                   |
| pootle_app_directory                          |
| pootle_app_language                           |
| pootle_app_permissionset                      |
| pootle_app_permissionset_negative_permissions |
| pootle_app_permissionset_positive_permissions |
| pootle_app_pootleprofile                      |
| pootle_app_pootleprofile_alt_src_langs        |
| pootle_app_pootleprofile_languages            |
| pootle_app_pootleprofile_projects             |
| pootle_app_project                            |
| pootle_app_submission                         |
| pootle_app_suggestion                         |
| pootle_app_translationproject                 |
| pootle_notifications_notice                   |
| pootle_store_qualitycheck                     |
| pootle_store_store                            |
| pootle_store_suggestion                       |
| pootle_store_unit                             |
| registration_registrationprofile              |
+-----------------------------------------------+
29 rows in set (0.00 sec)

I'm sorry if this is a lengthy question, however I'm attempting to provide as much relevant information as possible to give you a good idea of what's happening.

If you know a way to fix this issue, please let me know as the internet seems rather lacking in Pootle-related fixes.

Edit: Saw this: How to fix django's db_type deprecation warning?

changed the settings.py file to have this in it:

    col_type = f.db_type(connection=connection)
    #col_type = f.db_type(connection=self.connection)
    #col_type = f.db_type(self.connection)

Getting this error:

NameError: global name 'connection' is not defined

It looks like Pootle doesn't support Django 1.4 Uninstall Django 1.4 and install the older 1.3.1 version.

This could be helpful: How do I install an old version of Django on virtualenv?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM