Depending on what you're trying to do, I think you should be able to configure 
two separate databases in your settings file - one for the auth app (user 
tables, etc.) and one for your existing database.  Then use a database router 
to point each app to the right one.  This way the additional tables will not be 
added to your legacy database.

It seems easiest to use the 'default' database for auth and then route your 
models/app to the other database - e.g. 'legacy' or whatever.  It's been a 
while since I configured something like this so I might be missing something, 
but hopefully this helps...


<in settings.py>

DATABASES = {
   # legacy application
   'legacy': {
       'ENGINE': 'django.db.backends.postgresql_psycopg2', # db engine for 
postgres
       'NAME': 'legacy',                                   # database name in 
postgres
       'USER': 'postgres',                                 # username to access 
postgres db
       'PASSWORD': '********',                             # password to access 
postgres db
       'HOST': '10.10.10.10',                              # address of 
linquest vm3
       'PORT': '5432',                                     # default postgres 
port
   },

   # default database router maps objects from all other apps (e.g. auth, 
admin) to the
   # 'default' database
   'default': {
       'ENGINE': 'django.db.backends.postgresql_psycopg2', # db engine for 
postgres
       'NAME': 'users',                                    # database name in 
postgres
       'USER': 'postgres',                                 # username to access 
postgres db
       'PASSWORD': '********',                             # password to access 
postgres db
       'HOST': '10.10.10.10',                              # address of 
linquest vm3
       'PORT': '5432',                                     # default postgres 
port
   }

}

DATABASE_ROUTERS = ['mysite.db_routers.LegacyRouter']




<in db_routers.py>

class LegacyRouter(object):
   """ Router that directs all database operations on models in the 'legacy'
   application to the 'legacy' database """

   def db_for_read(self, model, **hints):
       if model._meta.app_label == 'legacy':
           return 'legacy'
       return None 

   def db_for_write(self, model, **hints):
       if model._meta.app_label == 'legacy':
           return 'legacy'
       return None 

   def allow_relation(self, obj1, obj2, **hints):
       if obj1._meta.app_label == 'legacy' or obj2._meta.app_label == 'legacy':
           return True
       return None

   def allow_syncdb(self, db, model):
       if db == 'legacy':
           return model._meta.app_label == 'legacy'
       elif model._meta.app_label == 'legacy':
           return False
       return None     





On Apr 4, 2013, at 12:38 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> I believe that additional tables are required to run Django, such as session 
> and user tables, stuff to do with permissions, stuff to do with content 
> types.  Maybe you can avoid these by not including the core applications in 
> INSTALLED_APPS, but then you couldn't log in to or be designated an superuser 
> to see the admin.  I don't know that code deeply enough to suggest a work 
> around.
> 
> 
> On Thu, Apr 4, 2013 at 2:22 PM, Giorgos Kontogiorgakis 
> <shortgeorge...@yahoo.com> wrote:
> So,after i run the inspectdb i have a model.py file generated that creates 
> models by introspecting my existing database,right?After that thing i must 
> create an app and place the models.py that generated after running inspectdb 
> in there and then add the app to my INSTALLED_APPS setting and run the python 
> manage.py syncdb last?
> With this way will i be able to see the tables of my database on my webui and 
> NOT creating additional tables,right?Or i am wrong!?Please help me!
> 
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to