Skip to content

Instantly share code, notes, and snippets.

@lukegb
Created January 13, 2016 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukegb/b34efa0f90dc9e2aae1e to your computer and use it in GitHub Desktop.
Save lukegb/b34efa0f90dc9e2aae1e to your computer and use it in GitHub Desktop.
I went a little overboard
import django
django.setup()
from dukpy import Context
from ore.projects.models import Project
ctx = Context()
ctx.define_global_obj("Project", Project)
ctx.define_global_func("get_first_project_for_namespace", lambda name: Project.objects.filter(namespace__name=name).first())
ctx.evaljs("""
var project = get_first_project_for_namespace('lukegb');
print(project.namespace.name, project.name, project.full_name(), project.is_visible);
""")
lukegb asdf lukegb/asdf true
@tazjin
Copy link

tazjin commented Jul 13, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment