Skip to content

Commit

Permalink
Fix blog config admin
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 26, 2024
1 parent 7284e75 commit bd21a13
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 199 deletions.
4 changes: 2 additions & 2 deletions djangocms_blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def lookups(self, request, model_admin):
def queryset(self, request, queryset):
try:
if "sites" in self.used_parameters:
return queryset.on_site(Site.objects.get(pk=self.used_parameters["sites"]))
return queryset.filter(models.Q(sites__isnull=True) | models.Q(sites=self.used_parameters["sites"]))
return queryset
except Site.DoesNotExist as e: # pragma: no cover
raise admin.options.IncorrectLookupParameters(e)
Expand Down Expand Up @@ -760,7 +760,7 @@ def get_fieldsets(self, request, obj=None):
{
"fields": (
"paginate_by",
("urlconf", "url_patterns"),
"url_patterns",
("menu_structure", "menu_empty_categories"),
"template_prefix",
("default_image_full", "default_image_thumbnail"),
Expand Down
167 changes: 167 additions & 0 deletions djangocms_blog/migrations/0048_alter_blogcategory_options_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Generated by Django 4.2.16 on 2024-10-03 12:48

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import taggit_autosuggest.managers


class Migration(migrations.Migration):
dependencies = [
("filer", "0017_image__transparent"),
(
"taggit",
"0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx",
),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("djangocms_blog", "0001_squashed_0047_migrate_config"),
]

operations = [
migrations.AlterModelOptions(
name="blogcategory",
options={
"ordering": (models.OrderBy(models.F("priority"), nulls_last=True),),
"verbose_name": "post category",
"verbose_name_plural": "post categories",
},
),
migrations.AlterModelOptions(
name="blogcategorytranslation",
options={
"default_permissions": (),
"managed": True,
"verbose_name": "post category Translation",
},
),
migrations.AlterModelOptions(
name="post",
options={
"get_latest_by": "date_published",
"ordering": (
models.OrderBy(models.F("pinned"), nulls_last=True),
"-date_published",
"-date_created",
),
"verbose_name": "post",
"verbose_name_plural": "posts",
},
),
migrations.AlterField(
model_name="authorentriesplugin",
name="authors",
field=models.ManyToManyField(
to=settings.AUTH_USER_MODEL, verbose_name="authors"
),
),
migrations.AlterField(
model_name="authorentriesplugin",
name="latest_posts",
field=models.IntegerField(
default=5,
help_text="The number of author entries to be displayed.",
verbose_name="entries",
),
),
migrations.AlterField(
model_name="authorentriesplugin",
name="template_folder",
field=models.CharField(
choices=[("plugins", "Default template")],
default="plugins",
help_text="Select plugin layout to load for this instance",
max_length=200,
verbose_name="Plugin layout",
),
),
migrations.AlterField(
model_name="blogconfig",
name="default_image_full",
field=models.ForeignKey(
blank=True,
help_text="If left empty the image size will have to be set for every newly created post.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="default_images_full",
to="filer.thumbnailoption",
verbose_name="default size of full images",
),
),
migrations.AlterField(
model_name="blogconfig",
name="default_image_thumbnail",
field=models.ForeignKey(
blank=True,
help_text="If left empty the thumbnail image size will have to be set for every newly created post.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="default_images_thumbnail",
to="filer.thumbnailoption",
verbose_name="default size of thumbnail images",
),
),
migrations.AlterField(
model_name="blogconfig",
name="namespace",
field=models.CharField(
default=None,
max_length=100,
unique=True,
verbose_name="instance namespace",
),
),
migrations.AlterField(
model_name="blogconfig",
name="type",
field=models.CharField(max_length=100, verbose_name="type"),
),
migrations.AlterField(
model_name="blogconfigtranslation",
name="app_title",
field=models.CharField(
default="blog", max_length=200, verbose_name="application title"
),
),
migrations.AlterField(
model_name="genericblogplugin",
name="template_folder",
field=models.CharField(
choices=[("plugins", "Default template")],
default="plugins",
help_text="Select plugin layout to load for this instance",
max_length=200,
verbose_name="Plugin layout",
),
),
migrations.AlterField(
model_name="latestpostsplugin",
name="latest_posts",
field=models.IntegerField(
default=5,
help_text="The number of latests entries to be displayed.",
verbose_name="entries",
),
),
migrations.AlterField(
model_name="latestpostsplugin",
name="tags",
field=taggit_autosuggest.managers.TaggableManager(
blank=True,
help_text="Show only the entries tagged with chosen tags.",
through="taggit.TaggedItem",
to="taggit.Tag",
verbose_name="filter by tag",
),
),
migrations.AlterField(
model_name="latestpostsplugin",
name="template_folder",
field=models.CharField(
choices=[("plugins", "Default template")],
default="plugins",
help_text="Select plugin layout to load for this instance",
max_length=200,
verbose_name="Plugin layout",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 4.2.16 on 2024-11-26 10:53

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("djangocms_blog", "0048_alter_blogcategory_options_and_more"),
]

operations = [
migrations.RemoveField(
model_name="blogconfig",
name="urlconf",
),
migrations.AlterField(
model_name="blogcategory",
name="id",
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
migrations.AlterField(
model_name="blogcategorytranslation",
name="id",
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
migrations.AlterField(
model_name="blogconfig",
name="id",
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
migrations.AlterField(
model_name="blogconfig",
name="paginate_by",
field=models.SmallIntegerField(
default=20,
help_text="When paginating list views, how many articles per page?",
null=True,
verbose_name="Paginate size",
),
),
migrations.AlterField(
model_name="blogconfig",
name="type",
field=models.CharField(default="Article", max_length=100, verbose_name="type"),
),
migrations.AlterField(
model_name="blogconfigtranslation",
name="id",
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
migrations.AlterField(
model_name="post",
name="id",
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
migrations.AlterField(
model_name="postcontent",
name="id",
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
]
Loading

3 comments on commit bd21a13

@jhonvidal
Copy link

Choose a reason for hiding this comment

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

When executing any instruction in the terminal, the following error appears:

django.core.exceptions.FieldError: Unknown field(s) (abstract, title) specified for Post

@fsbraun
Copy link
Owner Author

Choose a reason for hiding this comment

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

@jhonvidal Do you have a traceback?

@jhonvidal
Copy link

Choose a reason for hiding this comment

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

@fsbraun :

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    main()
  File "./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/.venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
  File ".venv/lib/python3.12/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File ".venv/lib/python3.12/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File ".venv/lib/python3.12/site-packages/cms/apps.py", line 13, in ready
    setup_cms_apps()
  File ".venv/lib/python3.12/site-packages/cms/utils/setup.py", line 64, in setup_cms_apps
    backwards_compatibility_config()
  File ".venv/lib/python3.12/site-packages/cms/app_registration.py", line 169, in backwards_compatibility_config
    import_module('%s.%s' % (app_config.name, module))
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File ".venv/lib/python3.12/site-packages/djangocms_blog/cms_wizards.py", line 18, in <module>
    class PostWizardForm(PostAdminFormBase):
  File ".venv/lib/python3.12/site-packages/django/forms/models.py", line 332, in __new__
    raise FieldError(message)
django.core.exceptions.FieldError: Unknown field(s) (title, abstract) specified for Post

My file pyproject.toml:

....
[tool.poetry.dependencies]
python = "~3.12"
django-cms = "~4.1.4"
psycopg2-binary = "~2.9.9"
django = "~5.0"
django-compressor = "^4.5.1"
django-sass-processor = "^1.4.1"
django-sekizai = "^4.1.0"
django-entangled = "^0.5.4"
django-filer = "^3.2.0"
django-parler = "^2.3"
django-polymorphic = "^3.1.0"
django-fsm = "^2.8.2"
djangocms-text-ckeditor = "^5.1.5"
djangocms-alias = "^2.0.1"
djangocms-attributes-field = "^3.0.0"
djangocms-frontend = "^1.3.3"
easy-thumbnails = "^2.9"
djangocms-versioning = "^2.0.2"
gunicorn = "^23.0.0"
django-taggit = "^6.1.0"
django-taggit-autosuggest = "^0.4.1"
aldryn-apphooks-config = "^0.7.0"
djangocms-blog = {git = "https://github.com/fsbraun/djangocms-blog.git", rev = "develop-4"}
...


Please sign in to comment.