Skip to content
Advertisement

Tag: django

How can I serialize a queryset from an unrelated model as a nested serializer?

I’m trying to add a nested serializer to an existing serializer based on some criteria of the parent model, not a foreign key. The use case is to return a ‘Research’ object with an array of ‘ResearchTemplate’ objects that are identified by filtering on a Postgres ArrayField. Models class Research(TimeStampedModel): category = models.CharField(max_length=100, choices=RESEARCH_TEMPLATE_CATEGORIES, default=’quote’) body = models.CharField(max_length=1000, blank=True, default=”)

Invalid Endblock tag in django

I am receiving an error message when I go to one of my pages in my Django project, as it is saying that the End-block tag is invalid (asks whether I remembered to register or load). The error looks like this: My code for this template – (login.html) – is below: I am very confused, and I am wondering whether

How to set environment variables in PyCharm?

I have started to work on a Django project, and I would like to set some environment variables without setting them manually or having a bash file to source. I want to set the following variables: I have read this, but that does not solve what I want. In addition, I have tried setting the environment variables in Preferences-> Build,

How to test a Django on_commit hook without clearing the database?

The on_commit function has been added to Django 1.9 to be able to trigger an action (e.g. a Celery task) after the current transaction has committed. They mention later in the docs that one should use TransactionTestCase to test features that rely on that function. However, unlike TestCase (which uses transactions and rolls them back), TransactionTestCase empties the whole database

ModuleNotFoundError: No module named ‘forms’

New to django, I am trying to understand this error. The forms is in the folder of the project. My forms.py is importing from django forms. My views.py is importing LoginForm I don’t know why I am getting this error? Thanks Answer It sounds like it should be working, you might want to post the full error and more of

Create a wav file from blob audio django

On the client side, I am sending a blob audio (wav) file. On the server side, I am trying to convert the blob file to an audio wav file. I did the following: I thought that converting the blob would be similar to converting a blob image to a jpeg file, but was very incorrect in that assumption. That didn’t

Why PDFKit doesn’t work well with margins?

although I just don’t have the need to ask something normally (internet is just a gold mine, especially this site), this is getting me off, as I had been two days trying to get this working and I don’t find anything useful. Link for similar post would be thanked if founded, as I didn’t found one. Let’s get started. I’m

Advertisement