Posts

Showing posts from September, 2022

Django - connect to Mysql database & CRUD APIs

Image
It is easy to connect to Mysql database from Django project. You have to create a database in XAMPP using PhpMyAdmin. Then open settings.py file in djsite/djsite folder. Change the following json values to your database credentials. DATABASES = { 'default' : { 'ENGINE' : 'django.db.backends.mysql' , 'NAME' : 'database name' , 'USER' : 'database user' , 'PASSWORD' : 'database password' , 'HOST' : 'localhost' , } } In the jobform folder, open models.py file and add the following code to create JobForm model. The model have the following data fields: - id (auto generated field) - first_name - last_name - dob - sex - email - education (selection field) - position (selection field) - fileatt - submit_date - user_id A job form belongs to an authorized user. Thus, we add user as a foreign key in the jobform table to make the relationship

Django on Windows

Image
Django is an open source Python web framework that allows fast web development. Django is very popular among many best frameworks such as Laravel, Express, ASP.NET core, etc.  Django uses the MVT (Model View Template) design pattern in which Model is the data  you want to present, View is a request handler that returns the relevant template and content, and Template is an HTML file containing the layout of the web page. In this tutorial, you learn to create APIs with Django and MYSQL. To access APIs, we will create client app using React. To start our development, you have to install the following tools on your local Windows machine.  - Python (version 3.8.2)  Download Python - XAMPP to manage MYSQL database and host Django APIs on apache using mod_wgsi  Download XAMPP - Visual Studio Code Editor to write and debug Django web APIs code  Download VSC After you have installed Python, open Command Prompt and execute the following command to check Python version: D:\>python --version P