Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Clean up to conform with lint

Marek Brzóska6b2961e370c7
diff --git a/product/migrations/0001_initial.py b/product/migrations/0001_initial.py
index b9d1b5fe46..2820c513c4 100644
--- a/product/migrations/0001_initial.py
+++ b/product/migrations/0001_initial.py
@@ -64,4 +64,4 @@ class Migration(SchemaMigration):
}
}
- complete_apps = ['product']
\ No newline at end of file
+ complete_apps = ['product']
diff --git a/product/models.py b/product/models.py
index 9d9ef5e8cb..1806d35bcc 100755
--- a/product/models.py
+++ b/product/models.py
@@ -29,18 +29,18 @@ class Product(Subtyped, ItemRange):
name = models.CharField(_('Product field', 'name'), max_length=128)
price = PriceField(_('Product field', 'price'), currency='USD',
max_digits=12, decimal_places=4)
- category = models.ForeignKey(Category,
+ category = models.ForeignKey(Category, related_name='products',
verbose_name=_('Product field', 'category'))
def __unicode__(self):
return self.name
- def get_slug(self):
- value = unidecode(self.name)
- value = re.sub('[^\w\s-]', '', value).strip().lower()
-
- return mark_safe(re.sub('[-\s]+', '-', value))
-
@models.permalink
def get_absolute_url(self):
return ('product:details', [self.get_slug(), self.id])
+
+ def get_slug(self):
+ value = unidecode(self.name)
+ value = re.sub(r'[^\w\s-]', '', value).strip().lower()
+
+ return mark_safe(re.sub(r'[-\s]+', '-', value))