Answer the question
In order to leave comments, you need to log in
Why am I getting UNIQUE constraint failed: offers_offer.currencyId_id?
I filter xml model and save it like this
try:
# check model
offer = Offer.objects.get(id = lxml_id)
currencyId = host_ip.find('currencyId').text
print(currencyId)
currency = Currency.objects.get(name = currencyId)
print(offer.currencyId)
if not offer.currencyId == currencyId:
offer.currencyId = currency
save_model = True
if save_model:
offer.save()
print('save 3')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question