How to Save Data Input through Form Using a Django Model Form (Django Tutorial) | Part 47

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ส.ค. 2024

ความคิดเห็น • 68

  • @guna23785
    @guna23785 4 ปีที่แล้ว +2

    I would to thank you for posting such a comprehensive videos .. You nailed it !

  • @FreddericUnpenstein
    @FreddericUnpenstein 5 ปีที่แล้ว +4

    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).

  • @cyberspider78910
    @cyberspider78910 4 ปีที่แล้ว

    that , (comma) explanation in python shell....it's subtle but epic at the same time.....Keep up buddy...thanks for tutorial

    • @stelity
      @stelity 3 ปีที่แล้ว

      I always thought {} meant it was a tuple.

  • @kipkiphoera
    @kipkiphoera 3 ปีที่แล้ว

    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.

  • @Azamatmv
    @Azamatmv 7 ปีที่แล้ว +10

    Please, lesson -custom django forms

  • @rahuljaiswal5755
    @rahuljaiswal5755 4 ปีที่แล้ว

    thankyou bro.Fabulous videos

  • @sivarajan00
    @sivarajan00 2 ปีที่แล้ว

    Good tutorials and you look like jordi

  • @siddhartht1345
    @siddhartht1345 5 ปีที่แล้ว +2

    Can you Please explain, how to retrieve data from models, By entering the data in Template.

  • @justingoh7836
    @justingoh7836 3 ปีที่แล้ว

    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.

  • @arpitsingh1000
    @arpitsingh1000 6 ปีที่แล้ว +1

    max it is very good lecture.

  • @RoamingRebel
    @RoamingRebel 4 ปีที่แล้ว

    Thank you for the good class.Very useful

  • @binarycars
    @binarycars 5 ปีที่แล้ว

    Every one of your videos is amazing. Thank you for making them.

  • @icaroamorim3123
    @icaroamorim3123 6 ปีที่แล้ว +2

    Very good job, very well sequenciated.

  • @nikh9852
    @nikh9852 5 ปีที่แล้ว +1

    Hi Sir, Can You Please Make video on Login Form , Data Entry Form With Validations in Django.

  • @alicewanjiku7178
    @alicewanjiku7178 6 ปีที่แล้ว +2

    i love the video but improve on the clarity at some point I couldnt see your code

  • @ibtihelhacheni8365
    @ibtihelhacheni8365 5 ปีที่แล้ว +1

    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 ?

    • @shubhammetkar6021
      @shubhammetkar6021 3 ปีที่แล้ว

      Hey @ibtihel have you found a solution over this?
      Thanks in advance!

  • @victoriacarcillo4520
    @victoriacarcillo4520 3 ปีที่แล้ว

    Does anyone know how to change where it says "Post: " on the website next to the text box to something else?

  • @pascallohscheidt7281
    @pascallohscheidt7281 6 ปีที่แล้ว +1

    really like your way to teach things :)

  • @supersim65
    @supersim65 6 ปีที่แล้ว

    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'

  • @ruhifatima4914
    @ruhifatima4914 4 ปีที่แล้ว

    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

  • @liteoner
    @liteoner 7 ปีที่แล้ว

    Thank fuck, after a day of confusion I finally understand this. Cheers!

    • @liteoner
      @liteoner 7 ปีที่แล้ว

      In fact, this clears up MANY things I didn't understand. Thanks!

  • @harrisonoluchukwuebuka3646
    @harrisonoluchukwuebuka3646 4 ปีที่แล้ว

    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

  • @DavidKelly999
    @DavidKelly999 6 ปีที่แล้ว

    Thank you for this tutorial! I found it very useful.

  • @aurionbaboon2320
    @aurionbaboon2320 5 ปีที่แล้ว

    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?

  • @ruthvikyerra2007
    @ruthvikyerra2007 ปีที่แล้ว

    what is the use of models.model

  • @Lupo9
    @Lupo9 5 ปีที่แล้ว

    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

  • @anky137339
    @anky137339 5 ปีที่แล้ว

    Hi I rendered database table after user filteration . How do user can edit mutliple row cells and save in database

  • @arjunbali2079
    @arjunbali2079 5 ปีที่แล้ว

    How to simply take input on a html form and save it to the database in django from scratch can you explain sir?

  • @danebrown
    @danebrown 6 ปีที่แล้ว

    Great video! Thanks.

  • @maheshlingareddy5924
    @maheshlingareddy5924 5 ปีที่แล้ว

    can you please explain,how to save input through form using mysql in django

  • @hyped2476
    @hyped2476 6 ปีที่แล้ว +1

    Learned new things.

  • @Wiley11
    @Wiley11 6 ปีที่แล้ว

    What is this i am getting all errors the return statement below is unreachable it cannot be reached when form is valid

  • @felixhall6429
    @felixhall6429 6 ปีที่แล้ว

    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?

  • @RizwanAli-bu5oy
    @RizwanAli-bu5oy 6 ปีที่แล้ว

    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!

  • @andrestorres2836
    @andrestorres2836 5 ปีที่แล้ว

    Great video!!

  • @dev_99999
    @dev_99999 6 ปีที่แล้ว

    Can you make another video for multiple fields because when i try it i get error

  • @icaroamorim3123
    @icaroamorim3123 6 ปีที่แล้ว

    What I just wanna save the text in a normal variable to make a request for an API or something
    Like a search field...

  • @mrwubson
    @mrwubson 6 ปีที่แล้ว

    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?

  • @89elmonster
    @89elmonster 6 ปีที่แล้ว

    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?

    • @samyoe
      @samyoe 6 ปีที่แล้ว

      go to previous video then look up what you want on stackoverflow

  • @supernova687
    @supernova687 5 ปีที่แล้ว

    Hey! You realli helped me! Thank you so much. I give you a like and already suscribed :D

  • @estebanmejia9989
    @estebanmejia9989 5 ปีที่แล้ว

    How so important is django at market?

  • @sujeet4410
    @sujeet4410 6 ปีที่แล้ว

    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.

    • @gabenewell8583
      @gabenewell8583 6 ปีที่แล้ว

      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

  • @gabenewell8583
    @gabenewell8583 6 ปีที่แล้ว

    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?

    • @gabenewell8583
      @gabenewell8583 6 ปีที่แล้ว

      now it's fine it actually was supposed to be that way

  • @toolatin5305
    @toolatin5305 6 ปีที่แล้ว

    sir how can i allow form field save as empty?
    because when i use form it require all to fill out before it save.

    • @aronkoppes3089
      @aronkoppes3089 6 ปีที่แล้ว +2

      in forms.py, put in the field: required=False. So you get: forms.CharField(required=False)

  • @Lokamp_
    @Lokamp_ 4 ปีที่แล้ว

    thanks man!

  • @luckychan0701
    @luckychan0701 5 ปีที่แล้ว

    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

  • @akhilez
    @akhilez 7 ปีที่แล้ว

    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?

  • @muhammedhatem4985
    @muhammedhatem4985 6 ปีที่แล้ว

    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.

    • @raphael3666
      @raphael3666 5 ปีที่แล้ว +2

      instead of using django-admin makemigrations use python manage.py makemigrations -- I ran into this problem as well

  • @dev_99999
    @dev_99999 6 ปีที่แล้ว

    thanks

  • @wilsoftm
    @wilsoftm 6 ปีที่แล้ว

    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?

  • @tennis-fan
    @tennis-fan 5 ปีที่แล้ว +1

    showing your monitor without constantly switching to you .... will be much easier to follow

  • @M0_0RPH
    @M0_0RPH 5 ปีที่แล้ว

    U cant explain good :(

  • @milanbhandari9933
    @milanbhandari9933 5 ปีที่แล้ว

    JPT...nonsense tutorial