Skip to content

Tag: django

How to put object datefield in html input value

I have a class “client” with an attribute datefield called “birth_date”. I want to give the possibility for update this field. How can i put the default value in the form, in the input type date? Because the format in “client.birth_date” is different. If i try with, for example: The input value is setting true, but the format is different

Cannot access staticfiles using Pycharm Community Edition

UPDATE: I have updated the followin This is the html file for that specific webpage. Here is the CSS file: I have also changed the settings file like this: You can see my project tree as under for more clarification: Now there is no error but the background image that I am trying to get is now shown on that

‘SessionStore’ object has no attribute ‘cart’ – Django

I generated a basket with 2 products, at the level of the basket page and also on this same page I added a form to insert the customer’s name. by clicking on the submit button which will send the request to a view for insert into the database. but I have an error (‘SessionStore’ object has no attribute ‘cart’) I

django url error this problem is happening only when user is logged in

##error is with line 12 #log ” Traceback (most recent call last): File “/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/”, line 34, in inner response = get_response(request) File “/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/”, line 115, in _get_response response = self.process_exception_by_middleware(e, request) File “/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/”, line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File “/app/website/”, line 298, in gallery return render ( request, ‘gallery.html’, context) File “/app/.heroku/python/lib/python3.10/site-packages/django/”, line 19, in render

Automatic avoidance of category duplicates

I have the problem with Category Model. I have 2 tables: so they are standard models with categories. User can create Category by creating a movie with the name of category additionaly. The problem is when user is trying to create Movie with category name that already exists, because it will create another category with the same name (like duplicate)

Building a custom canonical url in python

I want to build a canonical url for my website: here are the requirements: always include www subdomain always use https protocol remove default 80 and 443 ports remove trailing slash Example: This is what I have tried: But I don’t know how to join these url components? Answer You just need to write a simple function, Execution, Few

Error in running a project regarding virtual environment and “DJANGO_SECRET_KEY” in VS code

I want to run a project from gitlab on my local machine. I cloned the project, created a virtual environment and activated it. When I want to run without debugging I got this error: The output of this project is a form, how can I solve this error to get the output? Answer There’s a good explanation here basically

Django NotEqual custom lookup on related field

I registered a custom lookup base on this answer and official documentation. I registered the custom lookup in my app config. Then i use it in the exclude method this way. The idea here is to get all the customers where user is info.context.user (with private is False or True) OR user is NOT info.context.user but private is False but