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

Django multiple dbs - admin search results using a read-only db

I'm using the admin search_fields functionality. The problem: some of my tables are very big. So search is taking forever, and adding extra load on my production database. As I'm having a follower of my production db, I though a good idea would be…
lajarre
  • 4,910
  • 6
  • 42
  • 69
3
votes
1 answer

Django different model manager on foreign key

I have model User. There are two managers, UserManager that filters query set by is_active, and AllUserManager. Default manager is set to be UserManager. User has foreign key to another model, named Address, having related_name='users'. Problem is…
EnterSB
  • 984
  • 2
  • 10
  • 27
3
votes
1 answer

Django 1.2 : Multiple database and Generic Content Types

I am working on one project with django 1.2. I have 2 databases : - First, for users, user's profile, session ... - Second is to store data from my specifics models like post of blog, pictures, files ... I made a router (dbrouter.py) to manage…
Julien
  • 35
  • 5
3
votes
0 answers

Django testing - use separate database for TransactionTestCase

I need to test Django application behavior for concurrent requests. I need to test is database data correct after that. As a cnclusion, I need to test and transactions mechanism. So let's use TransactionTestCase for that. I spawned requests to…
skybobbi
  • 1,486
  • 2
  • 10
  • 7
3
votes
3 answers

django 1.5 select_for_update considered fragile design

The Django documentation states If you were relying on “automatic transactions” to provide locking between select_for_update() and a subsequent write operation — an extremely fragile design, but nonetheless possible — you must wrap the …
Trent
  • 2,328
  • 3
  • 33
  • 51
3
votes
1 answer

Data synchronization issue with Django

I have the following models.py: class BagOfApples(models.Model): quantity = models.PositiveSmallIntegerField(default = 0) Let's create a “bag of apples” object and put an “apple” in it: >>> from myapp import models >>> >>>…
alexpirine
  • 3,023
  • 1
  • 26
  • 41
3
votes
1 answer

Django, nginx and uWSGI caching results until uWSGI/MySQL restart

I've written a server app in Django and serve an API to a mobile app with Tastypie and serving the DB with a local MySQL server. It seems like queries are cached until the process is killed or ended. If I create a new user in the backend it will…
mbogh
  • 1,361
  • 11
  • 28
3
votes
2 answers

Django Unique Bulk Inserts

I need to be able to quickly bulk insert large amounts of records quickly, while still ensuring uniqueness in the database. The new records to be inserted have already been parsed, and are unique. I'm hoping there is a way to enforce uniqueness at…
NickCSE
  • 305
  • 1
  • 4
  • 14
3
votes
1 answer

Relational Database for genetic variation

I am trying to represent to genetic variation data in a database for my institution. We have discovered genetic variants, which have associated with them reference alleles, mutant alleles, chromosome, position, name, possible effect, gene, position…
Davy Kavanagh
  • 4,809
  • 9
  • 35
  • 50
2
votes
3 answers

nested @commit_on_success in @commit_manually

I use the following utility function in several scripts: @transaction.commit_on_success def save_something(arg): # creation of a model_instance using arg model_instance.save() In one of the scripts I upload lots of these model isntances to…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
2
votes
2 answers

django filter and exclude effect on performance?

I read filter and exclude from django documentation but I want to know that if I will use following code: Entry.objects.filter( ... headline__startswith='What' ... ).exclude( ... pub_date__gte=datetime.now() ... ).filter( ... …
Hafiz
  • 4,187
  • 12
  • 58
  • 111
2
votes
3 answers

model.AutoField - form.save() creates new records (INSERT) instead of updating existing

Situation: Have an existing mysql database with some data. For this example, I only use two fields; id and subject. id is defined as Integer with the *auto_increment* option, while subject is just a normal varchar. The code: Model: class…
Eigir
  • 1,969
  • 2
  • 14
  • 19
2
votes
2 answers

Django Get Last Object for each Value in List

I have a model called Purchase, with two fields, User and amount_spent. This is models.py: class Purchase(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) amount_spent = models.IntegerField() created_at =…
Stack
  • 1,028
  • 2
  • 10
  • 31
2
votes
1 answer

Django converting isoformat string datetime to tuple and rising error

I'm trying to update two datetimefields for the Skill entity in my db. I'm sure I'm passing an isoformat datetime string. When creating instead of updating everything works fine but on the update I get: Exception Type: TypeError Exception Value:…
2
votes
1 answer

Losing microseconds when inserting date to database

I have this code snippet in a view: time_from = datetime.strptime(req.POST['time_from'], "%Y-%m-%d %H:%M:%S.%f") with connections["mssql_database"].cursor() as cursor: sql_statement = "EXEC SaveActivity @TimeFrom='%s'" % (time_from) …
xralf
  • 3,312
  • 45
  • 129
  • 200