[Ncr-Python.in] Django - Loading a large default value in a model

Gora Mohanty gora at mimirtech.com
Wed Nov 21 07:57:59 CET 2012


On 21 November 2012 12:19, Nandeep Mali <n9986.mali at gmail.com> wrote:
> On Wed, Nov 21, 2012 at 12:14 PM, Gora Mohanty <gora at mimirtech.com> wrote:
> [...]
>> (a) seems fine, but aren't you over-analysing this? If the default value
>> is fixed, why not put it into a string in say, constants.py in the same
>> directory as models.py, and just import the string in models.py,
>
> I did not mention the entire use case. As I said, the said JSON string
> is properly formatted and indented. I need this portable and editable
> in the future, a schema which will evolve over time. This same JSON
> string is also being used outside the scope of the Django project.

In that case, having a file or a web service that provides the string
would make sense. Reading from a file is hardly different than
having a fixed string, IMHO. In both cases, source code version control
systems should take care of changes in the fixed string.

>                                                                                        As
> I said before, I personally find it cumbersome to dump a several
> hundred line long JSON string in a Python variable which is exactly
> not what I wanted to do.

If you are comfortable with reading it from a file, I do not really
see what distinction you are making here.

Regards,
Gora


More information about the Ncr-Python.in mailing list