{"id":21649443,"url":"https://github.com/wazedkhan/vscode-django-notebook","last_synced_at":"2026-01-28T01:04:10.918Z","repository":{"id":264053997,"uuid":"892211132","full_name":"WazedKhan/vscode-django-notebook","owner":"WazedKhan","description":"A lightweight Python package for running Django queries and tasks directly within Jupyter Notebooks in VS Code. Quickly initialize your Django project and interact with its ORM, models, and utilities — perfect for debugging, data inspection, and experimentation","archived":false,"fork":false,"pushed_at":"2024-11-21T18:36:41.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T20:11:43.736Z","etag":null,"topics":["debugger","debugging-tool","django","django-debug","django-orm","juypter-notebook","python","vscode"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/vscode-django-notebook/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WazedKhan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-21T17:42:26.000Z","updated_at":"2024-11-22T05:48:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"a19914a5-6664-4edf-966f-7307069f6b45","html_url":"https://github.com/WazedKhan/vscode-django-notebook","commit_stats":null,"previous_names":["wazedkhan/vscode-django-notebook"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WazedKhan%2Fvscode-django-notebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WazedKhan%2Fvscode-django-notebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WazedKhan%2Fvscode-django-notebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WazedKhan%2Fvscode-django-notebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WazedKhan","download_url":"https://codeload.github.com/WazedKhan/vscode-django-notebook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252949285,"owners_count":21830153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugger","debugging-tool","django","django-debug","django-orm","juypter-notebook","python","vscode"],"created_at":"2024-11-25T07:30:49.260Z","updated_at":"2026-01-28T01:04:10.912Z","avatar_url":"https://github.com/WazedKhan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vscode-django-notebook\n\nEasily run Django queries and tasks within Jupyter Notebooks in VS Code.\n\n## Overview\n\n`vscode-django-notebook` simplifies the process of initializing Django projects directly in Jupyter Notebook cells. This is particularly useful for quick debugging, querying, and testing in a flexible notebook environment.\n\n---\n\n## Features\n\n- **Convenient Django Initialization**: Avoid repetitive setup steps in Jupyter Notebooks.\n- **Interactive Django ORM Access**: Use Django models and utilities interactively.\n- **VS Code Compatible**: Tailored for the Jupyter extension in VS Code.\n\n---\n\n## Installation\n\nInstall the package via pip:\n\n```bash\npip install vscode-django-notebook\n```\n\n---\n\n## **Setup Guide**\n\n### Step 1: Create a Folder for Notebooks\n\nOn the same level as `manage.py`, create a folder to organize your Jupyter Notebooks. For example:\n\n```\nyour_project/\n├── manage.py\n├── config/\n│   ├── __init__.py\n│   ├── settings.py\n│   ├── urls.py\n│   └── wsgi.py\n├── notebook/\n│   ├── __init__.py\n│   └── user.ipynb\n```\n\n* **Folder Name** : You can name this folder anything you like (e.g., `notebooks`, `playground`, `testing`). In this example, we use `notebook`.\n* **Notebook File Name** : The notebook file (e.g., `user.ipynb`) can also have any name, depending on its purpose.\n\n---\n\n### Step 2: Select the Project's Environment in VS Code\n\n1. Open the `user.ipynb` notebook in VS Code.\n2. In the top-right corner of the Jupyter Notebook interface, click on the  **kernel selection dropdown** .\n3. Choose the Python environment where your Django project dependencies are installed.\n\n---\n\n### Step 3: Install and Initialize `vscode-django-notebook`\n\n1. Install the package:\n\n   ```bash\n   pip install vscode-django-notebook\n   ```\n2. Add the following code at the top of your notebook to initialize Django:\n\n   ```python\n   from vscode_django_notebook import init_django\n\n   # Initialize Django by specifying the project name\n   init_django(project_name=\"config\")\n   ```\n\n   Replace `\"config\"` with the name of your Django project module (where `settings.py` is located).\n\n---\n\n### Step 4: Write Complex Queries or Debug Utilities\n\nOnce initialized, you can interact with Django models, run complex queries, or debug utilities directly in the notebook. Here's an example:\n\n#### Example: Testing a Query\n\n```python\n# Import Django models\nfrom myapp.models import User, Order\n\n# Write and test complex queries\nusers_with_recent_orders = User.objects.filter(\n    id__in=Order.objects.filter(date__gte=\"2024-01-01\").values_list(\"user_id\", flat=True)\n)\n\n# Inspect the results\nprint(users_with_recent_orders)\n```\n\n#### Example: Writing and Debugging Utilities\n\n```python\n# Utility function to calculate total revenue for a user\ndef calculate_user_revenue(user_id):\n    from myapp.models import Order\n    return Order.objects.filter(user_id=user_id).aggregate(total_revenue=Sum(\"amount\"))[\"total_revenue\"]\n\n# Test the utility\ntest_user_id = 1\nprint(f\"Total revenue for user {test_user_id}: {calculate_user_revenue(test_user_id)}\")\n```\n\n---\n\n### Benefits of This Workflow\n\n* **Interactive Testing** : Test Django ORM queries and helper functions interactively.\n* **Debugging Made Easy** : Debug utilities or inspect data before adding them to the project.\n* **Reusable Code** : Refine and reuse tested code in the actual project.\n\n---\n\n### Troubleshooting\n\n* **Jupyter Kernel Not Working** : Ensure you’ve selected the correct Python environment in VS Code.\n* **Initialization Error** : Verify that the `project_name` in `init_django()` matches the folder containing your `settings.py`.\n\nNow you're ready to streamline your Django development workflow using Jupyter Notebooks! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwazedkhan%2Fvscode-django-notebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwazedkhan%2Fvscode-django-notebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwazedkhan%2Fvscode-django-notebook/lists"}