Like on clicking a share button that specific shop and its items should be transferred to another user and a receiver user can add that shop in its shopping list.
I tried Django channels but I failed. I was unable to understand how to send object from a model using channel. Every YouTube Video is sending a text using Django channel.
CodePudding user response:
if you want to share a complete shop object to the other user, you don't have to send it direct. You can give the access to this particular object to another user. so that he can retrieve data about shop directly from the database. And in this way, you can save your database space as it don't copying the whole object again in database.
CodePudding user response:
You probably need another model that can do this kind of connection, something like this:
class ShoppingShare(models.Model):
shopping = models.ForeignKey(Shopping, ...
to_user = models.ForeignKey(User, ...
status = models.IntegerField(... # e.g. 1: Not processed, 2: Accepted, 3: Rejected
Then when the user wants to share their shopping list with someone, it creates this ShoppingShare model. The user on the other side can then view the object and click accept/reject, you can then add your logic if they accept etc.