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

Allow fields to be omitted from list/detail form of resources #538

Closed
wants to merge 10 commits into from

Conversation

numan
Copy link
Contributor

@numan numan commented Jun 20, 2012

This is a pull request based on the patch by @funkybob in #526. Most of the credit should go to him. Also addresses #18. Things I added to the patch:

  • Tests for the patch
  • use_in can be a callback that is passed a bundle.
  • use_in defaults to all if it is not a callable, list, or detail

Conflicts:

	tastypie/fields.py

Pass use_in to the superclass.

Conflicts:

	tastypie/fields.py

Tests for related resources
@numan
Copy link
Contributor Author

numan commented Aug 12, 2012

I realized that this wasn't working for related fields. Fixed that in the last commit.

@travisbot
Copy link

This pull request passes (merged f929b56 into 8e8a1bb).

@@ -65,6 +71,7 @@ def __init__(self, attribute=None, default=NOT_PROVIDED, null=False, blank=False
self.readonly = readonly
self.value = None
self.unique = unique
self.use_in = use_in if use_in in ['all', 'detail', 'list'] or callable(use_in) else 'all'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like this line to be broken down more. It's difficult to read as it stands. Perhaps start with the default, then with multiple if statements to apply the options.

@toastdriven
Copy link
Contributor

Other than that piece of feedback, :shipit:

@numan
Copy link
Contributor Author

numan commented Feb 12, 2013

Fixed in SHA: fc4140c

@numan numan closed this Feb 12, 2013
@dnozay
Copy link

dnozay commented May 2, 2013

@numan, I was playing and trying out the use_in field attribute from the pull request #538 however it doesn't currently work as expected:

  • get_detail uses full_dehydrate(bundle) instead of full_dehydrate(bundle, for_list=False)
  • get_list uses full_dehydrate(bundle) instead of full_dehydrate(bundle, for_list=True)

@dnozay
Copy link

dnozay commented May 2, 2013

was fixed in pull request #841

@numan
Copy link
Contributor Author

numan commented May 2, 2013

yup. The fix should be in a new release coming out soon

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