Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Overview of Models | Models
Django: Build Your First Website
course content

Conteúdo do Curso

Django: Build Your First Website

Django: Build Your First Website

1. Get Started
2. The First Application
3. Models
4. CRUD Operations
5. Templates
6. Forms and Dynamic URLs

book
Overview of Models

Imagine your program needs to work with a database to store information. Django is a framework that makes this task easy. In Django, there's something called "models".

Models in Django help define what your information looks like and how it's stored in the database. The data types in models act like rules, telling Django how to handle different types of information.

For example, you might have a CharField, indicating you're storing short text like a username. Or a DateField to store a date.

This helps Django automatically create tables in the database and define what kinds of data can be stored. You don't have to manually write SQL queries to create tables or specify data storage rules. The data types in models are like your "rulebook," helping Django understand and efficiently use your database.

Here are some common data types in Django:

  • CharField: Used for short text strings;
  • TextField: Intended for larger text content;
  • IntegerField, FloatField: Used for numeric values;
  • DateField, DateTimeField: For storing dates and date-time values respectively;
  • BooleanField: For storing True/False values.
1. CharField - Used for numeric values
2. BooleanField - For storing True/False values
CharField -  Used for numeric values

CharField - Used for numeric values

Selecione a resposta correta

BooleanField - For storing True/False values

BooleanField - For storing True/False values

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 2
We're sorry to hear that something went wrong. What happened?
some-alt