stephenmuss / django-ios-notifications

Django iOS Notifications makes it easy to send push notifications to iOS devices
Other
230 stars 72 forks source link

Error after installing django-ios-notifications #52

Closed haftrine closed 10 years ago

haftrine commented 10 years ago

I'm facing an issue where I've installed a fresh copy of my project, and followed the steps to install this module, however after running loaddata or trying to add a new APNS I'm getting the following error

python manage.py loaddata notification/fixtures/ios_notifications.json
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 55, in handle
    self.loaddata(fixture_labels)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 84, in loaddata
    self.load_label(fixture_label)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 140, in load_label
    obj.save(using=self.using)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/core/serializers/base.py", line 164, in save
    models.Model.save_base(self.object, using=using, raw=True)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/models/base.py", line 573, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/models/base.py", line 635, in _save_table
    forced_update)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/models/base.py", line 679, in _do_update
    return filtered._update(values) > 0
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/models/query.py", line 507, in _update
    return query.get_compiler(self.db).execute_sql(None)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 976, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 782, in execute_sql
    cursor.execute(sql, params)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/backends/util.py", line 69, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/ubuntu/.virtual_envs/project/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: Problem installing fixture '/home/ubuntu/project/notification/fixtures/ios_notifications.json': Could not load ios_notifications.APNService(pk=1): multiple assignments to same column "passphrase"
stephenmuss commented 10 years ago

What does your ios_notifications.json file look like? It seems as though it is trying to assign passphrase more than once to a model.

haftrine commented 10 years ago

Hi stephenmuss, thank you for your prompt reply Here is what it looks like, I've checked and rechecked and there's one passphrase in the model as well as the data as well as the db

[{
        "pk": 1,
        "model": "ios_notifications.apnservice",
        "fields": {
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\r\nXX-KEY-XX\r\n-----END RSA PRIVATE KEY-----",
            "hostname": "gateway.sandbox.push.apple.com",
            "passphrase": "passphrase",
            "name": "APN Dev service",
            "certificate": "-----BEGIN CERTIFICATE-----\r\nXX-CERT-XX\r\n-----END CERTIFICATE-----"
        }
    }, {
        "pk": 2,
        "model": "ios_notifications.apnservice",
        "fields": {
            "private_key": "-----BEGIN RSA PRIVATE KEY-----\r\nXX-KEY-XX\r\n-----END RSA PRIVATE KEY-----",
            "hostname": "gateway.push.apple.com",
            "passphrase": "passphrase",
            "name": "APN Prod service",
            "certificate": "-----BEGIN CERTIFICATE-----\r\nXX-CERT-XX\r\n-----END CERTIFICATE-----"
        }
    }
]

same happens when adding device with column token

mbargiel commented 10 years ago

@haftrine Are you using Postgres? And what version of Django are you on?

I found a reference to a similar error here ( http://south.aeracode.org/ticket/327). It sure looks like an issue related to South introspection rules. Maybe a problem with EncryptedField... (I also found this, which may also be of interest: https://groups.google.com/forum/#!topic/south-users/UcFpgQyDACo)

On Tue, May 27, 2014 at 6:32 PM, Armen M. notifications@github.com wrote:

Hi stephenmuss, thank you for your prompt reply Here is what it looks like, I've checked and rechecked and there's one passphrase in the model as well as the data as well as the db

[{ "pk": 1, "model": "ios_notifications.apnservice", "fields": { "private_key": "-----BEGIN RSA PRIVATE KEY-----\r\nXX-KEY-XX\r\n-----END RSA PRIVATE KEY-----", "hostname": "gateway.sandbox.push.apple.com", "passphrase": "$AES$aac7e55e622015755940a6ac756192e7", "name": "APN Dev service", "certificate": "-----BEGIN CERTIFICATE-----\r\nXX-CERT-XX\r\n-----END CERTIFICATE-----" } }, { "pk": 2, "model": "ios_notifications.apnservice", "fields": { "private_key": "-----BEGIN RSA PRIVATE KEY-----\r\nXX-KEY-XX\r\n-----END RSA PRIVATE KEY-----", "hostname": "gateway.push.apple.com", "passphrase": "$AES$5a3d3b44f9778b922f9d65ca5eb2f91bbae8f99ae68e569346306f55508b33a5", "name": "APN Prod service", "certificate": "-----BEGIN CERTIFICATE-----\r\nXX-CERT-XX\r\n-----END CERTIFICATE-----" } }]

same happens when adding device with column token

— Reply to this email directly or view it on GitHubhttps://github.com/stephenmuss/django-ios-notifications/issues/52#issuecomment-44344126 .

haftrine commented 10 years ago

@mbargiel Yes I'm using Postgres, and Django 1.6.2. The issue described in the google group seems to be what I'm facing, the reply is to migrate manually, I'll try that and see if it works.

haftrine commented 10 years ago

Sorry for this, "ghost" code was adding the same columns from another module into this one. Thank you for your support

mbargiel commented 10 years ago

No problem, thanks for the update!

On Wed, May 28, 2014 at 3:46 PM, Armen M. notifications@github.com wrote:

Sorry for this, "ghost" code was adding the same columns from another module into this one.

— Reply to this email directly or view it on GitHubhttps://github.com/stephenmuss/django-ios-notifications/issues/52#issuecomment-44455355 .