The explanation on tuple unpacking from 4:10 got a little confused there… The point to make, is the brackets on the tuple are mostly unneeded, but generally included for clarity. They're doing nothing more than exactly the same thing they'd be doing in any other expression - mathematically grouping a set of individual terms, into a single compound expression term, which python calls a tuple. It's actually the comma that makes it a tuple, not the brackets at all; the comma is a "tupalizing operator" (from memory, it's official name is "grouping operator", not to be confused with "expression grouping", which is the mathematical expression sense), and a tuple itself is nothing more than the basic representation of a group of individual terms. So, you can actually write "(x,y) = (1,2)", and achieve the exact same thing - in both cases the brackets are stripped off (they just evaluate away to nothing) during parsing - and what you're left with is assigning a sequence of values (in this case a tuple), to a sequence of variables (also a tuple). This can be further highlighted by making it a little more complex; by changing it yet again to be "[x, y] = range(2)". Here, I'm assigning a sequence of values (in python3, range() will be a generator sequence, not a simple literal sequence at all), into a LIST of variables (a list is also a kind of sequence, plus here, it's a literal sequence because it's written out literally in the code) - all python cares about, is that you're assigning a sequence of values, to a literal sequence of variables, of the same length (python 3's extensions not withstanding). The reason for the literal requirement on the variables sequence, is simply because otherwise the python parser won't recognise it as an unpacking operation, and because you can't actually pass lvalues (the fancy name for the variable to the left of the assignment operator) around (in C/C++, for example, you do that with pointers or references).
Nice video. Small comment on the unpacking of single element tuples. I thought that (1) was not considered to be a tuple, but an expression. So the parentheses are the regular mathematical parentheses, so the result is indeed the integer 1. You add the comma to explain python that it is a tuple.
Hi all, if you want it to display it in your admin page, the following steps are helpful: from django.contrib import admin from .models import Post # Register your models here. class ContactForm(admin.ModelAdmin): list_display = ('post',) admin.site.register(Post, ContactForm) Just take note that whatever you put in your list_display has to correspond with a variable that you made in your models.py file. When I tried to do list_display('name',) it didn't work because my model form had no name attribute.
i want to save data in the administration view of django, i've written in the admin.py the adequat code but when i try to get my data the table created in django administration is always empty ! what should i do ?
Love these tutorials Max. Really concise and clear. I'm running into some trouble here which I can't find the answer to, can anyone help? When posting the form, I'm getting the error... 'duplicate key value violates unique constraint "...user_id_key" Key already exists'
please am having problems with my urls, for am instance if am in my register page at 127.0.0.1:8000/register/ and i click on home nave it redirects me to 127.0.0.1:8000/register/index and i have crosschecked several times in my anchor href to index page i have href="index" and this throws page not found error please any help on this
I saved my model form to the database but it doesnt save my checkboxes correctly it saves all of the checkboxes to the database even if they are not ticked. How do I deal with that situation?
What if the form is not valid? Then 'text' and 'form' are not defined and cant be passed as render args, and I think it will result in an error home/views.py at Line 16
Hey Max, thank you for these tutorials, I have found them very helpful so far. At the end of your video (around 11:50) you pass through the user id for the logged in user. How would we be able to pass through information from one user (say user: A) so that they can add in information to user B?
hi max. i have a created a form, its working well but not storing the data in the database and there is no error came when i submit the data. it submitted but did not storing in the database. please help me!
Can anyone help im trying to migrate the changes and i get this error. raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. any ideas?
I have a user input form but I want to change the form attributes how can I do that? Right now all I can do is add the model Fields but I don't know how to specify the type of form for the templating engine. How can I do that?
not working for me. i don't know what went wrong. i'm new to django and i'm working on my own college project. i'm exluding any field in the meta class and i'm not using user field. what i did is: instance = form. save(commit = False) instance.save() but somehow it doesn't work. when i go to the admin site theres no record being saved. pls help me.
why do you need the first line of code if you're not doing any other operations with a variable 'instance' except just saving it Your second line does all the work you need
when I'm trying to redirect users to 'home: home' my args do not work at all, because "return redirect ..." separates "return render..." in def post. And so because of this, I can't get 'method get' automatically. What should I do? Who knows the solution?
Hey Max! I always wanted to ask you one question. Why is that django has a poor integration with mysql? I know, python 2.7 uses MySQLdb and for 3.4 mysqlclient is recommended. But that mysqlclient throws so many errors, wouldn't install, outdated and is a mess. Later I found one unofficial version of mysqlclient that worked for me. Why is mysql support not maintained for django?
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but s ettings are not configured. You must either define the environment variable DJANGO_SETTINGS_MO DULE or call settings.configure() before accessing settings.
I'm using Django 2.0.4 and when I press the submit button I receive the following error: Cannot assign "": "contact.user" must be a "User" instance. it happens when try to run post.user = request.user any idea?
I would to thank you for posting such a comprehensive videos .. You nailed it !
The explanation on tuple unpacking from 4:10 got a little confused there… The point to make, is the brackets on the tuple are mostly unneeded, but generally included for clarity. They're doing nothing more than exactly the same thing they'd be doing in any other expression - mathematically grouping a set of individual terms, into a single compound expression term, which python calls a tuple. It's actually the comma that makes it a tuple, not the brackets at all; the comma is a "tupalizing operator" (from memory, it's official name is "grouping operator", not to be confused with "expression grouping", which is the mathematical expression sense), and a tuple itself is nothing more than the basic representation of a group of individual terms. So, you can actually write "(x,y) = (1,2)", and achieve the exact same thing - in both cases the brackets are stripped off (they just evaluate away to nothing) during parsing - and what you're left with is assigning a sequence of values (in this case a tuple), to a sequence of variables (also a tuple). This can be further highlighted by making it a little more complex; by changing it yet again to be "[x, y] = range(2)". Here, I'm assigning a sequence of values (in python3, range() will be a generator sequence, not a simple literal sequence at all), into a LIST of variables (a list is also a kind of sequence, plus here, it's a literal sequence because it's written out literally in the code) - all python cares about, is that you're assigning a sequence of values, to a literal sequence of variables, of the same length (python 3's extensions not withstanding). The reason for the literal requirement on the variables sequence, is simply because otherwise the python parser won't recognise it as an unpacking operation, and because you can't actually pass lvalues (the fancy name for the variable to the left of the assignment operator) around (in C/C++, for example, you do that with pointers or references).
that , (comma) explanation in python shell....it's subtle but epic at the same time.....Keep up buddy...thanks for tutorial
I always thought {} meant it was a tuple.
Nice video.
Small comment on the unpacking of single element tuples. I thought that (1) was not considered to be a tuple, but an expression. So the parentheses are the regular mathematical parentheses, so the result is indeed the integer 1. You add the comma to explain python that it is a tuple.
Please, lesson -custom django forms
thankyou bro.Fabulous videos
Good tutorials and you look like jordi
Can you Please explain, how to retrieve data from models, By entering the data in Template.
Hi all, if you want it to display it in your admin page, the following steps are helpful:
from django.contrib import admin
from .models import Post
# Register your models here.
class ContactForm(admin.ModelAdmin):
list_display = ('post',)
admin.site.register(Post, ContactForm)
Just take note that whatever you put in your list_display has to correspond with a variable that you made in your models.py file. When I tried to do list_display('name',) it didn't work because my model form had no name attribute.
max it is very good lecture.
Thank you for the good class.Very useful
Every one of your videos is amazing. Thank you for making them.
Very good job, very well sequenciated.
Hi Sir, Can You Please Make video on Login Form , Data Entry Form With Validations in Django.
i love the video but improve on the clarity at some point I couldnt see your code
i want to save data in the administration view of django, i've written in the admin.py the adequat code but when i try to get my data the table created in django administration is always empty ! what should i do ?
Hey @ibtihel have you found a solution over this?
Thanks in advance!
Does anyone know how to change where it says "Post: " on the website next to the text box to something else?
really like your way to teach things :)
Love these tutorials Max. Really concise and clear. I'm running into some trouble here which I can't find the answer to, can anyone help?
When posting the form, I'm getting the error...
'duplicate key value violates unique constraint "...user_id_key" Key already exists'
your explaination is good.i need one help.plzz by using djongo and mongo DB with local server how to fill form and save it in data base
Thank fuck, after a day of confusion I finally understand this. Cheers!
In fact, this clears up MANY things I didn't understand. Thanks!
please am having problems with my urls, for am instance if am in my register page at 127.0.0.1:8000/register/ and i click on home nave it redirects me to 127.0.0.1:8000/register/index and i have crosschecked several times in my anchor href to index page i have href="index" and this throws page not found error please any help on this
Thank you for this tutorial! I found it very useful.
I saved my model form to the database but it doesnt save my checkboxes correctly it saves all of the checkboxes to the database even if they are not ticked. How do I deal with that situation?
what is the use of models.model
What if the form is not valid? Then 'text' and 'form' are not defined and cant be passed as render args, and I think it will result in an error
home/views.py at Line 16
Hi I rendered database table after user filteration . How do user can edit mutliple row cells and save in database
How to simply take input on a html form and save it to the database in django from scratch can you explain sir?
Great video! Thanks.
can you please explain,how to save input through form using mysql in django
Learned new things.
What is this i am getting all errors the return statement below is unreachable it cannot be reached when form is valid
Hey Max, thank you for these tutorials, I have found them very helpful so far. At the end of your video (around 11:50) you pass through the user id for the logged in user. How would we be able to pass through information from one user (say user: A) so that they can add in information to user B?
hi max. i have a created a form, its working well but not storing the data in the database and there is no error came when i submit the data. it submitted but did not storing in the database. please help me!
Great video!!
Can you make another video for multiple fields because when i try it i get error
What I just wanna save the text in a normal variable to make a request for an API or something
Like a search field...
Can anyone help
im trying to migrate the changes and i get this error.
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
any ideas?
I have a user input form but I want to change the form attributes how can I do that? Right now all I can do is add the model Fields but I don't know how to specify the type of form for the templating engine. How can I do that?
go to previous video then look up what you want on stackoverflow
Hey! You realli helped me! Thank you so much. I give you a like and already suscribed :D
How so important is django at market?
not working for me. i don't know what went wrong. i'm new to django and i'm working on my own college project. i'm exluding any field in the meta class and i'm not using user field. what i did is:
instance = form. save(commit = False)
instance.save()
but somehow it doesn't work. when i go to the admin site theres no record being saved. pls help me.
why do you need the first line of code if you're not doing any other operations with a variable 'instance' except just saving it
Your second line does all the work you need
when I'm trying to redirect users to 'home: home' my args do not work at all, because "return redirect ..." separates "return render..." in def post. And so because of this, I can't get 'method get' automatically.
What should I do?
Who knows the solution?
now it's fine it actually was supposed to be that way
sir how can i allow form field save as empty?
because when i use form it require all to fill out before it save.
in forms.py, put in the field: required=False. So you get: forms.CharField(required=False)
thanks man!
Request Method: POST
Request URL: 127.0.0.1:8000/home/
Django Version: 2.1.5
Exception Type: AttributeError
Exception Value:
'HomeForm' object has no attribute 'save
PLEASE SEND HELP
Hey Max! I always wanted to ask you one question.
Why is that django has a poor integration with mysql? I know, python 2.7 uses MySQLdb and for 3.4 mysqlclient is recommended. But that mysqlclient throws so many errors, wouldn't install, outdated and is a mess. Later I found one unofficial version of mysqlclient that worked for me. Why is mysql support not maintained for django?
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but s
ettings are not configured. You must either define the environment variable DJANGO_SETTINGS_MO
DULE or call settings.configure() before accessing settings.
instead of using django-admin makemigrations use python manage.py makemigrations -- I ran into this problem as well
thanks
I'm using Django 2.0.4 and when I press the submit button I receive the following error:
Cannot assign "": "contact.user" must be a "User" instance.
it happens when try to run post.user = request.user
any idea?
showing your monitor without constantly switching to you .... will be much easier to follow
U cant explain good :(
JPT...nonsense tutorial