<commit_before>from django.contrib.gis.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _

HAS_GEOGRAPHY = False
try:
    # You need Django 1.2 and PostGIS > 1.5
    # http://code.djangoproject.com/wiki/GeoDjango1.2#PostGISGeographySupport 
    from django.db.connection.ops import geography
    if geography:
        HAS_GEOGRAPHY = True
except ImportError:
    pass
    
def field_kwargs(verbose_name):
    """
    Build kwargs for field based on the availability of geography fields
    """
    kwargs = {
        'blank': True,
        'null': True,
        'verbose_name': _(verbose_name),
    }
    if HAS_GEOGRAPHY:
        kwargs['geography'] = True
    return kwargs

class GeotagManager(models.GeoManager):
    def get_for_object(self, obj):<commit_msg>Fixed testing for geography fields<commit_after>from django.contrib.gis.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
from django.db import connection

HAS_GEOGRAPHY = False
try:
    # You need Django 1.2 and PostGIS > 1.5
    # http://code.djangoproject.com/wiki/GeoDjango1.2#PostGISGeographySupport 
    if connection.ops.geography:
        HAS_GEOGRAPHY = True
except ValueError:
    pass
    
def field_kwargs(verbose_name):
    """
    Build kwargs for field based on the availability of geography fields
    """
    kwargs = {
        'blank': True,
        'null': True,
        'verbose_name': _(verbose_name),
    }
    if HAS_GEOGRAPHY:
        kwargs['geography'] = True
    return kwargs

class GeotagManager(models.GeoManager):
    def get_for_object(self, obj):
{'fraction_non_alphanumeric': 0.08067050811943426, 'fraction_numerical': 0.006286013619696176, 'mean_word_length': 3.5368171021377672, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3057910', 'n_tokens_mistral': 595, 'n_tokens_neox': 574, 'n_words': 151}