Created
July 11, 2014 20:59
-
-
Save movEAX/5041cfa527939d72d434 to your computer and use it in GitHub Desktop.
Расширение для IPython, позволяющее подгружать модели на лету, без импортов.
This file contains 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
from IPython import Magics, magics_class, line_magic | |
from django.db.models import get_model | |
@magics_class | |
class ModelSearchMagics(Magics): | |
@line_magic | |
def model(self, app_label, model_name): | |
model_class = get_model(app_label, model_name) | |
self.shell.user_ns[model_class.__name__] = model_class | |
def load_ipython_extension(ip): | |
ip.magics_manager.register(ModelSearchMagics) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment