Questions tagged [django-mysql]

92 questions
0
votes
2 answers

Django MySQL Database location and setup

So I have a MySQL database for my Django project which I think is located in the default directly (wherever that should be). When I want to move my Django project to digital ocean, how do I move that database? The my.cnf file is located inside the…
arujbansal
  • 117
  • 2
  • 12
0
votes
1 answer

Unable to delete the data from mysql table which is fetched from a form in HTML using Django

I am want to: 1. save data from a HTML form to MySQL 2. delete data from mySQL which is entered through HTML form. The save functionality is working. While there is error in delete functionality. Model.py from django.db import models # Create your…
0
votes
1 answer

Django ForeignKey from external Database

I'm working with 2 Databases, 1 external not managed by Django and the other internal. Thi is the external database now working on models and in Admin site: class Client(models.Model):# IMPORT FROM MYSQL code = models.CharField(max_length=3,…
Alex Anadon
  • 77
  • 3
  • 11
0
votes
1 answer

Creating models.UniqueConstraint in django, but the constraint is not applying

My table is defined as below. class Role(models.Model): user = models.ForeignKey( settings.AUTH_USER_MODEL, to_field="email", db_column="user", on_delete=models.CASCADE ) vertical = models.ForeignKey( …
0
votes
2 answers

How to Insert & Update Multiple Record in Django

I want to know how to deal with this task. here are the details: this is product_feature model class Feature(models.Model): has_value_choice = [ ('y', 'Yes'), ('n', 'No'), ] feature_id =…
0
votes
2 answers

Adding data to many-to-many relation in Django database

I am using django 2.2, python 3.6.8 on ubuntu 18.04 with mysql server. I have courses, student and courses_student tables. There is a many-to-many relation between courses and students. In Courses model : student = models.ManyToManyField(Student,…
ivbtar
  • 799
  • 11
  • 29
0
votes
0 answers

Setting a field as primary key in django model

I am using django 2.2 with python 3.6.8 on ubuntu 18.04. I created a model like below : @reversion.register() class Courses(BaseModel): coursecode = models.AutoField(primary_key=True, verbose_name=_("Kurs Kodu")) coursename =…
ivbtar
  • 799
  • 11
  • 29
0
votes
1 answer

Column is not being added to table Mysql using Django

The following diagram is from my database Database schema I have the following model that represents that schema: class Finalproduct (models.Model): idfinalproduct = models.AutoField(primary_key=True) idproduct =…
0
votes
1 answer

ArrayField In Django is giving error while doing migrations

I have added arrayfield to model in my application. Below is my model class employees(models.Model): firstName=models.CharField(max_length=10) lastName=models.CharField(max_length=10) tags_data = ArrayField(models.CharField(max_length=10,…
0
votes
0 answers

model overwrites another model

I have made a table "Offenses" in my database which works fine, it has a primary key named "id" Now i want to create another table with name offense_category. and want to create a foreign key that points to "id" in table "offenses" however when i…
Kiran
  • 21
  • 5
0
votes
4 answers

How do I update a table column with Django?

I'm trying to create an app with a form that when submitted, updates a table in my database based on the info submitted, but I'm not sure how to go about it. Currently, I have a simple mode: class Client(models.Model): company_name =…
dataatallured
  • 33
  • 1
  • 7
0
votes
1 answer

How to efficiently use Django query and Q to filter each object in a queryset and return 1 field value for each unique field in the queryset

I have query that returns the following queryset: results = , , , , , , ]> The __str__ representation of the model is name…
0
votes
1 answer

django.db.utils.OperationalError: (1045, u"Access denied for user 'my_user'@'localhost' (using password: NO)")

I am trying to connect to MySQL from DJango. My settings.py file: DATABASES = { 'default':{ 'ENGINE': 'django.db.backends.mysql', 'Name': 'my_db', 'User': 'my_user', 'Password':…
0
votes
1 answer

Django add new field on model if new object is created from another model

I have two models: class Exam(models.Model): name = models.CharField(max_length=100,default="test") user = models.ForeignKey(User) class UserScore(models.Model): user =…
Mido
  • 1
  • 2
0
votes
2 answers

python3 manage.py dbshell not working

I am getting the following error while executing python3 manage.py dbshell on my mac. Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line…
Powell Mittra
  • 71
  • 4
  • 15