Skip to content
Advertisement

Tag: django

convert timestamp to date in custom commands

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

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

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

Advertisement