You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Greetings!
In DRF on creating new object get a ValueError: Ticket objects need to have a primary key value before you can access their tags
Will be apreciate for any ideas where I do wrong
MyModel:
class Ticket(models.Model):
...
tags = TaggableManager(blank=True)
...
@UnLuckyAki sorry, do you have a stacktrace available of your error, so we can see where you are hitting this?
Generally speaking, you can't get the tags of an object before saving the object. Why? Because in order to get the tags of an object we have to do a lookup by the object's primary key. And before you save an object, it doesn't have a primary key, so...
Given your code seemingly not doing anything too weird... this feels like something where maybe we want to have some special-case code in the serialisers, to make things smooth. After all, if an object isn't saved, we can probably say there are no tags. But I am curious about what the stack trace is.
Greetings!
In DRF on creating new object get a ValueError:
Ticket objects need to have a primary key value before you can access their tags
Will be apreciate for any ideas where I do wrong
MyModel:
MySerializer:
MyViewSet:
The text was updated successfully, but these errors were encountered: