Database Development Django HTML

How can I populate an HTML dropdown with data from a database using Django?

I’m attempting to create a dropdown selection on an HTML page containing options (specifically, the userID and name of a character for the user to select to load into a battle simulator) from my database, but it keeps coming up empty without any errors or any indication as to what is wrong. I’m trying to […]

Sending data from Django application to another Python script

I have a Django application where some data can be saved on my database using a form. I would like to create a Python script that, as soon as a new record is created, sends that data to an external Python script as json, and this external Python script should perform some operation with this […]

Convenient monitoring of database under Django

I am developing a web app under Linux and use Django for its back-end along with MySQL database (via DBeaver). Everything is awesome, but I was not yet able to find a convenient way to monitor the behavior of Django ORM. I want to see which queries ultimately hit the database in a convenient way. […]

Django extra button in a model’s changelist for Django Admin

So I want to add an extra button in my Fun model’s changelist_view which when pressed, performs a function and redirects me to a new page. I don’t want to have this function for every app nor do I want for every model, only the Fun model. And I will be using Django Admin to […]

I import the module TinyMCE and the django isnt working

I think I have a outdated verison of TinyMCE and i was wondering how to fix the ImportError: cannot import name ‘TinyMCE’ from ‘tinymce’. It was working before i from django import forms from tinymce import TinyMCE from .models import Post, Comment class TinyMCEWidget(TinyMCE): def use_required_attribute(self, *args): return False class PostForm(forms.ModelForm): content = forms.CharField( […]

Send data from Django to another server

I have an already existing Django app. I would like to add a system that sends data from my Django application to another Python application hosted on another server, so that the Python application receives data from the Django App in json format, possibly. So for example, i would need to create a view that […]

Synonymous many to many model relationship in Django

I’m trying to achieve what you could call a “synonymous” relationship on a self referencing many to many field in Django. Take this model for example (in reality I don’t use real words, but category tags instead): class Word(models.Model): name = models.CharField(max_length=30, unique=True) synonymous = models.ManyToManyField(‘self’, blank=True, related_name=’synonymous’) def __str__(self): return What I want […]

Development Django

How to pre select value in a django forms.Select field

I am new to django. I am creating a simple CRUD application using django 2.2, I have a simple addstudent.html page where i can add data in some fields including a dropdown where I can select the class of student and database is updated. Below is my code: class StudentForm(forms.ModelForm): class_list= [ (‘Class IIX’, […]

Dynamic choices for django forms

I’m building a booking form, and want to allow users to pick a date of booking from available dates in the next 60 days. I get the next 60 days by: base = date_list = [base + datetime.timedelta(days=x) for x in range(60)] Then I subtract already booked dates which are stored in the db: […]

Development Django

Querying datetime object in django doesn’t work because of time zone

I’m facing the issue of wrong query result due to timezone issue. I’ve read several answers, but most of them suggest USE_TZ = False. But we can’t do that because of several dependencies on time zone. blog = Post.objects.filter(date_posted__year=2019, date_posted__month=11) blog[0] Post: asfd random new india safasfd adf hey blog[0].date_posted datetime.datetime(2019, 11, 26, 20, 33, […]