Fellipe,

See:
    https://docs.djangoproject.com/en/dev/topics/db/multi-db/

There are a number of ways for force use of a specific database.
You can force it per query, per table, or by any other criteria you
like.  You may need to set up a simple "database router".

--Fred
------------------------------------------------------------------------
Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------

On 7/23/13 2:52 PM, Fellipe Henrique wrote:
The problem is: when usng modelForm, it try to validate the unique key in the database, and this validation use a default database.. if I remove primary_key=True in my model, work fine, but I need to set the pk in my model, because when I try to get using: obj.get(xx) show me error...


I try every think.. and I start to think is not possible multi-db in "runtime" in django.. :(

T.·.F.·.A.·.     S+F
*Fellipe Henrique P. Soares*

/Blog: http://fhbash.wordpress.com//
/GitHub: https://github.com/fellipeh/
/Twitter: @fh_bash/


2013/7/23 Brian Millham <bmill...@gmail.com <mailto:bmill...@gmail.com>>

    I've done that with this code:

        if form.is_valid():
          f = form.save(commit = False)
          f.save(using='yourdatabase')


    Works fine for me.


    On Tuesday, July 23, 2013 1:21:29 PM UTC-4, Fellipe Henrique wrote:

        I have many database setted in my setting.py   in my
        formModel, when I try to validate the form, show me error:

        
http://stackoverflow.com/questions/17797419/modelforms-and-multiple-datasbase-error-in-form-is-valid

        The problem is.. is_valid is going to "default" database...
        how can I force to got to another database?

        Thanks.

-- 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
    <mailto:django-users%2bunsubscr...@googlegroups.com>.
    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    Visit this group at http://groups.google.com/group/django-users.
    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.
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to