Creating a Weather App in Django Using Python Requests [Part 1]

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ก.ย. 2024

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

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

    Want to learn Django so you can build your own web apps? Join my Understanding Django course: courses.prettyprinted.com/p/understanding-django

  • @Denys.Stoianov
    @Denys.Stoianov 6 ปีที่แล้ว +26

    Thank you! Very useful. I like this video format, developing small live app

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

      Thanks for watching!

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

      really!!!!!!!

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

      sorry....wrong post....i meant really???...y u simply lying...tell the truth...

  • @manish236
    @manish236 6 ปีที่แล้ว +4

    Terrific explanation and live demo. Thank you very much for this buddy!

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

      You're welcome! Thanks for watching.

  • @kushaldhkl
    @kushaldhkl 4 ปีที่แล้ว +1

    This deserves all thanks from the middle of my heart. Thanks a lot.

  • @pycodes6832
    @pycodes6832 4 ปีที่แล้ว +3

    This is a great tutorial man, it's helping me to improve my skills.

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

    Thanks Anthony. Your videos are very helpful for people like us.

  • @isaacschultz8805
    @isaacschultz8805 6 ปีที่แล้ว +3

    Thank you, this helped me understand the basics of Django quickly

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

      I'm glad the video helped you. Thanks for watching!

  • @shubhamgupta-lk9ld
    @shubhamgupta-lk9ld 6 ปีที่แล้ว +3

    Its a best beginner practice application, thanks a lot for this tutorial... ☺️

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

    I needed to open an API for one Django project, and consume it from another Django project. This video helped a lot on designing the architecture

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

    simple , crisp and clear

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

    i love solid and clean tutorials .

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

    22:35 A better way to save users input does it this way:
    if request.method == 'POST':
    object = Weather.objects.create(city_name=request.POST['input_text']) # Give input tag an attribute name to access it
    object.save()

  • @tradeiumOfficial
    @tradeiumOfficial 5 ปีที่แล้ว +3

    Great content!
    Can you please give an overview of how youd go about saving the responses from the api to the database? For example, for the purpose of listing the weather over a period of time while adding a new row for the daily weather. Itd be a huge help!!

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

    Another clean and attentive tutorial.Thanks for it.

  • @prajjwalsoni1709
    @prajjwalsoni1709 4 ปีที่แล้ว +1

    kallu bhai, you are best

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

    thank you so much man!
    i created my first weather app...
    its working and displaying one city at a time..
    that means there is some problen with for loop..
    when u was able to display 3 cities in my case only melbourne was displayed..
    but still it works..thats what matter 👍

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

    Thank you, Anthony!

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

    you are a really good teacher thank you

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

    This was very informative and very helpful! Thanks for inspiring confidence in Django novices!

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

    One of the best python tutorials I've seen....!!

  • @blog.pymastery
    @blog.pymastery 4 ปีที่แล้ว

    I found your TH-cam channel too late. however, I am excited to be one of your subscriber!
    Thank you very much.

  • @riskzerobeatz
    @riskzerobeatz 4 ปีที่แล้ว +1

    Great tutorial. Thank you very much :D

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

    when i render the weather template, there is no "city name" column or las vegas weather. mind helping?

    • @nazishaslam9576
      @nazishaslam9576 4 ปีที่แล้ว +1

      I got the same issue because I was using the final version of index.html code while I was still at the initial phase. The problem was in this python line in jinja format -- {% for city_weather in weather_data %} to {% endfor %} -- in index.html. In starting, there is no "weather_data" variable (only city_weather), so you got nothing in the city_weather variable. To avoid this, I commented both these lines as, . But this even worsened the situation as then the whole block between these lines is disabled! And that's weird as it is the standard way of commenting the html code. Anyway, the solution is to remove both these lines from the html code until you get there in the tutorial.

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

    New subscriber here dude. Love how well you explain things. Would love to see more Django tutorials personally. Thank you!

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

      Glad you liked the video! Thanks for watching.

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

      How to get a weather template?

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

    Dude, you're awesome, great tutorial

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

      You're awesome for watching!

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

    So grateful. Great great tutorial....and thanks Python and Django

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

    Great tutorial. Thanks

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

    Very Thank you, I've learned so much, excuse me by my bad inglish, I am from Colombia

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

    God bless you people who help others

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

    Thank you, straight to the point.

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

    can you tell us from where u have taken html code weather.html coz without that we cannot create

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

      I put the code in the link in the description.

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

    Excellent tutorial, really useful. Well done!

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

    Thanks ! excellent, please keep uploading more videos on Django.

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

      I will definitely continue to do so. Thanks for watching!

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

    I've done everything step by step and for some reason my image,description and icon isn't showing I have my api with me but i don't really know the problem for sure...you mind helping out?

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

    I got an idea on how to add student to the database just for my Capstone🤗🤗Thanks!

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

    Thank you very much sir for your clear explanation.

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

      You're welcome! Thank you for watching.

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

    Thanks, great video!!

  • @suresh.suthar.24
    @suresh.suthar.24 ปีที่แล้ว

    good video and project love from india

  • @serhii.chumachenko
    @serhii.chumachenko 6 ปีที่แล้ว +1

    Thanks! It's a good job!

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

    thank you for making this useful video

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

    All the videos are very helpful..Please add some more videos with developing a full website with django and REST please.Elaborate REST Framework more please

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

      I definitely plan to do that in the future.

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

    Just love it,thanks ......

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

      You're welcome! Thanks for watching.

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

    Thank you

  • @chesterholt-quick5742
    @chesterholt-quick5742 5 ปีที่แล้ว

    Great vid man thanks

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

      You're welcome. Thanks for watching.

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

    thank you sir.

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

    what if i dont want to store the cities in the database and i just want to get them from the user input.. how can i do that

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

    hi ! i faced a issue that if i deleted all the cities from db then also in the web one city is fixed and everytime i refreshed the browser the no of the same city increases with the same value.
    What is the solution ?

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

    Hi Antony, what is the best and easiest way of integrating map into a django web application for locations purpose?

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

    Great tutorial anthony but my data is not saving into the database i am using input type submit instead of button

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

    Love your videos. Would you consider a Django tutorial that demonstrates how to use external api data as a way of tracking performance? Similar to your Fortenight Flask tutorial, but also store the data in a db and show trends of a player that a user can interact with.

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

      That's a good idea. I'll consider something like that.

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

    sir, I do same like you but in my "the_weather" folder weather.html file not found. i m using django 2.1.4 version so please help

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

      Are you using a 'weather' directory inside of your template directory like I am?

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

    Thank you!!

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

    Thank you.

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

    Awesome video

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

    How did you get vs code to use intellisense from the bash on windows version of python? Do you have python and django installed on the windows side, then installed them on the bash side?

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

      It worked automatically for me. I didn't install Python outside of Bash to get it to work.

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

      Pretty Printed interesting, ill have to give it a shot then. Any recommended extentions you recommend to go with vs code for python?

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

      I'm still using the base VS Code. I haven't tried any extensions yet.

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

    Thanks a lot!
    Can you please make some videos on how to build a full website with django?

    • @prettyprinted
      @prettyprinted  6 ปีที่แล้ว +3

      Yeah I plan on making more complicated tutorials soon.

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

      Thank you

  • @user-ui2md1ln7f
    @user-ui2md1ln7f หลายเดือนก่อน

    Could you please share the link of second part of this project

  • @abhithumar5766
    @abhithumar5766 4 ปีที่แล้ว +1

    Can you please help me to fix
    'temperature': r['main']['temp'],
    KeyError: 'main'
    please help me

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

      I get the same error

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

      you added the wrong city name

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

    Hello
    Your code does not match with the GitHub code,
    Giving key error at,
    r = requests.get(url.format(city)).json()

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

    is there any another way to fetch API key data without using json

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

    nice work. l like it and l enjoyed it very much

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

      Glad you did. Thanks for watching!

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

    very useful video.

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

    i get TemplateDoesNotExist at / error anyone with a solution

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

      Make sure the folder structure is the same. weather/templates/weather/weather.html

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

    if I am making something similar, should I put in error handling? or just leave it blank

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

    Greate Work... Thanks

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

      You're welcome! Thanks for watching.

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

    Nice video

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

    Great toturial, unfortunately there is a bug. Each time the page is refreshed, the last city entered is duplicated. Anyone know what the reason is?

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

    how to not accept same city? i accidently reload form and resubmit the form and found that it can show same city multiple times. what to do so it wont do it.

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

    It would be much better if you put validations on the name of cities, in case if a user inserts another text instead of an existing city name

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

      That's definitely an improvement. If I remake the video I'll definitely do that.

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

    Hey Anthony, just wondering could you assist,
    I have a ValueError at /
    The City could not be created because the data didn't validate. error,
    I see that the code in the video is different from GitHub repo,
    I can post my repo if needs be ,
    Thank you for assistance
    Big fan of your pythonic skills,
    Regards,
    Clive

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

      You can email me at anthony@prettyprinted.com with your code and I can take a look.

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

    At 7:28 there is a command "pipenv install requests", I was trying the command in cmd window, but it shows an error "'pipenv' is not recognized as an internal or external command, operable program or batch file." Can you help me with the issue?

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

      Did you install pipenv with pip first?

    • @arihantkumar5466
      @arihantkumar5466 4 ปีที่แล้ว +1

      @@prettyprinted No, I didn't back then, but later I have installed it, and the projects is running without any error by now. Thank you for weather app project, it helped me a lot for project development as a beginner. Thanx.

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

    oh was able to find the file at gitub link thanks again

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

    hello, I didn't understand why u passed input from Django forms ({{form.name}}) , as I don't know Django forms concept I am finding it little difficult to understand, could u please help me out ...

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

      You can use the form.name directly when you want to organize your form in a certain way. If you want Django to do it, just use {{ form.as_p }}

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

    whats the soulition if city not found because it raises an error called 'main'

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

      You can check if the city exists before trying to use it. Look at the JSON that comes back to determine the difference between the city being found and not found.

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

      @@prettyprinted try changing the URL API to the one given from the video not from the website API. It worked for me

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

      @@dickyadhitya5805 What is the URL needed?

  • @RaviRaj-th2dc
    @RaviRaj-th2dc 4 ปีที่แล้ว

    From where did you pick the url mentioned in views py?

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

    Bro im getting value error
    Model class has not specified

  • @saurabhsinha3566
    @saurabhsinha3566 4 ปีที่แล้ว +1

    is it really working....,,,,

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

    why using firefox doesn't work?? there's no weather html created !! I am confused

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

    Hi , i have value error, ModelForm has no model class specified. Here, form = CityForm(). Because of what it can be?

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

      Inside of your class for the model form, do you have an attribute like this: model = City ?

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

    Hi I'm having trouble in getting data i.e, the response data's are same for all cities (it returns only for London city) how to fix this

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

      Make sure the URL is being updated with the city typed in the form.

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

    this tutorial helps lot to understand how to consume web-service...I want to know how much time require to activate API key?

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

    i got this error when i want to view template page on index url
    upto 5:24 on video
    This is error
    UnicodeDecodeError at /
    'utf-8' codec can't decode byte 0xb0 in position 2464: invalid start byte

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

    City name temp this things not showing ?

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

    i haven't weather icon, what i should do?

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

      make sure you put the url correct on the template

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

    i have an issue while searching for a new city... it goes back to the main project Urls.py and looks for 'POST'. i want it to stay on the same page like youve shown right before making the forms.py file. but its not working. i dont know if its the button im using but i dont think so because the type is submit... so it may be the {{form.name}} and then name is not being passed through the files of the program correctly.

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

      if i add POST to the urls then it keeps the same data on the page but reroutes to the same home page. no new data was added. Thus only admin pushed data is being displayed please help lol

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

    thanks man

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

    Bro, thank you!

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

      You're welcome!

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

      @@prettyprinted how do you get the same size as the original input, I implemented the same way and added size into widgets but I still get the small box?

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

    I am in 5:40 and while loading the templates there were some components missing from it like the search panel, the location name and the weather. All i can see is the heading and the 'Add City ' button. I will be really grateful if you can spare some time and look at my problem.

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

      same problem for me

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

      @@Digital_illustrations Use the updated weather.html file in Github. This worked for me

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

    Hi,
    I can't access the api URL and i got below error. Please suggest me.
    raise MissingSchema(error)
    requests.exceptions.MissingSchema: Invalid URL

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

      The URL you're using in the request is invalid.

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

    Awesome and quick. I have only 1 doubt i.e How did you connect BUTTON'S SUBMIT with FORM's save functionality?

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

      It's handled automatically be HTML. If you put a submit button inside of form tags, then clicking it when submit the form.

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

      @@prettyprintedThanks for the response. Your really doing a great job. I love you to see your videos on Django.

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

    Hi could u explain why u add city in requests.get"url.format(city)).json

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

      It adds the city to the URL. The city needs to be in the URL for the API to return weather data for that city.

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

    What's the best way to send you a tutorial request for Django?

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

    why am I getting this Error : "list indices must be integers or slices, not str" ? Thank you in advance!

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

      In this app, that usually happens when no data is returned. You can add a check to make sure the data is there before you try to access it.

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

    can the views be changed to CBV

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

    asante sana(swahili 4 thanks)where can i download the .html template sir

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

    Please Can you Kindly update this app When it can record DATE,TIME,DAY,WIND,HUMIDITY, VISIBILITY, PRESSURE, TEMPERATURE and record the data automatically for six months or even a year and be able save into CSV or Json file for your personal projects, thank you??

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

    i have a error msg- type object 'City' has no attribute 'objectes'

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

      it's 'objects'

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

    @20:17 when i add the code for the 'for loop' all cities from the front-end disappear. if i remove the for loop Melbourne reappears? any help appreciated

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

      Make sure you have results in the weather_data variable

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

    hi can you help me. the key error keep saying that i have a problem on 'temperature' : r['main']['temp'],
    KeyError: 'main'

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

      Check out part 2 to this video. I talk about it there.

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

      @@prettyprinted i've tried using sqlite3 db sqlite3 which you have mention in part2, but the same error still occur. How?

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

    Can u show how to make a tourism app... I'm having some problems in building.. Thank you...