This is what my template index.html looks like And here is my urls.py file Finally, this is my link view inside of the views.py file Where page() is a function that takes one argument. I want the id of the <a></a> tag of index.html to be that argument. But I have no idea how to access get that id inside
Tag: django
Django administration Site. ‘Delete multiple objects’ produces ValidationError
When attempting to delete multiple rows, which have a one to one relationship with two other tables I received the following error: The models are set up as such: I am trying to delete the items in the Home › My_App_Main › Medias › Delete multiple objects from the Django administration site. Which presents me with the following: Are you
NoReverseMatch Reverse for ‘save-post’ with arguments ‘(”,)’ not found. 1 pattern(s) tried: [‘save/(?P[0-9]+)$’]
I cannot figure out why I keep getting this “NoReverseMatch at /”. I am trying to add AJAX to a form to save posts. It seems to be a problem with the URL in the Javascript, but I cannot figure out exactly what it is. Can anyone tell me what is wrong here? Thank you in advance. urls.py views.py popular.html
Django get user data in main template
I’m trying to check if user logged in in the main template using this: but it’s not working maybe because main template doesn’t have a view could any one help i don’t know if the question duplicated,but i didn’t find my answer. Answer you could use:
Auto update model value based on another value in this model django
I have a model called Products. This model has values like this How can I change display to be False if stock is equal to 0 automatically, so when client buys last product in store display value will change from True to False and will result in products that I want to show or are in stock. I know that
NameError: name ‘urlpatterns’ is not defined using i18n_patterns
I have problems writing the urls for translation. According to this question I understand that it is because I have += so I need to put this = the bad thing is that I have to translate all my urls I can’t leave any outside of i18n, what can I do to include all my urls there? Answer You did
Django How to link a foreign key to many tables
I have n classes and each class contains a column called key like this (where n==3) I want to make the column key as Foreign key between all the n classes? I know how make a foreign key between 2 classes but I want to do that with many classes because I have about 40 classes and some classes has
Using unittest.mock to mock a DRF response
My example is pretty basic: What I’m trying to do is mock the request to the /core/ URI so it returns a mocked response and not the response from the database. For example, considering unit testing in a CI pipeline when the database isn’t available. The below is what I have, but print(response.data) returns the actual response and not the
In django what is the use of urls.py for each app?
I am making a django project and i learnt that we need to create a urls.py file for each app created within project. Can anyone please tell what is the purpose of this because we have one urls.py file for the main project, isn’t that enough? Answer Mostly for reusability, partly for organizational reasons. Separate urls.py files allow django apps
After Changing Python Version 3.6 to 3.10 I got cannot import name ‘Callable’ from ‘collections’
Answer The offending line has been removed from Celery nearly 6 years ago. You should update the celery package to a recent version.