i am creating custom commands in django. i have a problem with conversion timestamp to date by methods like fromtimestamp. i have such error: line 13, in handle timest_conv = datetime.fromtimestamp(timest) OSError: [Errno 22] Invalid argument this is my class with handle Answer The timestamp is expressed in milliseconds since January 1st, 1970. You thus should divide these by 1’000
Tag: django
Module ‘project_name’ has no attribute ‘celery’
I’m trying to set up a background task using celery and rabbitmq on django but I’m getting an error saying that my project has no attribute celery. I’m using PyCharm and installed celery through that. I’m new to celery but I’ve read a lot of articles similar to this issue (AttributeError: module ‘module’ has no attribute ‘celery’ this one seems
How to transfer data from one list to another in Django?
I’m doing a small to-to list, I’m stuck in views.py, there are to-do tasks, in-progress tasks and done tasks, I want to move a task from the to-do task list to the in-progress task list, I can’t figure out how to delete the data in the to-to task and make new data same as to-do task in the in-progress task
Template syntax error Could not parse the remainder: ‘(“images/logo.png”)’ from ‘static(“images/logo.png”)’. in django-jinja template?
when including the static files in the Django-jinja template it shows an error. If I removed that line It worked. But I want to load my static files in jinja template. Answer First you have to load static at top of your html page Then you have to use {% %} instead of {{ }}
how to pass input to api from angular forms without formControlName?
I am passing some data from angular to django rest api, Which is as follows first what django need in for api: what I am passing from angular now my issue is that I am not taking classname as input because It doesn’t make sense here so is there any other way by which I directly pass classname to api
Django form keeps information after submission
I have a Django form and I am trying different options to do 2 things when the form is submitted: Redirect the form back without any information Trigger a Modal after a Django Form is submitted. I have followed this answer but it did not work the form was successfully submitted but the modal did not appear. I have added
Django merge QuerySet while keeping the order
i’m trying to join together 2 QuerySets. Right now, I’m using the | operator, but doing it this way won’t function as an “append”. My current code is: I need the elements from querysetA to be before querysetB. Is it even possible to accomplish while keeping them just queries? Answer This can be solved by using annotate to add a
Django – Retrieve all manytomany field objects related to a specific model
I have my models reviews and news, both having a manytomany relation with Category model. Now I want to get all the categories associated with only one of these two models. For example, to get all categories associated with News model, I tried querying database with News.categories.all() but got AttributeError: ‘ManyToManyDescriptor’ object has no attribute ‘objects’. News Model: Reviews Model:
Splitting dictionary objects
I am building a Blog App and I made a queryset which is showing blog date and likes of every day since blog date, But it is showing in dictionary and i am trying to show both instances differently in table like. Blog Date Likes 20 Sep. 6 Likes 21 Sep. 2 Likes 22 Sep. 4 Likes But it is
Why isn’t my .Dockerignore file ignoring files?
When I build the container and I check the files that should have been ignored, most of them haven’t been ignored. This is my folder structure. Let’s say i want to ignore the __pycache__ & data(data will be created with the docker-compose up command, when creating the container) folders and the .gitignore & .env files. I will ignore these with