Commits

Branko Vukelic committed 7461945

Renamed GetRelatedMixin to RelatedObjectMixin

This way, it's somewhat closer to Django's mixin nomenclature.

Comments (0)

Files changed (2)

 ``existing_form_name`` (``get_existing_form_name``)
     Customizes the name of the context object containing the form.
 
-GetRelatedMixin
+RelatedObjectMixin
 ===============
 
 This mixin is a generic related object pre-fetching mixin. Before resorting to
 using this mixin, let's first discuss an approach that works well without the
-overhead of ``GetRelatedMixin``, in cases where you are only fetching the
+overhead of ``RelatedObjectMixin``, in cases where you are only fetching the
 related object, but doing nothing else. Consider this URL pattern::
 
     /posts/(?P<pk>\d+)/comments
 (Yes, there is a whole comment system included in Django, so, sorry for the
 corny example.) In the above case You would normally use a list view for the
 comments. But you might also want to fetch the post object as well. There is no
-need to use ``GetRelatedMixin`` in this particular case, because you can
+need to use ``RelatedObjectMixin`` in this particular case, because you can
 combine Django's built-in ``SingleObjectMixin`` with ``ListView`` to achieve
 what you want.
 
 
 For users of the previous versions of django-related, it has to be noted that
 this mixin is simply ripped out of what used to be a monolithic
-``CreateWithRelatedMixin_``. It therefore behaves more or less the same as that
+CreateWithRelatedMixin_. It therefore behaves more or less the same as that
 mixin.
 
 Here is an example::
 
-    from related import GetRelatedMixin
+    from related import RelatedObjectMixin
     from django.views.detail import SingleObjectMixin
     from django.views import FormView
 
 
     # view for `/match/(?P<first_card_pk>\d+)/(?<second_card_pk>\d+)/`
 
-    class ViewAttachment(GetRelatedMixin, SingleObjectMixin, FormView):
+    class ViewAttachment(RelatedObjectMixin, SingleObjectMixin, FormView):
         model = Card
         related_model = Card
         pk_url_kwarg = 'first_card_pk'
         def form_valid(self, form):
             # Do something with the form, etc
 
-``GetRelatedMixin`` is currently limited to fetching only one object, just like
-``SingleObjectMixin``, and is therefore not suitable for complex nested
+``RelatedObjectMixin`` is currently limited to fetching only one object, just
+like ``SingleObjectMixin``, and is therefore not suitable for complex nested
 structures. Again, using Django's DB API would be more reasonable in many of
 those cases.
 
 resource. The main assumption is that higher levels of the path contains a slug
 or pk that points to the related model's object.
 
-As discussed in the ``GetRelatedMixin_`` section, this mixin is based on it, so
+As discussed in the RelatedObjectMixin_ section, this mixin is based on it, so
 the same customization options are available.
 
-The key difference between normal CreateView, which can be persuaded to give
+The key difference between normal CreateView (which can be persuaded to give
 you the related object using the ``queryset`` attribute and ``get_object``
-method, and this mixin, lies in the form processing. This mixin does two things
+method) and this mixin, lies in the form processing. This mixin does two things
 differently:
 
 1. It ensures that the related object exists (behavior similar to
    ``get_object`` is forced)
 2. It attaches the related object to the appropriate field in the submitted
-   object.
+   form.
 
 Here is an example::
 
         return super(GetExistingMixin, self).post(request, *args, **kwargs)
 
 
-class GetRelatedMixin(object):
+class RelatedObjectMixin(object):
     related_model = None
     related_404_redirect_url = None
     related_404_message = '%s does not exist'
         return self.related_object_name
 
     def get_context_data(self, *args, **kwargs):
-        context = super(GetRelatedMixin, self).get_context_data(*args, **kwargs)
+        context = super(RelatedObjectMixin, self).get_context_data(*args, **kwargs)
 
         related_object = self.get_related_object()
 
 
         return context
 
-class CreateWithRelatedMixin(GetRelatedMixin, object):
+class CreateWithRelatedMixin(RelatedObjectMixin, object):
     related_field = None
     integrity_error_message = 'Such record already exists'
     cache_backend = cache
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.