django-oscar / django-oscar-accounts

Managed accounts for Django (with or without django-oscar)
BSD 3-Clause "New" or "Revised" License
212 stars 119 forks source link

can't init #178

Closed j2l closed 7 months ago

j2l commented 7 months ago

Hello, I followed the default install process, no tweak.

python manage.py oscar_accounts_init
Traceback (most recent call last):
  File "/home/pm/Documents/github/django_tests/django-oscar/frobshop/manage.py", line 22, in <module>
    main()
  File "/home/pm/Documents/github/django_tests/django-oscar/frobshop/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/oscar_accounts/management/commands/oscar_accounts_init.py", line 10, in handle
    create_default_accounts()
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/oscar_accounts/setup.py", line 12, in create_default_accounts
    sales.accounts.create(name=names.REDEMPTIONS)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/db/models/fields/related_descriptors.py", line 799, in create
    return super(RelatedManager, self.db_manager(db)).create(**kwargs)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/db/models/query.py", line 658, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/oscar_accounts/abstract_models.py", line 149, in save
    self.balance = self._balance()
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/oscar_accounts/abstract_models.py", line 153, in _balance
    aggregates = self.transactions.aggregate(sum=Sum('amount'))
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/pm/Documents/github/django_tests/django-oscar/oscar/lib/python3.10/site-packages/django/db/models/fields/related_descriptors.py", line 718, in get_queryset
    raise ValueError(
ValueError: 'Account' instance needs to have a primary key value before this relationship can be used.

Tables are in place:

python manage.py migrate oscar_accounts
Operations to perform:
  Apply all migrations: oscar_accounts
Running migrations:
  No migrations to apply.

My versions:

pip freeze
asgiref==3.7.2
Babel==2.14.0
certifi==2023.11.17
charset-normalizer==3.3.2
Django==4.2.9
django-extra-views==0.14.0
django-haystack==3.2.1
django-oscar==3.2.2
django-oscar-accounts==3.0.1
django-phonenumber-field==6.4.0
django-tables2==2.3.4
django-treebeard==4.7
django-widget-tweaks==1.5.0
factory-boy==3.2.1
Faker==22.2.0
idna==3.6
phonenumbers==8.13.28
pillow==10.2.0
purl==1.6
pysolr==3.9.0
python-dateutil==2.8.2
requests==2.31.0
six==1.16.0
sorl-thumbnail==12.9.0
sqlparse==0.4.4
typing_extensions==4.9.0
urllib3==2.1.0

Any idea?

j2l commented 7 months ago

Applying one of the fork changes fixed it. Also the PR from sept 2023 is fixing it.