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’
Tag: django
Django: Gmail SMTP error: please run connect() first
I am trying to send mail when a certain query is executed. But I am getting error in the connection. I have tried the following settings in my settings.py file server = smtplib.SMTP(‘smtp.gmail.com’) …
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 Celery delay() always pushing to default ‘celery’ queue
I’m ripping my hair out with this one. The crux of my issue is that, using the Django CELERY_DEFAULT_QUEUE setting in my settings.py is not forcing my tasks to go to that particular queue that I’ve …
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
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 …
Run / Debug a Django application’s UnitTests from the mouse right click context menu in PyCharm Community Edition?
I must emphasize on PyCharm Community Edition which does not have any Django integration (v2016.3.2 at question time). I’ve Googled my problem and (surprisingly,) I did not get any answers, (of course I don’t exclude the possibility that there might be some, be but I just missed them). The question is simple: in PyCharm, one […]