Jesús

Where is your data right now?

If you can put it into a separate database - or even a spreadsheet - it can be automatically reloaded at any time.

There are two ways to do this. One is a data migration ...

https://docs.djangoproject.com/en/1.11/ref/migration-operations/#runpython

... and the other is a custom manage.py command ...

https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/#module-django.core.management

In either case you write a function which uses Django's everyday tools to insert data. If your data is in a flat file you can read it line by line and extract the data you want, format it the way you want, run it through any checks or tests you want then if it doesn't already exist insert it.

I first used data migrations to insert reference data and worked out a way to live with it. In effect, I had to insert 'return None' at a strategic spot to prevent it running a second time.

Then I had a very complex data import with lots of m2m data represented in a flat Excel spreadsheet and that was too ugly for a data migration so I put in some study time and eventually built a manage.py command.

However, a possible third way might be found here ...

https://djangopackages.org/grids/g/countries/

I haven't used any so I can't tell you much.

Good luck

Mike


On 7/12/2018 5:28 AM, Informatico de Neurodesarrollo wrote:

Saludos Gerson:

Es real, trabajo en salud y estoy trabajando en un sistema para el control de medicamentos y necesito tener ya en la base de datos las provincias, sus municipios, áreas de salud, medicamentos controlados, etc. con los que voy a trabajar y cuando lo termine será puesto es todas las farmacias del municipio donde trabajo (Cárdenas,Matanzas,Cuba). como decía, estoy comenzando en Django y quiero hacerlo porque deseo trabajar sobre software libre y trabajo con linux desde el 2004 (más orientado a servidores).

In english:

I am working in Cuban's  system health  care and I am began work on  a web app apply to a medicine's control and I need put into the database to go ahead on my app, some data like all province, each municipals  regions, cities and other information (at time to deploy my app in production site, I save time and work to introduce a lot of data time after time ).

PD Apologist my english and I answered to Gerson's email address.
PD Disculpen  respondí al correo de Gerson, no a la lista.

El 04/12/18 a las 12:51, Gerson David Vizquel Alemán escribió:
Hola Jesus, la información que requieres cargar inicialmente en la base de datos es información fake o real?

El martes, 4 de diciembre de 2018, 13:09:04 (UTC-4), Informatico de Neurodesarrollo escribió:

    Hello:

    I am a beginner on Django. I wish develop a web app with Django
    2.1.3
    and Postgres.

    I have to create my project and later, make migrations on my data
    base,
    but I need introduce some data previously into my database like all
    provinces and other a lot of information's, which don't want
    introduce
    a lot of data that I want put into them without insert one and
    other time.

      Any one can help me

--
    Ing. Jesús Reyes Piedra
    Admin Red Neurodesarrollo,Cárdenas
    La caja decía:"Requiere windows 95 o superior"...
    Entonces instalé LINUX.


-- Este mensaje le ha llegado mediante el servicio de correo
    electronico que ofrece Infomed para respaldar el cumplimiento de
    las misiones del Sistema Nacional de Salud. La persona que envia
    este correo asume el compromiso de usar el servicio a tales fines
    y cumplir con las regulaciones establecidas

    Infomed: http://www.sld.cu/

--
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+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/982e6114-a6ea-423c-938c-8865d0652fdd%40googlegroups.com <https://groups.google.com/d/msgid/django-users/982e6114-a6ea-423c-938c-8865d0652fdd%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--

Ing. Jesús Reyes Piedra
Admin Red Neurodesarrollo,Cárdenas
La caja decía:"Requiere windows 95 o superior"...
Entonces instalé LINUX.
--
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+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto: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/bab14959-46fd-9702-6d10-715794bf9c01%40infomed.sld.cu <https://groups.google.com/d/msgid/django-users/bab14959-46fd-9702-6d10-715794bf9c01%40infomed.sld.cu?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
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/2ffb8840-8c59-8ba6-45a6-2034f24e7fba%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to