Re: Is there a way to provide a delete-hook on a custom field?
It's a bit offtopic, but: There is a project for non relational Django, and they have released backend for django and mongoDB. It might be interesting for you, if you don't know about the project: http://www.allbuttonspressed.com/blog/django/2010/05/MongoDB-backend-for-Django-nonrel-released На Tue, 13 Sep 2011 10:40:38 -0600 Jeff Heard написа: > I have a custom field class that very nicely references a document in > MongoDB, but I would like to have the document deleted if the record > is deleted. That is, I have a MongoDBField that stores an object ID > in a structured database using the regular Django ORM. The field > back-references to the record's primary key, so I can use NoSQL > lookups and SQL lookups interchangeably to find the same record, even, > which is quite nice. However right now, Ihave to write a custom > delete() function for every model that uses it. I'd like to have > something in the field that whenever the model instance's delete() > function is called. Perhaps the best thing is just to have a class > HybridModel(Model) and have all models that use both databases inherit > from that? > > -- Jeff > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there a way to provide a delete-hook on a custom field?
You can use the post_delete signal in Django's signals. Then, assuming your MongoDB collection name is derived from your model in a consistent manner then you're all set. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there a way to provide a delete-hook on a custom field?
Thanks. That works! -- Jeff On Tue, Sep 13, 2011 at 11:13 AM, Shawn Milochik wrote: > You can use the post_delete signal in Django's signals. Then, assuming your > MongoDB collection name is derived from your model in a consistent manner > then you're all set. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Is there a way to provide a delete-hook on a custom field?
I have a custom field class that very nicely references a document in MongoDB, but I would like to have the document deleted if the record is deleted. That is, I have a MongoDBField that stores an object ID in a structured database using the regular Django ORM. The field back-references to the record's primary key, so I can use NoSQL lookups and SQL lookups interchangeably to find the same record, even, which is quite nice. However right now, Ihave to write a custom delete() function for every model that uses it. I'd like to have something in the field that whenever the model instance's delete() function is called. Perhaps the best thing is just to have a class HybridModel(Model) and have all models that use both databases inherit from that? -- Jeff -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.