Skip to content

Instantly share code, notes, and snippets.

@movEAX
Created July 11, 2014 20:59
Show Gist options
  • Save movEAX/5041cfa527939d72d434 to your computer and use it in GitHub Desktop.
Save movEAX/5041cfa527939d72d434 to your computer and use it in GitHub Desktop.
Расширение для IPython, позволяющее подгружать модели на лету, без импортов.
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