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
Is morph_to feature equivalent to Orator ones ? #224
Comments
morph_to is going from the polymorphic table to the actual record table. To go back the other way I think you would just need a simple belongs_to. Something like this: class Like:
# morphs to articles and comments. An article and a comment can both have likes
@morph_to
def record(self):
pass then on the article or comment model: class Comment:
@has_many('comment_id', 'record_id')
def likes(self):
return Likes.where('record_type', 'Comment') Is there a better way to do this? Maybe I'm missing something |
@josephmancuso Well seems okay to me. Other questions to make this work:
|
@girardinsamuel currently its mandatory yeah. Do you know a way we can automatically guess the model? |
@josephmancuso In Django there is a helper which can return the model class from a string : "users.User" or "blog.Article". The process would be:
|
That's typicaly how its done yeah. We usually store something like
|
Or maybe we should just add a |
@josephmancuso what do you think ? |
umm if we added a morph key, how would we really know? we would have to register the morph map somehow. I think it would be easier to save the namespace and model name and then use pydoc to locate the model if there's no record in the morph map |
I think this question has been answered. If you (or anybody) wants to come up with a proposed solution on enhancing the morph map here I'm all for it |
Opened this issue to clarify the use of
morph_to
.I was using this with Orator:
Then I can call:
So now with ORM, I figured I could do what is below but I can't figure out:
user.notifications()
?(I mainly looked here #168 for info)
@josephmancuso do you have some tips :) ?
The text was updated successfully, but these errors were encountered: