Skip to content
Advertisement

Tag: django

django ‘str’ object has no attribute ‘_meta’

Sorry for my English. I have some data from another server, but I need to output this data like JSON. if i print response in console: but, if i return this response like HttpResponse i have an error AttributeError: ‘str’ object has no attribute ‘_meta’ this my code: UPD: I tried with this: but have error: Object of type ‘ModelYears’

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 my

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 django admin and store

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 <my_app_name>, I get this error:

Django Rest Framework – AssertionError Fix your URL conf, or set the `.lookup_field` attribute on the view correctly

I’m trying to return as single object (not a queryset) that is specific to a user without them having to specify an identifier/pk within the requested URL. Each user has an organisation FK. i.e. http://website/organisation and not http://website/organisation/1 I’m receiving the following error, since it’s expecting this identifier: AssertionError: Expected view OrganisationDetail to be called […]

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 models

Advertisement