This project is a command-line tool for generating and updating Django projects. It uses GPT-3.5 to create HTML templates based on user descriptions, automates project creation, and supports custom templates, CSS, and JavaScript files. Additionally, it handles user authentication.
Features
- Create multiple-page Django websites
- Optional predefined or custom templates, CSS, and JavaScript files
- Generate Django models and forms based on user input
- Authentication features (registration, login, and logout)
- GPT-3.5 generated HTML content for each page
- Update existing HTML templates using GPT-3.5
Prerequisites
- Python 3.8 or later
- Django 3.2 or later
- OpenAI Python Library
Setup
- Install the required packages using pip:
pip install -r requirements.txt
- Set your OpenAI API key as an environment variable or update the openai.api_key value in gpt.py.
- Run the Django project generator:
python main.py create <project_name> <app_name> <num_pages> --template <template_name> --custom_template_path <custom_template_path> --custom_css_path <custom_css_path> --custom_js_path <custom_js_path> --models <model_descriptions>
- <project_name>: Name of the Django project
- <app_name>: Name of the Django app
- <num_pages>: Number of pages to create
- <template_name>: (Optional) Predefined template to use (template1 or template2)
- <custom_template_path>: (Optional) Path to the custom HTML template
- <custom_css_path>: (Optional) Path to the custom CSS file
- <custom_js_path>: (Optional) Path to the custom JavaScript file
- <model_descriptions>: (Optional) List of model descriptions
- Update an existing Django project:
python main.py update <html_template_path> <description>
- <html_template_path>: Path to the HTML template to update
- <description>: Description of the changes to make to the existing HTML template
Project Structure
The project is organized into the following modules:
- main.py: Entry point of the application
- gpt.py: GPT-3.5 functions for generating content and updating templates
- project_creation.py: Functions for creating and updating Django projects and apps
- static_files.py: Functions for handling static files (CSS and JavaScript)
- authentication.py: Functions for generating user authentication views, templates, and URLs
Refer to the source code for detailed information on each module's functionality.
Notes
- This project uses GPT-3.5, which requires an API key from OpenAI. Make sure to set your OpenAI API key in the gpt.py file.
- The GPT-3.5 model has a token limit. If the generated content exceeds this limit, the output might be incomplete. Adjust the max_response_tokens and total_tokens variables in gpt.py as needed.