1π
in views.py, Here I want to replace the user(Product.user) of the product by sender sending amount from wallet
ctp_val.update(user=receiverrUser)
Also, it will be great if someone can (a) tell me how the admin can trace the transactions and (b) restrict the user If out of Balance. Thank you <3
(a) You will need to create a new table Transaction
that will keep track of the exchange between users. Something like (pseudo-Django-Python code):
class Transaction:
id = random_generated_hash()
timestamp = time.now()
buyer = User
seller = User
product = Product
price = float
And then on every transaction, create a new Transaction
entry. You can then either (1) keep track of transactions via the Django admin portal, or (2) create an new admin-only page that shows all of the transactions.
(b)
recvbalance = Balance.objects.filter(user=receiverrUser).first()
if recvbalance and recvbalance.balance >= ctp_val.price: # Whatever is the key for 'product price'.
# Do exchange here.
else:
# Throw error.
0π
thank you @Felipe, I did tried,
ctp_val.update(user=receiverrUser)
Product value has to attribute βupdateβ
then I tried;
ctp_val.user = senderUser
ctp_val.save()
and it worked for me
In (a) I want to know, how I can get recent data/transection details between users.
thank you for (b)<3
- [Answered ]-How do I test a Django model with ImageSpecField?
- [Answered ]-Django β Best practice to join two models
- [Answered ]-Django view os.system permissions / post-receive hook