Skip to content

Tag: django

Add custom CSS styling to model form django

I am using a bootstrap variant to help style a model form. There is a certain class I would like one of the fields to be and I have read around on the subject and the general consensus is to add a widget to the ModelForm’s meta, like I tried below: forms.py However this doesn’t seem to render onto…

Django multiple image upload to S3

I am struggling to find a solution for a photo gallery in django. I’ve checkout out every django photo package (photologue, imagekit, etc.) I could find an none of them are really helping me in my quest. I am trying to build a simple image gallery that will allow me to upload multiple photos from the dj…

Getting TypeError: __init__() missing 1 required positional argument: ‘on_delete’ when trying to add parent table after child table with entries

I have two classes in my sqlite database, a parent table named Categorie and the child table called Article. I created first the child table class and addes entries. So first I had this: And after I have added parent table, and now my models.py looks like this: So when I run python manage.py makemigrations &l…

Cannot import models from another app in Django

so I have 2 apps running in the same project. My files are structured as follows: So, I for some weird reason have a different name for my base directory (that is, it ends with codebase). Hopefully, that is not an issue. In my settings.py, I have this: Ok, so in my models.py (from app2), I can easily import m…

Django writing generic update view restricted to certain user

I am building a small blog using django.I want to build a function that allow post author to delete and update their own posts. Then I find django has LoginMixin for generic view,but it only block those who don’t login. My article Model is like below This is the generic article detail view. I firstly wa…

Django: m doesn’t look like a module path

I can vistit the /admin url but went I login admin or call my login api. I got this error message error: Answer You haven’t given enough details to know for certain, however I am going to guess that this is a problem with your AUTHENTICATION_BACKENDS setting. See Django AUTHENTICATION_BACKENDS import er…