Skip to content

Error at CustomLocation class #58

Description

@DrMartiner

Trace log:

  File "/path/.virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 223, in get_response
    response = middleware_method(request, response)
  File "/path/.virtualenv/lib/python2.7/site-packages/django_geoip/middleware.py", line 24, in process_response
    storage = storage_class(request=request, response=response)
  File "/path/.virtualenv/lib/python2.7/site-packages/django_geoip/storage.py", line 16, in __init__
    self.location_model = get_class(settings.GEOIP_LOCATION_MODEL)
  File "/path/.virtualenv/lib/python2.7/site-packages/django_geoip/utils.py", line 10, in get_class
    cls = getattr(__import__(mod_name, {}, {}, ['']), class_name)
  File "/path/src/apps/city/models.py", line 37, in <module>
    class CustomLocation(GeoLocationFacade):
  File "/path/.virtualenv/lib/python2.7/abc.py", line 87, in __new__
    cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
  File "/path/.virtualenv/lib/python2.7/site-packages/django/db/models/base.py", line 309, in __new__
    new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
  File "/path/.virtualenv/lib/python2.7/site-packages/django/apps/registry.py", line 221, in register_model
    (model_name, app_label, app_models[model_name], model))
RuntimeError: Conflicting 'customlocation' models in application 'city': <class 'apps.city.models.CustomLocation'> and <class 'city.models.CustomLocation'>.

CustomLocation class:

class CustomLocation(GeoLocationFacade):
    name = models.CharField(max_length=100)
    is_default = models.BooleanField(default=False)

    def __unicode__(self):
        return self.name

    @classmethod
    def get_by_ip_range(cls, ip_range):
        return ip_range

    @classmethod
    def get_default_location(cls):
        return cls.objects.get(is_default=True)

    @classmethod
    def get_available_locations(cls):
        return cls.objects.all()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions