Skip to content

Add Django application with PyGento integration - #1

Draft
Genaker with Copilot wants to merge 5 commits into
mainfrom
copilot/create-django-app-with-pygento
Draft

Genaker with Copilot wants to merge 5 commits into
mainfrom
copilot/create-django-app-with-pygento

Conversation

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

Implements Django web application demonstrating direct Magento database access via PyGento ORM.

Implementation

Django App Structure

  • products/ app with class-based views for Magento catalog queries
  • Three endpoints: home documentation (/), product listing (/products/), health check (/health/)
  • Dual-format responses: HTML templates + JSON API (?format=json)
  • Query parameter: limit (1-100, default 10) with validation

PyGento Integration

from models import init_db
from models.catalog import CatalogProductEntity as Product
from utils.database import DatabaseConnection

# Initialize connection using existing .env config
db_conn = DatabaseConnection()
engine, Session = init_db(db_conn.get_connection_string())
session = Session()

# Direct SQLAlchemy queries
products = session.query(Product).limit(limit).all()

Security & Error Handling

  • SECRET_KEY from environment variable with development fallback
  • Input validation with bounds checking on query parameters
  • Database connection errors return 500 with user-facing error messages
  • Session cleanup in finally blocks

Templates

  • Responsive UI with gradient styling, stats cards, product tables
  • Error state rendering when database unavailable
  • Base template for consistent layout

Testing

  • Test suite covering views, validation, both formats (HTML/JSON)
  • Handles missing database gracefully in tests

Documentation

  • Updated README with Django quick start
  • DJANGO_APP.md with API reference, deployment guide, troubleshooting
  • run_django.py convenience script with startup banner

Configuration

Reuses existing PyGento .env configuration:

  • Database credentials (DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD)
  • MAGENTO_EDITION (community/enterprise)
  • Optional DJANGO_SECRET_KEY for production

Code Quality

  • 473 LOC across 16 Python files + 3 templates
  • CodeQL: 0 vulnerabilities
  • .gitignore excludes __pycache__, db.sqlite3, etc.
Original prompt

Write jango app using PyGento


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 10, 2026 08:38
…outing

Co-authored-by: Genaker <9213670+Genaker@users.noreply.github.com>
…tion

Co-authored-by: Genaker <9213670+Genaker@users.noreply.github.com>
Co-authored-by: Genaker <9213670+Genaker@users.noreply.github.com>
Co-authored-by: Genaker <9213670+Genaker@users.noreply.github.com>
Copilot AI changed the title [WIP] Create Django app using PyGento Add Django application with PyGento integration Feb 10, 2026
Copilot AI requested a review from Genaker February 10, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants