This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_child_instance_from_parent(child_cls, parent_instance): | |
| parent_cls = parent_instance.__class__ | |
| field = child_cls._meta.get_ancestor_link(parent_cls).column | |
| # We could specify a parent_identifier which is a unique field in | |
| # the parent class that link child to parent | |
| if hasattr(child_cls, 'parent_identifier'): | |
| try: | |
| child_instance = child_cls.objects.get( | |
| **{child_cls.child_parent_identifier: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://stackoverflow.com/questions/9821935/django-model-inheritance-create-a-subclass-using-existing-super-class | |
| class Place(models.Model): | |
| name = models.CharField(max_length=50) | |
| address = models.CharField(max_length=80) | |
| class Restaurant(Place): | |
| serves_hot_dogs = models.BooleanField() | |
| serves_pizza = models.BooleanField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function parseHashBangArgs(aURL) { | |
| aURL = aURL || window.location.href; | |
| var vars = {}; | |
| var hashes = aURL.slice(aURL.indexOf('#') + 1).split('&'); | |
| for (var i = 0; i < hashes.length; i++) { | |
| var hash = hashes[i].split('='); |
NewerOlder