Render Django Form Manually - Make Custom Form with Form Validations | Code Band

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 46

  • @realdaly
    @realdaly Год назад +1

    I've seen some people create a form in the html template with names for the fields and then get the values of these fields by the name in the view when the request is post, so they don't create a forms.py file. Why did you create a forms.py file to set the names of your model fields if it's possible without it, or is you way better??
    My second question is if I have a ManyToManyField in a model that inherits from another model which contains an ImageField to upload images to my db, I wanna make a custom form in html template where I can display all my images that are in the database and be able to select multiple images and when I submit the form I want the selected images to be stored as the values of the ManyToManyField I mentioned before, is such thing possible in Django??
    I hope you answer me and thank you for making this video.

    • @CodeBand
      @CodeBand  Год назад +2

      Handling forms in code is the Djangoish way of dealing with forms, and that's the convention which is considered as the de facto standard.
      And to your second question, that's absolutely possible in Django, in fact it seems to be not too hard to achieve.
      Thanks.

    • @realdaly
      @realdaly Год назад +1

      @@CodeBand
      Aha thanks for your reply, I'm just a beginner in Django that's why I don't know these things 😅

    • @CodeBand
      @CodeBand  Год назад +1

      Hey no problem, happy to help, and its fairly easy to achieve.

  • @muhammadyasir8880
    @muhammadyasir8880 3 года назад +1

    Awesome stuff. Brilliant

    • @CodeBand
      @CodeBand  3 года назад +1

      Thanks a lot😊

  • @TuksimAdventures
    @TuksimAdventures 3 года назад +1

    I was just looking for such video for a long time..... For that case you got my sub :)

    • @CodeBand
      @CodeBand  3 года назад +3

      Thanks for the sub and very glad to hear that!
      Keep going😊

  • @venkatesh.jeyakumaresan
    @venkatesh.jeyakumaresan 4 года назад +2

    Thank you brother. You saved my life as a manual html snippets developer. Do you have any tutorial for saving and updating data from a custom form(Plain HTML Form) using django forms.

    • @CodeBand
      @CodeBand  4 года назад +2

      Glad to hear that brother❤️...Actually, I use Django forms all the time, except for some rare cases. Currently, there is no video in this channel where I deal with plain html forms. Anyway, its not that hard, you can find a lot of tutorials on the web😊

    • @venkatesh.jeyakumaresan
      @venkatesh.jeyakumaresan 4 года назад +1

      Okay thank you brother, looking forward for more educational videos from you. Keep up the good work going 👍

    • @CodeBand
      @CodeBand  4 года назад +2

      @@venkatesh.jeyakumaresan Thanks a lot brother, will keep posting😊

    • @sunami6620
      @sunami6620 2 года назад

      @@CodeBand have you got the tutorial yet?

  • @Huseyin-ty1qd
    @Huseyin-ty1qd Год назад

    Hey man, thank you for the video but ı cant save the form into database by form.save(). What do ı have to do and Problem is form.save is not valid for forms.Form , it is for forms.ModelForm how can ı do it by ModelForm

  • @OthmanAlikhan
    @OthmanAlikhan 2 года назад +1

    Thanks for the video =)

  • @omarouelhazi4199
    @omarouelhazi4199 2 года назад +1

    nice brother

  • @misfarsiddeek3105
    @misfarsiddeek3105 4 года назад +1

    Hi brother. What is the difference between function base view and class base view? Which one is u prefer to use?

    • @CodeBand
      @CodeBand  4 года назад +2

      For beginners just starting with Django, I would highly recommend using Function Based Views(FBVs) because it will actually makes us understand whats going around. Now, if we do have some experience, then stick with Class Based Views(CBVs) as they are highly efficient and wiill do the task just with few lines of code.
      This is one of my playlist in Django Class Based Views. So far, I have only done one video, but I will definitely update that in the future.
      ruclips.net/p/PLbasZIkCgHJFkmaNPyXqrOqFvZlWWlDmW
      Keep learning... :)

    • @misfarsiddeek3105
      @misfarsiddeek3105 4 года назад +1

      @@CodeBand that mean, class base view is secure?

    • @CodeBand
      @CodeBand  4 года назад +1

      Sorry for being late...CBVs are secure as the implementation is already done and we have to just use it. This doesn't mean that FBVs are not secure...Its all up to you and how you design the logic.

  • @mahadev1050
    @mahadev1050 3 года назад +1

    Awesome stuff keep doing. 😊
    Subscribed.

    • @CodeBand
      @CodeBand  3 года назад +1

      Thank you so much 😁

  • @abdullahnasser4121
    @abdullahnasser4121 3 года назад +1

    Brilliant ❤️👌

    • @CodeBand
      @CodeBand  3 года назад +1

      Thanks a lot😊😊

  • @fillaliziad2702
    @fillaliziad2702 2 года назад +1

    thanks alot

  • @ghilesdjebara8066
    @ghilesdjebara8066 4 года назад +1

    THANK YOU !!!!

    • @CodeBand
      @CodeBand  4 года назад +1

      Keep going👍🏻

  • @tneuron83
    @tneuron83 3 года назад +1

    good

    • @CodeBand
      @CodeBand  3 года назад +1

      Thanks a lot😊

  • @tasniasharmin7701
    @tasniasharmin7701 4 года назад +2

    how can I assign those value in the database?

    • @CodeBand
      @CodeBand  4 года назад +2

      You can use form.save() or use Model.objects.create(fields) where Model=your model name and fields are the fields in your model...(eg. Contact.objects.create(phone=323))
      😊

    • @tasniasharmin7701
      @tasniasharmin7701 4 года назад +1

      @@CodeBand yes .. I got it. thank you :)

    • @CodeBand
      @CodeBand  4 года назад +1

      @@tasniasharmin7701 Keep going :)

    • @adnanmiah971
      @adnanmiah971 3 года назад +1

      @@CodeBand I've tried using form.save but I'm not too sure if it's saving the data stored in my text boxes.

    • @CodeBand
      @CodeBand  3 года назад +1

      @@adnanmiah971 form.save() will save the object into the model...👍🏻

  • @akshatchouhan5199
    @akshatchouhan5199 3 года назад +1

    Can you provide a video for user define sign up form containing "password" & "email" field......there is very less videos of it

    • @CodeBand
      @CodeBand  3 года назад +2

      If you are looking for setting up a Custom User Model, then, here you go:
      ruclips.net/video/SbU2wdPIcaY/видео.html

    • @akshatchouhan5199
      @akshatchouhan5199 3 года назад +1

      @@CodeBand buddy my requirements is I have to create 2 signup form for seller and customer in my project....and I wanted to use my table instead of "User" table because each customer has a foreign key which point his data and seller table also has a foreign key which point to it's multiple products

    • @CodeBand
      @CodeBand  3 года назад +1

      ​@@akshatchouhan5199 Using a new Authentication System by completely replacing the built-in one is not recommended unless the case is of extreme complexity. In your case, extending the built-in User model, along with adding multiple user types would do the trick in your case, I believe.
      You can refer this video for more info. : ruclips.net/video/f0hdXr2MOEA/видео.html

  • @instructorleonardolopez2639
    @instructorleonardolopez2639 3 года назад +1

    hi, when I use the reverse_lazy() function it threw the 405 error

    • @CodeBand
      @CodeBand  3 года назад +2

      Guess not because of reverse_lazy() because 405 is Method Not Allowed... so an issue with GET / POST...