paulocheque / django-dynamic-fixture

A complete library to create dynamic model instances for testing purposes.
http://django-dynamic-fixture.readthedocs.io/
Other
391 stars 67 forks source link

Sequencial-Unique #3

Closed zvictor closed 12 years ago

zvictor commented 12 years ago

avoid uniqueness issues among models, like conflicting slug/alias

paulocheque commented 12 years ago

Hi ZVictor, thanks for your report.

I am not sure if I understand this issue. Could you please send an example to reproduce the error?

Thanks!

zvictor commented 12 years ago

Imagine github account system, or something like that, where we have User and Organization, that are different models, but share the same name limitations.

In this described situation, if we tried something like that

G(User)
G(Organization)

both would have the same conflicting name/alias/slug (1, 2, 3...), and, according to github policies, It couldn't accept. So, in such cases, I guess, the best solution is to generate GLOBAL keys, where User would use key 1, followed by Organization using key 2, and so on...

I decided to share this solution because is very simple to implement and can help whose is having this problem.

paulocheque commented 12 years ago

Oh, now I see, thanks for your explanation.

It is possible to deal with it teaching DDF how to build a model instance, using Shelve: https://github.com/paulocheque/django-dynamic-fixture/wiki/Documentation

Nevertheless, you build a simple solution that works too! Thanks for your pull request. I am just thinking to rename this fixture to GlobalSequentialDataFixture instead of SequentialUniqueDataFixture. What do you think?

zvictor commented 12 years ago

Feel free to set the name. I am not an english native speaker, so I do not have a trustable opinion for this.

I hadn't noticed Shelve. It seems great, and you are creating a really good tool for developers community. Thanks for your work.