Creating Tech_Projects app Models - SethuGopalan/ebdjangoVR GitHub Wiki
Here We going to use Django built-in Object Relational Mapper (ORM).An ORM is a program that allows you to create classes that correspond to database tables. Class attributes correspond to columns, and instances of the classes correspond to rows in the database When you’re using an ORM, the classes you build that represent database tables are referred to as models. In Django, they live in the models.py module of each Django app. We need to create for Tech_projects app, only one table to store the different projects so that we only need to create one model in models.py.
The model you’ll create will be called Tech_Project and will have the following fields:
title will be a short string field to hold the name of your project.
description will be a larger string field to hold a longer piece of text.
technology will be a string field, but its contents will be limited to a select number of choices.
image will be an image field that holds the file path where the image is stored.
To create this model, we’ll create a new class in models.py and add the following in our fields:
Django models come with many built-in model field types. CharField is used for short strings and specifies a maximum length.TextField is similar to CharField but can be used for longer form text as it doesn’t have a maximum length limit. FilePathField also holds a string but must point to a file path name.