Django Database Switching Issue

19 views
Skip to first unread message

G Z

unread,
Jul 11, 2014, 4:27:09 PM7/11/14
to django...@googlegroups.com
So I tracked down an issue, whenever I change my database from development to production which have the same exact schema 
it still uses the data from development although my settings.py file is set to the production database and it even swtiches the user I have
to log in with to the one associated with production but all of the data is development. 

I have tried running sync db and sql. Nothing seems to work I know this is a django ism but not sure how to fix it . 

Thomas Lockhart

unread,
Jul 11, 2014, 4:30:23 PM7/11/14
to django...@googlegroups.com
Django only knows what you tell it.

If the production setup is really specifying the production database
(make sure you don't have a local_settings.py overriding your
settings.py values), perhaps you should check your caching setup next?

hth

- Tom

G Z

unread,
Jul 11, 2014, 6:30:42 PM7/11/14
to django...@googlegroups.com
Thomas,

I have no cache setup, Django is all set to default right now there is no local_settings file I have actually changed every settings file that exist for django to match my production db yet still the wrong data.

Thomas Lockhart

unread,
Jul 11, 2014, 6:37:48 PM7/11/14
to django...@googlegroups.com
On 7/11/14 11:30 AM, G Z wrote:
Thomas,

I have no cache setup, Django is all set to default right now there is no local_settings file I have actually changed every settings file that exist for django to match my production db yet still the wrong data.
Well, you will have to give more details on your setup. Which database? What are the database settings? Do you have NFS involved?

I would guess that if you remove your development db you will see a different error ;)

                                  - Tom


On Friday, July 11, 2014 10:30:23 AM UTC-6, Thomas wrote:
On 7/11/14 9:27 AM, G Z wrote:
> So I tracked down an issue, whenever I change my database from
> development to production which have the same exact schema
> it still uses the data from development although my settings.py file
> is set to the production database and it even swtiches the user I have
> to log in with to the one associated with production but all of the
> data is development.
>
> I have tried running sync db and sql. Nothing seems to work I know
> this is a django ism but not sure how to fix it .
Django only knows what you tell it.

If the production setup is really specifying the production database
(make sure you don't have a local_settings.py overriding your
settings.py values), perhaps you should check your caching setup next?

hth

                            - Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/66e147de-875c-46af-be8d-1e02844f9408%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

G Z

unread,
Jul 14, 2014, 3:44:31 PM7/14/14
to django...@googlegroups.com
Thomas,

We are using an oracle database setup, we have a development database and a production database, the production database is for billing.
The databases have the sane TNS resolver name of DB1. To test that it was using the correct settings.py file  I removed the database information 
from it and it is using the settings.py file that I thought it was. However when I log into the development database and run the query im using with 
django it will return what im seeing on my django page although my django settings file is pointed to my other database and I even have to use the login associated 
with the production database, the weird part is that the data returned is still the development database. I'm running in debug mode, manage.py runserver. However the production database
right now has no write privileges only read privileges so that should not be affecting the query. I even output the exact query that im using to the webpage and run seperately in each database 
it returns the correct data when im manually logged into the production database. The app was first synced on the development database.

select customer_name, substr(decode(vcd_managed,'Y',vm_name,'N',vm_group_name || ' ' || vm_display_name),1,100) vm_name, cpu_ghz_hours,ram_gb_hours, guest_os from customers a, vm_groups b, vms c, vm_compute_usage_histories d, vm_compute_histories e, guest_os f where a.customer_id = b.customer_id and b.vm_group_id = c.vm_group_id and c.vm_id = d.vm_id and trunc(d.datetime) = to_date('01-Jun-2014', 'DD-MON-YY') and a.customer_id != 24 and inactive = 'N' and cpu_ghz_hours > 0 and e.datetime = (select max(datetime) from vm_compute_histories g where c.vm_id = g.vm_id) and e.vm_id = c.vm_id and e.guest_os_id = f.guest_os_id order by 1,2 

there is the query that im running.

when i sync the db it syncs just fine. I'm not sure how this is even possible.

G Z

unread,
Jul 14, 2014, 4:18:28 PM7/14/14
to django...@googlegroups.com
I solved it thanks for all your help though.
Reply all
Reply to author
Forward
0 new messages