This post cross-published with OnePublish
What's up DEVs?
It is time to create another cool project using Django and REST Framework.
In this pos...
For further actions, you may consider blocking this person and/or reporting abuse
Lovely, thanks for sharing this!
When trying to get it to work, I have a potentially dumb error:
I am getting the Rest Entry Point at localhost:8000, however the list of data stays empty.
Same with the default database db.sqlite3 where no data are arriving either (the table is created after doing the migrations, but the select * returns nothing).
However, the celery task works in that it prints the data updates to the console (starting with
Updating data... and the new bitcoin etc. rates).
Now I wonder: am I making a kind of typical, very dumb mistake?
Did you migrate your project? Try to delete all migrations and migrate your project right after you created models. You can check my github I put commands there. Let me know if it worked for you :)
Thank you very much for the fast response! I have now rebuilt everything (also a fresh install of a venv with the requirements), but I am still getting the same problem:
I also tried a completely fresh checkout with a git clone, but again the same issue (Database gets created, but no data end up there. Rest is visible on localhost:8000, but no data arrive, only the celery worker prints the data as intendended)
Hmm, I will check it again in few hours. Can you please update your tasks.py file:
and go check your admin to see objects are created.
Make sure you are running celery and django at the same time.
Thanks a lot, that was it!
is always false, so crawl_currency() was never called.
I have set a celery breakpoint there for the first time, then called crawl_currency() at the breakpoint by hand, and now it works like a charm!
Thanks so much!
P.S.:
Would it make sense to test for an empty queryset instead? Sth. like this:
Great! Ah, I see. Yeah I will fix that line. Thank you for your attention👍
Hello guys, because when this code snippet is active, rabbitmq is idle.
if not Cryptocurrency.objects:
crawl_currency()
while True:
sleep(15)
update_currency()
I didn't understand this logic, could someone help me
thank you sir for such an amazing article. Now I am working on a similar project but instead of refreshing I want my API to automatically stream data whenever new data comes
Can you clarify why does the data have to be stored? serializers seem enough
Must the data be stored? can't you just display it without storing? Kindly explain.
Hi can you add async services like channels to see this data updated in front-end