is there difference between TEMPLATES = [ { 'BACKEND': 'django.template.backends.jinja2.Jinja2', ....... }, ] and (imported from django-jinja package) TEMPLATES = [ { "BACKEND": "django_jinja.backend.Jinja2", ....... }, ]
The default format of django timezone.now() example Aug. 15, 2021, 1:00pm how to convert this into 2021-8-15 thanks in advance! Here is my models.py publish= models.DateTimeField(default=timezone.now()) i tried this: publish= models.DateTimeField(default=timezone.now().strftime('%Y-%m-%d')) but its not working , here is …
Im trying to write a django web that will retrieve data from postgresql and display on it. But whenever I run my application it show me: from EmailIngestionDemo.EmailIngestionDemo.models import EmailData ModuleNotFoundError: No module named 'EmailIngestionDemo.EmailIngestionDemo' On my views.py …
So I am trying to loop through the list of classes see if there is a match or not if there is a match return a Response and say there is a match otherwise register the student I am using …
First of all: I know, there are a few solutions for this online, but they wont work for me (because they use e.g. Jason or are just outdated) I work on a project in Django and want to use ajax …
everyone, I am absolutely a beginner in DjangoRestFramework. I have confusion to deal with relationships in DRF. How do I save foreign keys data using APIView? models class User(AbstractUser): email = models.EmailField(max_length=255, unique=True) is_client = models.BooleanField(default=False) is_professional = models.BooleanField(default=False) …
I have this view that creates a form with groups and exercises. How can I do to be able to create more groups and exercises in the template? views.py @login_required def creaScheda(request): if request.method == "POST": form = CreaSchedaForm(request.POST) if …
I want to create dictionary format like ; { "2021": [ { "name": "John Doe", "date": "01.01.2021", "items": "item1" } ], "2020": [ { "name": "Jane Doe", "date": None, "items": "item2" }, { "name": "Jack Doe", "date": None, "items": …
I have an app which uses Angular(with Nginx), Django and MySQL. Each of these are containerized separately on AWS Ubuntu instance. I have been able to connect from Django container to Mysql container and do migrations for Django. Neither the …
I have a forms.py that show a dropdown when creating. But I would like it to be a hidden field when updating. Is it possible to make forms.py show 2 diffrent views depending on you are creating or updating? asset …
I have a web app, backend using Django. I want to change the following SQL query to Django ORM command: SELECT distinct t.id, t.title as Textbook, GROUP_CONCAT(concat(ci.discipline_code, ci.code, " (" , ci.type , ")") SEPARATOR ', ') as CourseCode …
I want to update model fields and fields of related model in one query in Django: Link.objects.filter(alpha=True).update( alpha=False, target__backup_of_original_start=F('target__original_start'), target__backup_of_original_end=F('target__original_end'), target__original_start=F('target__start'), target__original_end=F('target__end'), ) In this question I see that it is impossible using update. Is it possible to …
I am pretty new to django and have an issue with the db. I tried to test a few things and got the following error: Creating test database for alias 'default'... .... RuntimeWarning: Normally Django will use a connection to …
I want to show specific categories of items on a single page. Each category has a subheading and specific categories in the group. Whenever i run the enve, everything is good but each subcategories output all the products, even the …
I have a Django project and I want to update the model using the javascript fetch method put to update the value from true => false and vice versa. however, I get error 500 inbox.js:63 PUT http://127.0.0.1:8000/add-like/14 500 (Internal Server …
How can I use the template tag to create a "p-tag only for products that do not have product_code in the option table"? {% for option in option_object %} {{option.product_code}} {% if option.product_code == None %}} <p> hello </p> {% …
I'm working on a project developed in Python 2.7 and Django 1.11. I'm trying to show in admin page two fields passing through a ManyToMany field. Here the models: class ModelZero(Model): # some fields mtm_field = models.ManyToManyField(to="ModelOne", through="ModelTwo") class …
I am trying to fetch data from a django model while filtering its DateField() to the current date and current hour. models.py class Log(models.Model): DATE = models.DateTimeField() TYPE = models.CharField(max_length=32,primary_key=True) class Meta: db_table='LOG' indexes=[ models.Index(fields=['DATE','TYPE']) ] views.py obj=Log.objects.filter() …
I am trying to integrate some tables from an Oracle DB, which is not a part of my Django project. That DB has 2 tables of interest to me, with the first one having 90% of information, and the 2nd …
I have written API for python speech to text and I want to test using postman so far I have tried this code but not be able to get the result. import speech_recognition as sr from flask import …