Instalación de Django en Entorno Virtual de Python (virtualenv): Cómo instalar el framework Django ✅
How to Create a Django Web Application from Scratch
Setting Up the Environment
- The video introduces the process of creating web applications using the Django framework within a virtual environment, emphasizing a step-by-step approach.
- A new folder named "rango" is created on the desktop, and Visual Studio Code is used as the code editor to open this folder.
- The speaker creates a virtual environment using Python 3 and mentions that viewers unfamiliar with virtual environments should refer to an earlier tutorial for detailed explanations.
Installing Django
- After activating the virtual environment, the command
pip listis executed to check installed packages, confirming only three are present before proceeding to install Django.
- The installation of Django is initiated with
pip install django, and upon completion, another check confirms that Django has been successfully installed.
Creating a New Project
- A new Django project named "project" is created using
django-admin startproject, which generates necessary files and folders for the project structure.
- Within the project directory, an "apps" folder is created to organize multiple applications related to this project.
Developing an Application
- An application called "app1" is created inside the "apps" directory using
django-admin startapp, establishing its foundational structure.
- A simple model for storing YouTube videos is defined in
models.py, including fields for title (char field), URL (for video link), and upload date (defaulting to current time).
Registering Models and Configurations
- The newly created model needs registration in admin; this involves importing it from models and ensuring proper functionality within Django's admin interface.
- Viewers are encouraged to like the video and check out a free course on Django linked in the description.
Finalizing Application Setup
- To ensure proper recognition of app paths, modifications are made in settings by adding 'apps.app1' under INSTALLED_APPS after adjusting its name accordingly.
- The speaker highlights common issues when working with apps in a structured manner within projects, particularly regarding path recognition.
Database Migration Process
- After verifying access to manage.py file, initial migrations are performed using
python manage.py makemigrations, successfully creating database tables based on defined models.
- A superuser account creation process begins with prompts for username, email, and password setup for accessing admin functionalities.
Completing Migrations
- Initial migrations are confirmed successful; further migration commands ensure all changes take effect before running the server.
Running a Django Server and Managing Videos
Starting the Django Server
- The speaker successfully starts the Django server on port 8000, indicating that there are no issues with the setup.
- Accessing the web browser, the speaker navigates to the admin panel of their Django project and logs in using a previously assigned password.
Video Management in Django
- The speaker demonstrates how to register a video within their application, specifically mentioning a tutorial on Flash as an example.
- After entering video details, they click "save," confirming that everything is functioning correctly within the application.
Conclusion and Engagement
- The speaker expresses hope that viewers find this video useful, especially those who had questions about working with Django.
- They encourage viewers to like, subscribe, and comment on their experiences or thoughts regarding the content shared.