djaodjin / djaodjin-saas

Django application for software-as-service and subscription businesses
Other
564 stars 124 forks source link

Cannot create database schema #110

Closed FrancisBou closed 7 years ago

FrancisBou commented 7 years ago

Getting the follwing error using the migrate command.

python ./manage.py migrate --run-syncdb --noinput Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying saas.0001_initial...Traceback (most recent call last): File "./manage.py", line 22, in execute_from_command_line(sys.argv) File "C:\Python35\lib\site-packages\django\core\management__init__.py", line 363, in execute_from_command_line utility.execute() File "C:\Python35\lib\site-packages\django\core\management__init__.py", line 355, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python35\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv self.execute(*args, *cmd_options) File "C:\Python35\lib\site-packages\django\core\management\base.py", line 330, in execute output = self.handle(args, options) File "C:\Python35\lib\site-packages\django\core\management\commands\migrate.py", line 204, in handle fake_initial=fake_initial, File "C:\Python35\lib\site-packages\django\db\migrations\executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Python35\lib\site-packages\django\db\migrations\executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "C:\Python35\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "C:\Python35\lib\site-packages\django\db\migrations\migration.py", line 129, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "C:\Python35\lib\site-packages\django\db\migrations\operations\models.py", line 97, in database_forwards schema_editor.create_model(model) File "C:\Python35\lib\site-packages\django\db\backends\base\schema.py", line 271, in create_model self.deferred_sql.append(self._create_fk_sql(model, field, "fk%(totable)s%(to_column)s")) File "C:\Python35\lib\site-packages\django\db\backends\base\schema.py", line 957, in _create_fk_sql "name": self.quote_name(self._create_index_name(model, [from_column], suffix=suffix)), File "C:\Python35\lib\site-packages\django\db\backends\base\schema.py", line 860, in _create_index_name indexname = '%s%s_%s' % (tablename, ''.join(column_names), hash_suffix_part) TypeError: sequence item 0: expected str instance, bytes found**

smirolo commented 7 years ago

Python3 utf-8 string vs bytes issue. I was convinced I fixed that issue a few weeks ago. Let me take a look again. Thanks for the report. Stay tuned.

FrancisBou commented 7 years ago

@smirolo It does indeed work in Python2.

smirolo commented 7 years ago

So I fixed a few things in the testsite but none that should have an effect on this issue.

On OSX, Python3.6 installed through MacPorts:

$ virtualenv-3.6 ~/workspace
$ cd ~/workspace
$ git clone https://github.com/djaodjin/djaodjin-saas.git
$ cd djaodjin-saas
$ ../bin/pip install -r testsite/requirements.txt
$ ../bin/python ./manage.py migrate --run-syncdb --noinput
$ ../bin/python ./manage.py loaddata testsite/fixtures/test_data.json
$ ../bin/python ./manage.py runserver

No pb...

@FrancisBou: I see you are using Python3.5. I am going to try with that version next. What about Django? Which version are you using? Thank you.

FrancisBou commented 7 years ago

Thanks. @smirolo Using Django 1.11.2

FrancisBou commented 7 years ago

Maybe a bit off topic but what would be the lastest compaptible Django version for this package?

smirolo commented 7 years ago

We run Django 1.9.9 in production for a while now. We started with Django 1.7 so my guess is all versions in between are still ok to use. Moving to Django 1.10 proved a little more complex than anticipated - mostly because we have to wait 3rd party dependencies get upgraded.

  1. I ran Python3.5 and Django 1.9.9 Today. manage.py migrate worked.
  2. When I tried Python3.5 and Django 1.11.2, I stumbled upon a missing django.conf.BaseSettings with django-countries which got fixed after upgrading django-countries to 4.6.1, then manage.py migrate worked.

The following commit (5e5b7356) which could be related to your issue has not be part of an official release yet.

Are you running from master on GitHub or the version on Pypi?

FrancisBou commented 7 years ago

@smirolo I was using the package manager. I'll try and downgrade when I get the time, and thanks alot for your detailed input . 👍

smirolo commented 7 years ago

Great, that explains it. I will try to make sure all tests pass and push a Python3-compatible version to Pypi this week.

smirolo commented 7 years ago

Uploaded new package on Pypi - djaodjin-saas version 0.2.6. The code should be fully Python3.6 compatible at this point.

I am closing the issue. Please re-open or create a new one if you still have problems. Thank you.