Skip to content
Advertisement

Tag: django

How to connect 2 forms in HTML and Django?

I am creating a web page and i’m wondering if i could make sure that the data on the left is filled before pressing the blue button. On the left you can see a form to pay by entering your address, city etc. but on the right you can see another form with stripe implemented to pay with credit card.

Django index unique on where

I have a class, which represents photos attached to a person. I want to make sure that for every person there could be only one main photo. In pure SQL i would use something like You can play with it here http://sqlfiddle.com/#!15/34dfe/4 How to express such constraint in django model? I am using django 4.0.1 Answer You can add a

How to add data to Many-To-Many field in Django DRF

I’m new to Django DRF, trying to have a sports school project done. I have a model for coaches, classes and students. Here is a stripped version to keep it simple and easy: In order to list/add students to the class, I’m using the following serializer: Getting the data is working ok. Also, adding a coach is working fine, what

Django Template Aren’t Loading

I’m trying to load different html files into the base.html and they’re not showing. Any ideas? Answer I think you may be confusing template inheritance with template composition. In template inheritance, you have a base page like base.html: Then, you have a second template shoes.html that extends base.html. It inherits all the HTML from base.html, but fills in some custom

Django Azure SQL ProgrammingError Invalid Object name

I am trying to use Azure SQL with Django by using mssql-django. I get this error during “makemigrations”: django.db.utils.ProgrammingError: (’42S02′, “[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name ‘customer_group_customergroup’. (208) (SQLExecDirectW); [42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)”) The connection to Azure SQL is already working. If I start a new app,

Error: __str__ returned non-string (type ModelName) in Django

I am attempting to create an issue tracker similar to github’s. I’m stuck on trying to implement the assigning feature, here’s what I have so far admin page I feel like I’m close, however when I try to use I get the error of Anyone ideas on how to fix this? Thank you. Answer ERROR DESCRIPTION str returned non-string (type

django.db.utils.DataError: value too long for type character varying(30). I am getting this error while migrating on heroku postgresql

The errors I am getting while migrating on PostgreSQL Heroku. Note: It is working fine on the local server. there is no column with 30 lengths even tried migrating after deleting all data and still getting the same error. This is the model of the project models.py Answer I just deleted the junk file inside the migrations>pycache

get more than two foreign keys from another django table and perform calculations on them

In the Django app, I have created two tables. Product Invoice I have one table called Product which contains product name and product price columns are given. Then, I have a second table named Invoice which contains a product name(foreign key), product price(foreign key), discount, and total. My concern is how can I import both the values from the Product

Python/Django routing messed up when clicking a button

I am working through a basic django tutorial and I have become stuck. When the favorites button is clicked I am trying to redirect the user to reviews/favorite, which will then redirect to reviews/review_id, which is where they started. Instead, whenever I click the favorite button on the page it redirects me to reviews/reviews/review_id which fails. Interestingly enough if I

Advertisement