Django/ Python! Flashcards

1
Q

What is admin.py?

A

admin.py is used to is used to register created models to the admin interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create a new project in Django?

A

django-admin startproject name .
Don’t forget the period!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you create a new app in django?

A

python manage.py startapp (name you create)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you add an app to your project?

A

You visit the settings.py file and add it to the installed apps list(array). Then, update url patterns in urls.py to include your apps urls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Each class in your models represents a?

A

a table in your database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Each variable in you class represents?

A

a column of your table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how can you create a model (title, return)

A

class Post(models.Model):
title = models.Charfield(max_length=140)

def __str__(self):
return self.title

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do we make migrations?

A

python manage.py makemigrations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

how do we run migrations?

A

python manage.py migrate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how do you create a super user in django

A

python manage.py createsuperuser

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

where do you register your models to work with admin?

A

admin.py

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how do import your models (2 froms, admin.site)

A

from django.contrib import admin
from app.models import modelname

admin.site.register(modelname)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What query set methods are used most often to look up objects from the database?

A

all(), get(), filter() and exclude()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is models.py?

A

Structure of the data and what fields they use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is views.py?

A

Holds class based or function based views, it handles request and return reponses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the migrations folder?

A

Creates configuration of data base and it works together with models.py.