Django templates and Models

Edit the models.py file in basic app.

Import models and declare first name and lastname in Members class

This will create a database table with the name Members and add to fields by the name of first name and lastname.The following

The following command will apply the changes , i.e create the database.

OUTPUT:

A bit of templating to render the website. Here we create a table named Members with first and last names.

Here we add a clickable button called Add member

The above templating works result in this.

Kindly simple but would do for now.

Now we create the views to connect the app to the Django.

Here the add function loads the add.html and renders it.

And addrecord is used to create the input form.

Another template to render the form.

Adding urls.

Which would create the form.

Published by Saqibfarooq

I am a Computer and Software Engineer from NUST. I have experience in Python development including the full stack, i.e, DevOps, MLOps and for back-end, I can work in Django and Flask. I have contributed to and helped develop ML products, with the ML side comprising of ML subcategories such as NLP, Object detection, and Form processing which includes OCR and NER. And with the Python development side consists of maintaining the end-to-end pipeline and the back-end development. My professional goal is to take on challenging roles that utilize my present skills and enhances them, nourish my professional growth through developing new skills, and allows me to prove myself as a cohesive member of a winning team.

Leave a comment

Design a site like this with WordPress.com
Get started