Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an optional context processor that injects an 'enums' dict with all our enums #33

Closed
wants to merge 1 commit into from

Conversation

lamby
Copy link
Contributor

@lamby lamby commented May 4, 2016

Saves manually/tediously adding enum classes to view template context to check them. Invalid lookup values raise an error.

Signed-off-by: Chris Lamb chris@chris-lamb.co.uk

…ur enums

Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk>
@lamby
Copy link
Contributor Author

lamby commented Aug 25, 2018

Big user of this. Any chance of it being merged? Open since 2016 (!)

@Swamii
Copy link
Contributor

Swamii commented Sep 13, 2018

@lamby Sorry for the (very) late answer. This looks like an easy merge. If you could add tests and document it somehow (basic note in README is fine), then it's good to go.

@lamby
Copy link
Contributor Author

lamby commented Sep 13, 2018

I'm afraid I won't be able to find the bandwidth to add tests and docs soon; could it not be merged in the meantime? It does not affect the other code, after all.

@Swamii
Copy link
Contributor

Swamii commented Sep 13, 2018

It's just that if we merge it and people start using it and after a while it breaks, then we wouldn't know.

Also, this project is barely maintained. The less code, the better in that regard 😄

@lamby
Copy link
Contributor Author

lamby commented Sep 13, 2018

Aw. :(

@antonagestam
Copy link
Contributor

This looks like a cool feature, however I don't think it belongs in django-enumfield especially since django-enumfield now uses standard library Enums. This PR relies on users putting enum definitions in a submodule named "enums" which limits its usefulness. The fact that this feature doesn't need to rely on other features of django-enumfield or vice versa and its narrow scope makes it a better fit for being its own library in my opinion.

@lamby
Copy link
Contributor Author

lamby commented Jan 2, 2020 via email

@antonagestam
Copy link
Contributor

antonagestam commented Jan 7, 2020

@lamby The enum classes that django-enumfield provides inherit from standard library enum, so you wouldn't at all need to stay in-sync with django-enumfield. In fact, just replacing the import with import enum should be enough to make your code independent of this library.

is quite a small amount of code and thus a separate project seems a bit overkill

I don't agree with this sentiment, I find it much healthier for projects to do one thing and to do it well. You're asking us to support your use-case which is very specific to how you are working and not necessarily related to this project. The purpose of this library is not to implement every possible use-case of enums that relates to Django. If someone puts their enums in the same module as their models, or in a module called "enumerations" this solution doesn't work, should we support those use-cases as well then?

I think this is clearly a use-case that can stand on its own legs and shouldn't be included in this project.

@jocke-l
Copy link

jocke-l commented Jan 7, 2020

Actually, this kind of feature would (if slightly more generalized) fit in libraries like https://github.com/5monkeys/django-bananas if you want to avoid micro libraries. It does not need to be tightly coupled to django-enumfield.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants