-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On Tue, Jan 15, 2019 at 03:04:23PM +0530, Glen D souza wrote:
> Hi,
> 
> I have two different django projects which each project having different
> model
> 
> Lets say projects to be p1 and p2
> 
> 
> Now i have to populate the data from p1 model to a model in p2 ( note p1
> and p2 models are different, i just have to use some data from p1 model to
> move to p2)
> 
> 
> Now in order to write the script i have to initialise two different django
> projects, something like
> 
> 
> os.environ.setdefault('DJANGO_SETTINGS_MODULE', "p1.settings")
> django.setup()
> 
> 
> settings.configure("p2.settings", DEBUG=True)
> django.setup()
> 
> 
> So i was wondering, is this even possible? and is there any other way

Hi Glen,

This won't work – Django uses a whole lot of global state to keep
track of all the settings, model registries, and so on.

I'd suggest an alternative approach, where you'd use a management
command to export the relevant data from one project (either just
dumpdata, or write your own, more specialized version), and then use
another management command in the other project to import the exported
data (again, either write your own custom importer, or use loaddata,
depending on whether you need to transform it in any way).

Good luck,

Michal
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJcPbANAAoJEHA7T/IPM/klSMIQALnCiWUeVCvKvjVnrk6bboYX
abN8NrPjO/rEwVzqMnxw1V5wZvJ12SgK/hQMiiaO+LKMsbx0D8PSWTlZdPRzBWOi
asXnlxKdrEy/2zT7ohW0DGdl8mwltqIdkqtbAZl4T9/+gOwUiFIdvfw1SKX/Zbrx
rTXBKb/cwixUymfRPmdX0ML4d9NTQ4JD4N2RW1OKtMrn2PpfdW9nqtiukFC16ExX
8Zbow6SQHL5m2VfR/FJIdXY2ueG7RRm6TPrrHUF6ww3NIKBx1grUHw6vcyIW3ueb
YE0dDIhK0Xcj0zxwjumxjKG/Snzlrwc2TKtOM0syf3FXdgv4IWnP0iqj6i8R9hwM
F5x+4WsFrBbd6hLlNWXGmcwa5VzdxHSI0fZzVbtQI5gfMKVyk0byWdHIBlgNhBd6
SzwkGN2AgK+++cMwwGNKpiuo27EOS/ilHD7oLBTDSXcKFJ7UU9Unp56at+2mmd82
SjZsoDnoYoeOiuJ+Z6TMfvidvKrUJsuYqqZxWwlrUPLz1zWAyyWRdAq1n1fiZh3K
i8mr/n/QD64Jaq9KNZ+CU+/65Jicxg0bAtuvUuDrBUIirua9RJ+XEFTmphCWIobj
gBt5NPoR4ZkODukFG2N8IY3xxc9qEoZynTrhIxxpxcZJIdv2PoljsTnOk9BkUCYb
l+rHw0rgU2BZJkAd7AYg
=cOhG
-----END PGP SIGNATURE-----

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20190115100357.GY8269%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to