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
Problem with mixins losing model fields #1342
Comments
I haven't used mixins with Tastypie that much, a test case would be very helpful. |
Havn't had any success getting it to fail in a controlled way yet. Was working with an earlier version of tastypie, so will keep working on it. |
Can you post (or pastebin) your models.py and your resource definition?
|
Is there something I don't understand about caching? In preparing the list of resources and doing a final test to make sure I'm not being obviously stupid, I copied my resources called todos to a new one called todostest, stripped it right down and it worked then. So I slowly added back all the methods and properties and I now have two identical resources, one of which works and the other one doesn't. So I switch the resource_name around. Now the one the was working isn't and visa versa, ie. the one name todos doesn't work and the one name todostest does. Sounds like a cache problem? Tried different sorts and filters but no way can I persuade the broken one to work. It will return a blank set or complain about the name of most of the fields. |
Hmm, interesting. I wonder if it has something to do with "canonical" resources. I'll try to recreate in a test case later. |
@phoebebright Could you add the definition for the todostest resource? |
This looks like the code from the time I had the problem. Both TodoResource and TodoTestResource should the same as I just copied one and renamed it: Since then I've split the code and put all the methods into a class and then subclassed ToDoResource and it all seems to work fine. Have not idea how I broke it I'm afraid or what exactly fixed it again. If there is anything I can test, let me know. |
Neither of those resources are using mixins though. Just to confirm, the error was caused when 2 resources shared the same mixin which defined some fields, correct? Did the mixin class itself inherit from Resource or ModelResource, or just from object? |
The problem SEEMED to be caused by having two mixins on the model, tastypie was not able to identify all the fields that should make up that model. I did quite a bit of tracing trying to see what the problem was but never got to the bottom of it. I still have the two mixins and it is now working but sadly can't say what I did that fixed it, hence my thought it might be something to do with cache. |
I'm having an issue with the api report {"error": "No matching 'priority' field for ordering on."}
where priority field is one of the model fields but on tracing the code, self.fields has only the fields from one of the mixins, there are 2, when it gets to apply_sorting. If this is not a known problem and it's not something I'm doing wrong, then I'll see if I can build a test to replicate it.
The text was updated successfully, but these errors were encountered: