Questions tagged [django-mysql]
92 questions
1
vote
1 answer
Deleting a django model class object without foreignkey warning
I have two tables in MySql created with django models.One is Students model, other is Attendance model.
class Attendance(BaseModel):
stu = models.ForeignKey(Students, verbose_name=_("Student"))
I did't put "on_delete=models.PROTECT" to stu in…

ivbtar
- 799
- 11
- 29
1
vote
0 answers
How to store array in mysql database using django model?
1.I have array of products and want to store it in mysql database using django model.I tried with 'ListTextField' in models.py as below,
products = ListTextField(
base_field=models.CharField(max_length=255),
size=100, # Maximum of…

Vidyashree Boragalli
- 25
- 5
1
vote
1 answer
mac django error Did you install mysqlclient or MySQL-python?
I am trying to set up a django rest project on my mac. Whenever I run python manage.py makemigrations it shows: Did you install mysqlclient or MySQL-python? error. However both of them are already installed.
Full stack trace:
(VB_env)…

Thinker
- 5,326
- 13
- 61
- 137
1
vote
1 answer
WARNING: Django_mysql.w001
I am developing an E-commerce website using Python 3.6. I made a fresh installation of Django 2.0.6 and connected it to a MySQL database (on the localhost) by defining the Database variables in settings.py as below:
DATABASES = {
'default': {
…

Bilal Mahmud
- 45
- 1
- 1
- 5
1
vote
2 answers
Django configuring different databases
I have 2 databases of interest, the basic one and the development one:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| projectsdb |
| projectsdb_dev …

kaligne
- 3,098
- 9
- 34
- 60
1
vote
1 answer
Django/MySQL: Making non-unique field unique fails even if field values are unique
I currently have this:
class Committee(models.Model):
# ...some fields...
committee_xml_id = models.IntegerField()
I need to make the field committee_xml_id unique, i.e. make it so:
class Committee(models.Model):
# ...some fields...
…

Teekin
- 12,581
- 15
- 55
- 67
1
vote
2 answers
Django - Time aggregates of DatetimeField across queryset
(using django 1.11.2, python 2.7.10, mysql 5.7.18)
If we imagine a simple model:
class Event(models.Model):
happened_datetime = DateTimeField()
value = IntegerField()
What would be the most elegant (and quickest) way to run something…

Hal
- 537
- 4
- 13
1
vote
1 answer
Mysql query in django view
I do not have much knowledge of mysql. My django model is as follows:
class Exercise_state(models.Model):
exercise = models.ForeignKey(Exercise, blank=True, null=True)
user = models.ForeignKey(User, blank=True, null=True)
…

Thinker
- 5,326
- 13
- 61
- 137
1
vote
0 answers
Django QuerySet returning multiple objects (filtered on UNIQUE key)
I am facing a very weird issue with Django ORM. I am having a below queryset which is expected to return single object (as my_unique_key is unique value), but it is returning multiple instance of the same object (check list of primary…

Moinuddin Quadri
- 46,825
- 13
- 96
- 126
1
vote
1 answer
ImportError: No module named termios with django_mysql on Windows
I'm on a 64bit Windows machine working on a Django project using PyCharm. Django 1.8.7, Python 2.7.9, MySQL 5.6. I'd like to try out django_mysql, but I get:
Unhandled exception in thread started by…

Csaba Toth
- 10,021
- 5
- 75
- 121
1
vote
0 answers
Django mysql tuple index out of range
My views.py looks like following:
@api_view(('GET',))
def save_progress_for_particular_user(request, exerciseId, rating):
#view to call stored proc that stores the progress for a particular user
…

Thinker
- 5,326
- 13
- 61
- 137
0
votes
3 answers
Django SELECT Query
Hi Iam try to select from mysql using Django
my models.py
from django.db import models
from django.db.models import Q
class Series(models.Model):
id = models.IntegerField(primary_key=True)
title = models.CharField(max_length=255)
des =…

Ghost Ghaith
- 29
- 1
- 6
0
votes
1 answer
Error when trying to delete model instance in Django 4.2.2
I've been trying to delete an existent instance from the user table (mysql) but I keep getting error from the user.delete()
this is the my viewpoint:
@api_view(['GET', 'PUT', 'DELETE'])
def user_api_id(request):
try:
id =…

usef
- 25
- 4
0
votes
1 answer
Django LIKE operation
I'm trying to send a query through Django python
I also try to block any sql injection exploits
Can someone explain to me how messaging is done
LIKE Query
for example
"SELECT * FROM admin WHERE name LIKE '%myTitle%'
It's easy to configure Query…

Ghost Ghaith
- 29
- 1
- 6
0
votes
1 answer
Redirect database call to different db url based on type of query(Read, write, update) with Django
In an existing project, how can I implement a method using which I can redirect it different database(Write, Update & read) without modifying existing Django queries?
If I have 2 queries:
MyModel.objects.get(name =…

SUP
- 349
- 1
- 2
- 11