Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6533513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:08:09+00:00 2026-05-25T10:08:09+00:00

I am using a custom Django model field to and widget to render a

  • 0

I am using a custom Django model field to and widget to render a GoogleMap widget in my admin, i also want to use South with my project to handle database migrations. However after much effort i am unable to generate a custom South rule that fits, this are my custom model and the last of the many instrospection rules that i’ve tried.

class GoogleMapMarkerField(models.CharField):
    __metaclass__ = models.SubfieldBase
    description = _('Un marcador de Google Maps')
    widget = GoogleMapMarkerWidget

    def __init__(self, center, *args, **kwargs):
        kwargs['max_length'] = 100
        kwargs['help_text'] = _('Arrastre el cursor en el mapa para seleccionar el punto')
        self.center = center

        super(GoogleMapMarkerField, self).__init__(*args, **kwargs)

    def formfield(self, **kwargs):
        defaults = {
            'center': self.center,
            'form_class':GoogleMapMarkerFormField
        }
        defaults.update(kwargs)
        return super(GoogleMapMarkerField, self).formfield(**defaults)

    def to_python(self, value):
        if isinstance(value, GoogleMapMarker):
            return value
        if isinstance(value, list):
            return GoogleMapMarker(*map(float, value))

        elif isinstance(value, basestring):
            try:
                return GoogleMapMarker(*map(float, value.split(',')))
            except ValueError:
                pass

    def get_prep_value(self, value):
        return '%f,%f' % (value.latitude, value.longitude)


add_introspection_rules([
            (
                (GoogleMapMarkerField, ),
            [],
            {
                'center': ('center', {}),
            }
            )

    ],  ["^website\.fields\.GoogleMapMarkerField"])

And this is the traceback that i’m getting

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/management/commands/schemamigration.py", line 97, in handle
    old_orm = last_migration.orm(),
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/utils.py", line 62, in method
    value = function(self)
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/migration/base.py", line 422, in orm
    return FakeORM(self.migration_class(), self.app_label())
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 46, in FakeORM
    _orm_cache[args] = _FakeORM(*args)  
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 125, in __init__
    self.models[name] = self.make_model(app_label, model_name, data)
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 321, in make_model
    field = self.eval_in_context(code, app, extra_imports)
  File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 236, in eval_in_context
    return eval(code, globals(), fake_locals)
  File "<string>", line 1, in <module>
TypeError: __init__() takes at least 2 arguments (1 given)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:08:10+00:00Added an answer on May 25, 2026 at 10:08 am

    center isn’t a keyword argument, it’s a positional argument. You shouldn’t use positional arguments with South, it doesn’t understand them. (See Custom Fields: Keyword Arguments). You could solve this by providing center with a default value( center=None would be fine) and then following the example code at the link for defining the keyword name as passed to __init__, the name as stored in the database, and a dictionary of options (may be blank, but setting the default value there too helps).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can Django admin site select entries by a custom date range, i.e. using two
I have extended Django's User Model using a custom user profile called UserExtension .
DUPLICATE: Using a Django custom model method property in order_by() I have two models;
I am using custom permissions in my Django models like this: class T21Turma(models.Model): class
I'm using a custom Django field to represent JSON encoded data: class JSONField(models.TextField): __metaclass__
I have a django admin interface and in the model listing I want a
When using custom assemblies in a visual studio project. How does one check in
Background : I am currently using custom controls within my C# project (basic controls
I am using custom row view in ListView widget. I am having getView method
I am using custom model binder in ASP.NET MVC 2 that looks like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.