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

Error at CustomLocation class #58

Open
DrMartiner opened this issue Sep 16, 2015 · 1 comment
Open

Error at CustomLocation class #58

DrMartiner opened this issue Sep 16, 2015 · 1 comment

Comments

@DrMartiner
Copy link

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()
@coagulant
Copy link
Member

RuntimeError: Conflicting 'customlocation' models in application 'city': <class 'apps.city.models.CustomLocation'> and <class 'city.models.CustomLocation'>.

Looks like you're importing CustomLocation from different places in sys.path.

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

No branches or pull requests

2 participants