Skip to content

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…

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 …

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 …

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 DESC…

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…