Hi Dp,

Basically, you'll have to:

1. Add the command; the documentation explains quite well how to make a new
command:
https://docs.djangoproject.com/en/2.0/howto/custom-management-commands/

2. In that command, you'll have to read a directory. That's pure python and
you could use something like walk
https://docs.python.org/3/library/os.html?highlight=os#os.walk, although
there are other commands. Check the `os` and `os.path` modules.

3. Reading a JSON is easy peasy with the JSON module:
https://docs.python.org/3/library/json.html?highlight=json#module-json

4. And to add the values in PostgreSQL, you'll need to have your model
defined (https://docs.djangoproject.com/en/2.0/topics/db/models/) and, with
that, you just create records and `.save()` them.



On Fri, Jul 20, 2018 at 1:24 AM, dp Audiovisual <dgp...@gmail.com> wrote:

> Hello, I need to create a "custom command" that uploads all the Json files
> of a folder within the project to the postgres database. Help, I'm learning.
>
> --
> 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/6f2c4d6a-8f05-44b9-967c-c3fe0f7f5e72%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/6f2c4d6a-8f05-44b9-967c-c3fe0f7f5e72%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Julio Biason*, Sofware Engineer
*AZION*  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101 <callto:+555130838101>  |  Mobile: +55 51
<callto:+5551996209291>*99907 0554*

-- 
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/CAEM7gE1AOY8KLi7sNSWtc0h_n3547uHrUkRCGBx0eVsiv2Ke2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to