Try Django 1.8 Tutorial - 9 of 42 - Models - Learn Django

preview_player
Показать описание
Try Django 1.8 Tutorial - 9 of 42 - Models - Learn Django

Topics include:
- Django Project Setup
- Models, Model Forms, Forms, Form Validation
- Function Based Views
- Integrate Bootstrap front-end framework.
- Django Registration Redux for Authentication/Registration
- Launch on a live server
- And More

Post any/all questions in the comments area -- we try to answer all. If you know the answer someone else's question(s), please share!

We are Coding For Entrepreneurs [CFE] and have built an entire library of content to help you master Django and other web technologies launch real projects faster. Enroll today for as low as $20/month.

What Technology you'll learn in the Try Django 1.8 series:
-- Bootstrap (version 3.3): a powerful front-end framework used by thousands of sites around the world. Bootstrap makes it easier to have a responsive web application so it looks awesome on any mobile device and any desktop computer.

All of our tutorials have a simple goal in mind: get you building something real and quickly.

Рекомендации по теме
Комментарии
Автор

Dame you a life saver!!!! i don't know why they always changing things finally i have something that can explain to me django 1.8!

tawheedcoopoosamy
Автор

Love the tututorial! Why don't you declare the id primary key auto increment in the model? Thanks!

arthurlp
Автор


You just need to add two lines to your urls.py.
import newsletter.views
url(r'^$', newsletter.views.home)

CleverProgrammer
Автор

Can you explain a bit why you define a function in views.py while creating a class in models.py? When do you need to create class instead of just defining function, and vice versa?CodingEntrepreneurs

tdinh
Автор

Very good explanation of how models work.I just didnt understood the part with return '__unicode__(__str__-for python3) ...'
Why did u return email?And What actually happens in the background?

ismailsarenkapic
Автор

Great tutorial so far.
In setting.py why did we add 'newsletter' to the INSTALLED_APPS? what decided that it was newsletter. I was expecting that it would need to be SignUp  @ 10:20 timestamp. Also do you go more into __unicode__ later in the tutorial. the explanation in this video was a bit confusing.
Thanks,
Jordan

JsKr
Автор

Thank you for all tutorials but Sir in this tutorial I didn't get EmailId in SignUps in admin page instead of showing emailId it shows SignUp object. I am using python version '2.7.10'

surtinishi
Автор

Hey! your tutorial is great !
I need to add password field to already created model but widgets com in .forms so how can i do it?
and can i add it to already created model .??

AviNashbakshi
Автор

When I've tried to makemigrations on the models code, the machine has given me two options: "You are trying to add a non-nullable field 'timestamp' to signup without a default; we can't do that(the database needs something to populate existing rows). Please select a fix:

1- Provide a one-off default now (will be setting on all existing rows)
2- Quit, and let me add a default in models.py"

And then I choose 2. I've received a lot of errors, maybe because I'm using Python 3.3? i am doing right?

I've changed to

def __str__(self): #Python 3.3 is __str__
return self.email

VidAgendaConcertsCat
Автор

i have a problem when i run python manage.py makemigration gives errorScreen Shot
in lecture9Screen

vikashkumar-zviw
Автор

CodingEntrepreneurs Hey Justin Please reply
What is the need of creating def__unicode__
when we can get same results if we write email in list_display
I've deleted def__unicode__ function
and changed this
list_display = ["email", "full_name", "timestamp", "updated"]
still the output is same. Is there something going wrong behind all this

kushtrivedigogetter
Автор

I get the "TypeError" takes 2 arguments (2given)
in the 6th line of urls.py

Joshuaknight
Автор

Justin just how soon will Django 1.9 be released for widespread use? Also, we cannot go ajhead and use "createsuperuser" instead of "syncdb" which will be deprecated in django 1.9?

steveburrus
Автор

hi, one question, how can i get done this (store information on my data base) but not with the admin page, besides with another page crated by me, thanks for you help

aburgosTV
Автор

python manage.py migrate
RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got newsletter.views.home). Pass the callable instead.
url(r'^home/', 'newsletter.views.home', name='home'),
Getting this warning..How to resolve?

jayeshbidani
Автор

Are there any sql injection concerns with django + sqlite?

Jose-spkz
Автор

So, we cannot do migrations and similar things when server is ran?

radoznalipustolov
Автор

i did makemigrations and it wont make the model it just says url (r'^$', 'news.views.home', name='home'), news is the name of page im using django 1.9 python 2.7 please help i have had trouble with it and other things that relate to that same string of code im tired of debugging it

papakushi
Автор

class SignUp(models, Model):
NameError: name 'Model' is not defined

РоманБургарт-нй
Автор

from django.db import models


class SignUp(models, Model):
email = models.EmailField()
full_name = models.CharField(max_lenght=120, blank=True, null=True)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.models.DateTimeField(auto_now_add=False, auto_now=True)

def __unicode__(self):
return self.email

РоманБургарт-нй
visit shbcf.ru