Features: 1) Add JSONField system_attributes to stock model with default as an empty dictionary; 2) Extend sitemaps for Category and Brand to include slug in queried fields;
Fixes: None; Extra: 1) Standardize quotes in migration dependencies and field declarations; 2) Break down queryset methods in sitemaps for improved readability;
This commit is contained in:
parent
0cd2e417cb
commit
b4292fde53
2 changed files with 24 additions and 7 deletions
|
|
@ -4,15 +4,14 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0050_remove_attribute_categories'),
|
||||
("core", "0050_remove_attribute_categories"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='stock',
|
||||
name='system_attributes',
|
||||
field=models.JSONField(default=dict, verbose_name='system attributes'),
|
||||
model_name="stock",
|
||||
name="system_attributes",
|
||||
field=models.JSONField(default=dict, verbose_name="system attributes"),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -91,7 +91,16 @@ class CategorySitemap(SitemapLanguageMixin, Sitemap): # type: ignore [type-arg]
|
|||
limit = 10000
|
||||
|
||||
def items(self):
|
||||
return Category.objects.filter(is_active=True).only("uuid", "name", "modified").order_by("-modified")
|
||||
return (
|
||||
Category.objects.filter(is_active=True)
|
||||
.only(
|
||||
"uuid",
|
||||
"name",
|
||||
"modified",
|
||||
"slug",
|
||||
)
|
||||
.order_by("-modified")
|
||||
)
|
||||
|
||||
def lastmod(self, obj):
|
||||
return obj.modified
|
||||
|
|
@ -107,7 +116,16 @@ class BrandSitemap(SitemapLanguageMixin, Sitemap): # type: ignore [type-arg]
|
|||
limit = 10000
|
||||
|
||||
def items(self):
|
||||
return Brand.objects.filter(is_active=True).only("uuid", "name", "modified").order_by("-modified")
|
||||
return (
|
||||
Brand.objects.filter(is_active=True)
|
||||
.only(
|
||||
"uuid",
|
||||
"name",
|
||||
"modified",
|
||||
"slug",
|
||||
)
|
||||
.order_by("-modified")
|
||||
)
|
||||
|
||||
def lastmod(self, obj):
|
||||
return obj.modified
|
||||
|
|
|
|||
Loading…
Reference in a new issue