Skip to content

Commit

Permalink
fix: attempt to fix ValueError in AppConfig
Browse files Browse the repository at this point in the history
ValueError: Primary key 'django.db.models.UUIDField' referred by core.apps.CoreConfig.default_auto_field must subclass AutoField.
  • Loading branch information
srevinsaju committed May 7, 2021
1 parent ae56636 commit 4223801
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion archivebox/core/apps.py
Expand Up @@ -3,4 +3,4 @@

class CoreConfig(AppConfig):
name = 'core'
default_auto_field = 'django.db.models.UUIDField'
default_auto_field = 'django.db.models.BigAutoField'

3 comments on commit 4223801

@dasj19
Copy link

@dasj19 dasj19 commented on 4223801 Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the same issue and this change helped. Thanks. Why is this not merged in the main branch?

@pirate
Copy link
Member

@pirate pirate commented on 4223801 Jun 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot change the uuid schema lol it's far too late for that, this would break everything and break lots of future design plans. also UUIDs are much better than auto incremeting ids. Exactly what error did you encounter?

@dasj19
Copy link

@dasj19 dasj19 commented on 4223801 Jun 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the full output:

$ archivebox server 0.0.0.0:8000 
[i] [2022-06-25 14:31:35] ArchiveBox v0.6.2: archivebox server 0.0.0.0:8000
    > /home/archivebox

Traceback (most recent call last):
  File "/usr/bin/archivebox", line 11, in <module>
    load_entry_point('archivebox==0.6.2', 'console_scripts', 'archivebox')()
  File "/usr/lib/python3/dist-packages/archivebox/cli/__init__.py", line 140, in main
    run_subcommand(
  File "/usr/lib/python3/dist-packages/archivebox/cli/__init__.py", line 74, in run_subcommand
    setup_django(in_memory_db=subcommand in fake_db, check_db=cmd_requires_db and not init_pending)
  File "/usr/lib/python3/dist-packages/archivebox/config.py", line 1136, in setup_django
    django.setup()
  File "/usr/lib/python3/dist-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/usr/lib/python3/dist-packages/django/apps/config.py", line 301, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/archivebox/core/models.py", line 87, in <module>
    class Snapshot(models.Model):
  File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 161, in __new__
    new_class.add_to_class(obj_name, obj)
  File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 326, in add_to_class
    value.contribute_to_class(cls, name)
  File "/usr/lib/python3/dist-packages/django/db/models/fields/related.py", line 1635, in contribute_to_class
    self.remote_field.through = create_many_to_many_intermediary_model(self, cls)
  File "/usr/lib/python3/dist-packages/django/db/models/fields/related.py", line 1104, in create_many_to_many_intermediary_model
    return type(name, (models.Model,), {
  File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 320, in __new__
    new_class._prepare()
  File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 333, in _prepare
    opts._prepare(cls)
  File "/usr/lib/python3/dist-packages/django/db/models/options.py", line 285, in _prepare
    pk_class = self._get_default_pk_class()
  File "/usr/lib/python3/dist-packages/django/db/models/options.py", line 246, in _get_default_pk_class
    raise ValueError(
ValueError: Primary key 'django.db.models.UUIDField' referred by core.apps.CoreConfig.default_auto_field must subclass AutoField.

I don't know if that makes a difference but I have it running on arhmhf/armv7l (32-bit)

Please sign in to comment.