-
-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tags.add function not working in pre-save/post-save in django #818
Comments
Does this code not work if you use the |
@rtpg No it's also not working for post-save |
Could you do something like:
and show the results here? that might make it a bit easier to debug what is going on |
after that I got this ;
But tags are not saved in data table tags field. |
@rtpg please any suggestion for that |
I made some progress on tracking this down but not entirely sure how to address it. Looks like when creating/editing an object in the admin view with a post_save signal the order of operations is:
Looks like the tag is added with the post_save then overwritten with the .set() in the save_form_data. I can work on a PR to try to address this, thoughts on the best method? |
Made a little more progress identifying the issue:
This is why printing the tags before and after the add in the post_save shows the correct tags, but once saved the post-save tags are gone. The solution to form.save(commit=False) is listed in the docs. I've played around with it a little, attempting to overwrite various save methods and setting custom forms for the Admin view but everything I've tried brings other problems. I'm open to ideas. I'll keep investigating as I have time. |
@chambersh1129 thanks for digging into this, I get what you're saying. I don't think this is really a bug, signals are really nastly like this. For me what I do in these situations is to just give in and write a So yeah, recommendation here is to overwrite the Admin form (there's a |
I'm labelling this a |
I am using django taggit for tags. I want to add fields text in tags for some data table. But its not working.
models.py:
pre-save function:
It's neither showing any error nor working. Any one please help if any solution or alternative.
The text was updated successfully, but these errors were encountered: