Questions tagged [django-database]

django-database refers to database backends that Django supports out of the box

refers to database backends that Django supports out of the box.

This tutorial help you to make application using mongodb database. enter link description here

664 questions
0
votes
2 answers

Set alternative pk in Django

I would like to make Django generate 6+ digits number id's for one Model. I don't want to start from zero but I want this id's to be clear and readable by users. So the good one is for example: 658975 How to do that? I've tried this: class…
Milano
  • 18,048
  • 37
  • 153
  • 353
0
votes
2 answers

NullBooleanField is always True

Please spare your valuable time and help me. The idea of my app is that each User will receive a set of the same 30 cards, and then he has to decide each card is Important or Not. I have 2 classes as follows: class Card(models.Model): …
Huy Than
  • 1,538
  • 2
  • 16
  • 31
0
votes
0 answers

how to provide False in raw SQL query

I have inherited Django code that does a migration with a raw SQL query: INSERT INTO karaage_projectmembership ( ..., is_project_supervisor, ...) SELECT DISTINCT ..., '0', ... is_project_supervisor is a boolean. The full code is on github. This…
Penguin Brian
  • 1,991
  • 14
  • 25
0
votes
1 answer

Django: Get model field data from a model field data

I have something like this in views.py. if form.is_valid(): ref_user = User.objects.get( username=form.cleaned_data['referrer']) if User.objects.filter(username=ref_user).exists(): user =…
0
votes
0 answers

Django 1.9 and model changes

Okay so I have a problem where I designed a model in django and now I need to delete the table in my DB that my model is associated with. I looked around and could not find any suitable instructions for how to do this django 1.9 so I thought I…
jdv12
  • 171
  • 4
  • 17
0
votes
2 answers

Django table with specific relation to two or more other tables

How is it possible to create a relationship like this: Imagine a restaurant. Among their datatables is one for recipes and one for ingredients. And there is another one, which contains categories of food such as dinner, lunch, breakfast, dessert,…
0
votes
0 answers

Django -- dumppdata without being able to SSH into server

I can't ssh into server because of some foolish permissions mistakes I made. Doing a clean install, but want to recover the django data. Is there a way to dumpdata without being in the server? Maybe from the admin panel?
Craig
  • 835
  • 1
  • 7
  • 21
0
votes
0 answers

Database Routers defined never call `allow_relation()`

I have 2 database routers, both with very basic logic such as: class App2Router(object): def db_for_read(self, model, **hints): if model._meta.app_label == 'app2' and model._meta.object_name == 'MyModel2': return 'db2' …
DanH
  • 5,498
  • 4
  • 49
  • 72
0
votes
2 answers

Django - MySQL : 1146 Table doesn't exist

Hello everybody this is my first post, I made a website with Django 1.8.9 and Python 3.4.4 on Windows 7. As I was using SQLite3 everything was fine. I needed to change the database to MySQL. I installed MySQL 5.6 and mysqlclient. I changed the…
pillow_willow
  • 99
  • 3
  • 11
0
votes
1 answer

Select columns from multiple tables

I have multiple tables with identical primary key fields but no other identical field. I want to select a collection of columns from all tables matching a specific primary key, something like so: SELECT T1.a, T2.b, ..., TN.z FROM T1, T2, ..., TN…
ZuLu
  • 933
  • 8
  • 17
0
votes
1 answer

using mysql and mongodb in django1.8

I am creating a django web application in which I need to use both mysql and mongodb. I have used mongoengine for this thus: mongoengine.connect("mongodb://username:password@localhost:27017/dbname") In my django/settings.py: DATABASES = { …
aras
  • 1
  • 1
0
votes
2 answers

Can I make Django perform some function when a model's field changes?

Here is my Django Model: from django.db import models import datetime class MyModel(models.Model): my_timestamp = models.DateTimeField( default=datetime.datetime( year=2016, month=10, day=3, …
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272
0
votes
1 answer

How to query over two models to filter out a reference to a model?

Suppose I have two models. class Applicant(models.Model): firstName = models.CharField(max_length=50) applicationStatus = models.CharField(max_length=15, default="Pending") and class VolInterview(models.Model): applicant =…
Roy
  • 59
  • 6
0
votes
1 answer

Django db query not behaving the same way in views.py and shell

I am trying to generate a query for which I get the expected result in django shell, but for the same query, I am getting an error that the attribute for the model does not exist. First the shell: >>> from dbaccess.models import * >>>…
Roy
  • 59
  • 6
0
votes
1 answer

How to count all ForeignKey models with exact field values in Django?

I'm not sure if it's possible or not, but I want to count all votes associated with a model with an exact vote_type attribute. Here's the model: class Link(models.Model): title = models.CharField(max_length=200) . . . class…