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
2
votes
2 answers

Sharing (mysql) database between apps Django with Database routers

I've created a django project and then two apps, app1 and app2. I want that both apps share a mysql database('nameofDB' to mysql, 'mydb' to django). I added the database to DATABASES in settings.py and for each app I created a dbrouter file, and…
voodoo14
  • 515
  • 2
  • 6
  • 10
2
votes
1 answer

Issue with django_db mark in setupclass

Morning, i'm using test inherit from django.test.TestCase and I have problems using setupclass method, because that access to db and and raise this error "Failed: Database access not allowed, use the "django_db" mark to enable", however i'm using…
Javier Vazquez
  • 117
  • 1
  • 1
  • 9
2
votes
1 answer

Referring to an object in the URL - do you use primary key or what is the best practice?

I want to refer to some instance of a data through my URL. What is the recommended way to do that? Should I use the primary key of that data or is that exposing database information unnecessarily? Even with using PKs, the URL is not 'clean'. So how…
zaphod
  • 2,045
  • 1
  • 14
  • 18
2
votes
1 answer

Is connection.cursor() thread-safe in Django 1.6?

AFAIK In Django 1.6 the cursor is shared between requests and open a new connection when needed. However I couldn't find any information about how connection.cursor() method works and how can I should use connection.cursor() method in different…
osman
  • 45
  • 4
2
votes
4 answers

Django - queryset split to 4, causes lots of hits to the database

Here is my template tag: @register.filter def split_to_4_columns(queryset): split = int(ceil(queryset.count()/4.)) columns = list() for i in range(4): columns.append(queryset[i*split:(i+1)*split]) return columns And here is…
gwaramadze
  • 4,523
  • 5
  • 30
  • 42
2
votes
1 answer

Django routing to database based on model table

I have a Django (1.6) project with two databases. I have one app with one model, and multiple tables. I want to use the database routers to set specific tables in the model to a specific database. All the documentation I have found seems to explain…
LondonAppDev
  • 8,501
  • 8
  • 60
  • 87
2
votes
0 answers

Creating a test database through the shell. Missing connection.creation.create_test_db()

The way this is supposed to be done is: from django.db import connection db = connection.creation.create_test_db() # Create the test db However, the connection i import has no methods or attributes. It's type is django.db.DefaultConnectionProxy. In…
TheMeaningfulEngineer
  • 15,679
  • 27
  • 85
  • 143
2
votes
2 answers

Monitor database requests in Django, tied to line number

We've got some really strange extraneous DB hits happening in our project. Is there any way to monitor where the requests are coming from, possibly by line number? The SQL printing middleware helps, but we've looked everywhere those kinds of…
CaptainThrowup
  • 919
  • 1
  • 7
  • 15
2
votes
1 answer

database error no such table django

I have made a new app 'api' in the django project 'cc'. I have a remote database 'launchg' which I integrated it with Django using Legacies and used python manage.py inspectdb > models.py to generate a models.py file. Next replaced the generated…
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267
2
votes
2 answers

Django lookup tables and fields

Can I look around in a database with Django? I mean outputting a list of all tables, all fields in tables and all objects in a specific table? I know how to build models and lookup objects, but can I lookup fields in a preexisting database? I have a…
Nets
  • 141
  • 8
2
votes
2 answers

Django: objects.raw() unable to fetch results despite SQL working in MySQL directly

I've written a function for Django which allows a user to enter a word or phrase, and fetch all the instances in a specified model where that instance has all those words appear in any order across a range of specified fields. I have chosen to use…
michaeljtbrooks
  • 162
  • 2
  • 11
2
votes
1 answer

Unable to get repr for

Debug show me that: comments = Comment.get_for_intention(id) is: {QuerySet} Unable to get repr for class 'django.db.models.query.QuerySet' Comment model: class Comment(models.Model): user = models.ForeignKey(User) intention =…
Codium
  • 3,200
  • 6
  • 34
  • 60
2
votes
1 answer

Issues with feeding data into database when using for loop

In my template I have used for loop for some fields

Title:

{{ form.title }}

Upload Images :

{{ form.image }}

{% for item in product…
Inforian
  • 1,716
  • 5
  • 21
  • 42
2
votes
1 answer

Avoid RETURN postgresql statment in django1.4 and postgresql 8.1 related to bug #10467

A few days ago I write a project in django1.4 using the admin capabilities with the intention to make a CRUD for debug data migrated from a legacy system to a new system (the migration wasn't entirely successful), I write it using django 1.4 and…
2
votes
2 answers

Storing User Information Django

For Users on a website, what is the best way to store information in Django with databases. The website I'm working on has the following sections: A sort of chat room where users can post comments. A set of documents that are public to other…
sinθ
  • 11,093
  • 25
  • 85
  • 121