Add ShopModel and integrate with ProductModel

- Created ShopModel with fields for shop name, description, and user association.
- Updated ProductModel to include a foreign key relationship with ShopModel.
- Added admin interface for ShopModel with search functionality.
- Created migrations for ShopModel and its integration with ProductModel.
This commit is contained in:
Parsa Nazer
2025-08-02 18:57:46 +03:30
parent d955fcb107
commit d0dfa3eaa7
7 changed files with 115 additions and 4 deletions
+14
View File
@@ -120,6 +120,20 @@ class User(AbstractBaseUser, PermissionsMixin):
return self.phone
class ShopModel(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='shop', verbose_name='کاربر')
shop_name = models.CharField(max_length=100, verbose_name='نام فروشگاه')
shop_description = models.TextField(verbose_name='توضیحات فروشگاه')
def __str__(self):
return f"{self.user.phone} - {self.shop_name}"
class Meta:
verbose_name = 'فروشگاه'
verbose_name_plural = 'فروشگاه ها'
class UserAddressModel(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='address', verbose_name='کاربر')
name = models.CharField(max_length=30, verbose_name='نام ادرس')