original_docstring: 
          Adds a wrapper around the documents pk field. The wrapper object gets
          the attributes django expects on the pk field, like name and attname.
  
          The function also adds a _get_pk_val method to the document.
          
docstring: Adds a wrapper around the documents pk field. The wrapper object gets
  the attributes django expects on the pk field, like name and attname.
  
  The function also adds a _get_pk_val method to the document.
docstring_tokens: Adds a wrapper around the documents pk field . The wrapper object gets the attributes django expects on the pk field like name and attname . The function also adds a _get_pk_val method to the document .
code: def _init_pk(self):
          """
          Adds a wrapper around the documents pk field. The wrapper object gets
          the attributes django expects on the pk field, like name and attname.
  
          The function also adds a _get_pk_val method to the document.
          """
          if 'id_field' in self._meta:
              self.pk_name = self._meta['id_field']
              pk_field = getattr(self.document, self.pk_name)
          else:
              pk_field = None
          self.pk = PkWrapper(pk_field)
  
          def _get_pk_val(obj):
              return obj.pk
          patch_document(_get_pk_val, self.document, False)  # document is a class...
  
          if pk_field is not None:
              self.pk.name = self.pk_name
              self.pk.attname = self.pk_name
          else:
              self.pk.fake = True
              # this is used in the admin and used to determine if the admin
              # needs to add a hidden pk field. It does not for embedded fields.
              # So we pretend to have an editable pk field and just ignore it otherwise
              self.pk.editable = True
code_tokens: def _init_pk ( self ) : if 'id_field' in self . _meta : self . pk_name = self . _meta [ 'id_field' ] pk_field = getattr ( self . document , self . pk_name ) else : pk_field = None self . pk = PkWrapper ( pk_field ) def _get_pk_val ( obj ) : return obj . pk patch_document ( _get_pk_val , self . document , False ) if pk_field is not None : self . pk . name = self . pk_name self . pk . attname = self . pk_name else : self . pk . fake = True self . pk . editable = True
short_docstring: Adds a wrapper around the documents pk field.
short_docstring_tokens: Adds a wrapper around the documents pk field .
comment: """
          Adds a wrapper around the documents pk field. The wrapper object gets
          the attributes django expects on the pk field, like name and attname.
  
          The function also adds a _get_pk_val method to the document.
          """$SEP$# document is a class...$SEP$# this is used in the admin and used to determine if the admin$SEP$# needs to add a hidden pk field. It does not for embedded fields.$SEP$# So we pretend to have an editable pk field and just ignore it otherwise