I have these two models and as you can see they have a relationship. As far as I understand if I query posts and push them to a template and post, I would expect to use something like this in my templates to retrieve the images URL attached to the posts but it doesn’t seem to work. What am I
Tag: django
Calling an External API That Fails Randomly
I am using Django server to call a Korean government’s weather API to retrieve weather data for around 1800 locations. However, this weather API results in time out most of the time. I tried giving resting periods. For example, for every request, it will sleep for 0.8 seconds and after every 30 requests, it will sleep for 30 seconds. But
ValueError: Field ‘id’ expected a number but got ‘Die erste Meldung’. after adding an item via console
I’m trying to add an item into db.sqlite3 via command line but got this error: Inside migrations001_initial.py below the field id of contentobject Meldung is declared as auto_created=True, but it seems it’s not working as expected. How can I solve it? expected result Field ‘id’ is generated automated by db.sqlite3 environment Python 3.8.2 Django 3.1.3 models.py migrations001_initial.py Answer The first
parse json object in django view
I have a form than i need to check if the emails on my form are valid or not here is my ajax code : and this is my code in django view: it raises this error : TypeError: the JSON object must be str, bytes or bytearray, not ‘NoneType’ thanks in advance Answer TypeError: the JSON object must be
Serialize a M-2-M relation with grouping in Django REST framework
I have two models, linked through a separate model as follow: Serialized is pretty straight forward: A viewset returns the total number of houses assigned to each employee for different projects, summed over dates: In the output we have multiple records for each employee: I want to convert it to a nested list so that the booked hours show up
Django form: phone field not showing
I would like to create a contact form on my Django website. For now, this is my code: models.py: forms.py: views.py: html: I of course installed phonenumber_field and added it in settings.py This is the result, phone field missing: Any help is hugely appreciated! Thanks for your time. Answer You used a model field, whereas for a form, you need
django – how to save api data into model from template button
I am using the Yelp API to search bars in a any location. This uses a template called results.html that has a button. Clicking this button should save the Yelp API unique ID of a Bar into my models. In my results dictionary that I loop over I call this ‘id’. This is where I am having issues, taking the
How to filter and paginate in ListView Django
I have a problem when I want to paginate the filter that I create with django_filter, in my template it shows me the query set and filter but paginate does not work, I would like to know why this happens and if you could help me. I’ll insert snippets of my code so you can see. This is my views.py
TypeError: float() argument must be a string or a number, not ‘Profile’
Problem: I’m trying to get the latest value from my model called Profile. But I’ve encountered a problem, when I try to save it to a variable as a float value I get this error TypeError: float() argument must be a string or a number, not ‘Profile’. I need this so, I can make calculations with the datas. Models.py file:
djnoer gives TypeError: permission_denied() got an unexpected keyword argument ‘code’ on get request on /users/me/
Doing just a get request on auth/users/me/ results in this error which says the above. Couldn’t find anything that helps. Can you help me figure out where this error is coming from and how can I fix it. The link to the tutorial I was following is below. Just had setup a new project and installed djoner with jwt. Below