remove dollor model cuclation and fix price filter bug

This commit is contained in:
Parsa Nazer
2025-03-11 01:36:42 +03:30
parent 4255910e81
commit d3da83d7e9
3 changed files with 11 additions and 19 deletions
+2 -4
View File
@@ -1,6 +1,6 @@
from django.db import models
from account.models import User
from product.models import ProductModel, DollorModel
from product.models import ProductModel
from django.conf import settings
import openai
from time import sleep
@@ -24,9 +24,7 @@ class ProductChatModel(models.Model):
def save(self, *args, **kwargs):
if not self.thread:
client = openai.OpenAI(api_key=settings.OPENAI_API_KEY)
dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique')
dollor_price = dollor_object.price
product_json = DynamicProductSerializer(instance=self.product, context={'dollor_price': dollor_price, 'view_type': 'chat'}).data
product_json = DynamicProductSerializer(instance=self.product, context={'view_type': 'chat'}).data
try:
thread = client.beta.threads.create(