address model + ajax state and city search
I google whith no success for an app to remplace django shop adress model, that could auto load states when you select a country and city when select states... preferentially world wide. Does anyone know of any? thanks, and sorry my english is a little bit rusty. Mariano DAngelo -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ed246438-8134-44a3-a854-42f0c64f4b2c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
django admin filter foregein key
What I'm trying to do is to filter a dropdown list with foregein key, with the value of a previus selected dropdown list: cat_choices = (('AMA','Amateur Mayores'),('AJ','Amateur Juveniles'),('AME','Amateur Menores'),('P','Profesional')) class category(models.Model): name = models.CharField('Categoria', max_length=30) gender = models.CharField('Sexo',choices= (('M','Masculino'),('F','Femenino')), max_length=1) type = models.CharField('Tipo',choices=cat_choices , max_length=3) class boxer (person): gender = models.CharField('Sexo',choices= (('m','Masculino'),('F','Femenino')), max_length=30) type = models.CharField('Tipo',choices=cat_choices, max_length=30) category = models.ForeignKey(category) I need to filter categories in boxer admin with the value of gender, and type choose in boxer admin I was going to do it with js but I wanted to know if the something already done... thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/GRucdgLpKsMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Inline number set incorrect
extra info the code of the autocomplete code: class BaseAutocompleteWidget(ForeignKeyRawIdWidget): widget_template = None search_path = '../foreignkey_autocomplete/' class Media: css = css_dict js = js_tuple abstract= True def label_for_value(self, value): key = self.rel.get_related_field().name obj = self.rel.to._default_manager.get(**{key: value}) return truncate_words(obj, 14) class InlineForeignKeySearchWidget(BaseAutocompleteWidget): def __init__(self, rel, search_fields, attrs=None): self.search_fields = search_fields super(InlineForeignKeySearchWidget, self).__init__(rel, attrs) def render(self, name, value, attrs=None): if attrs is None: attrs = {} opts = self.rel.to._meta app_label = opts.app_label model_name = opts.object_name.lower() related_url = '../../../%s/%s/' % (app_label, model_name) params = self.url_parameters() if params: url = '?' + ''.join(['%s=%s' % (k, v) for k, v in params.items()]) else: url = '' if not attrs.has_key('class'): attrs['class'] = 'vForeignKeyRawIdHiddenAdminField' output = [forms.TextInput.render(self, name, value, attrs)] if value: label = self.label_for_value(value) else: label = u'' context = { 'url': url, 'related_url': related_url, 'search_path': self.search_path, 'search_fields': ','.join(self.search_fields), 'model_name': model_name, 'app_label': app_label, 'label': label, 'name': name, } output.append(render_to_string(self.widget_template or ( '%s/%s/%s' % (app_label, model_name, 'inline_widget.html'), '%s/%s' % (app_label, 'inline_widget.html'), 'admin/myautocomplete/%s' % 'inline_widget.html', ), context)) output.reverse() return mark_safe(u''.join(output)) class BaseAutocompleteAdminMixin(object): related_search_fields = {} related_string_functions = {} related_search_filters = {} class Meta: abstract = True def foreignkey_autocomplete(self, request): def _restrict_queryset(queryset, search_fields): for bit in search_fields.split(','): if bit[0] == '#': key, val = bit[1:].split('=') queryset = queryset.filter(**{key: val}) return queryset query = request.GET.get('q', None) app_label = request.GET.get('app_label', None) model_name = request.GET.get('model_name', None) search_fields = request.GET.get('search_fields', None) object_pk = request.GET.get('object_pk', None) try: to_string_function = self.related_string_functions[model_name] except KeyError: to_string_function = lambda x: x.__unicode__() if search_fields and app_label and model_name and (query or object_pk): def construct_search(field_name): if field_name.startswith('^'): return "%s__istartswith" % field_name[1:] elif field_name.startswith('='): return "%s__iexact" % field_name[1:] elif field_name.startswith('@'): return "%s__search" % field_name[1:] else: return "%s__icontains" % field_name model = models.get_model(app_label, model_name) queryset = model._default_manager.all() data = '' if query: for bit in query.split(): or_queries = [] for field_name in search_fields.split(','): if field_name[0] == "#": continue or_queries.append( models.Q(**{construct_search(smart_str(field_name)): smart_str(bit)})) other_qs = QuerySet(model) other_qs.dup_select_related(queryset) other_qs = other_qs.filter(reduce(operator.or_, or_queries)) queryset = queryset & other_qs queryset = _restrict_queryset(queryset, search_fields) data = ''.join([u'%s|%s\n' % ( to_string_function(f), f.pk) for f in queryset]) elif object_pk: try: obj = queryset.get(pk=object_pk) except: pass else: data = to_string_function(obj) return HttpResponse(data) return HttpResponseNotFound() def get_help_text(self, field_name, model_name): searchable_fields =
Inline number set incorrect
Hello, I'm using https://github.com/jeremyjbowers/django-autocomplete to use inline-admin autocomplete. The problem occurs when I add another inline the name of the input doesnt have the number of the row, it have --prefix--.instead. I'm using the id to capture events with javascript, so I need each one to have the id with the row number. Any idea why its doing that? the template of the widget is: So I think the {{name}} tag is not rendering. as it seen on the picture attached. any help is welcome -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Oc0zfWsEV7MJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. <>
Dynamic choices on inlines
Hi, I'm new in django and I'm searching how to the following... I've the following models class Fighter(Person): pass class Fight_Event(models.Model): pass # INLINE MODEL class Fight(models.Model): event = models.ForeignKey(Fight_Event) fighter1 = models.ForeignKey(Fighter,related_name='fighter1') fighter2 = models.ForeignKey(Fighter,related_name='fighter2') winner = # choices fighter1 or fighter2 class Fight_Event_Fight_Inline(admin.TabularInline): model = Fight fk_name = 'event' class Fight_Event_ADMIN (ForeignKeyAutocompleteAdmin): inlines = [Fight_Event_Fight_Inline,] admin.site.register(Fight_Event,Fight_Event_ADMIN) I need to add the 2 figther selected on the admin the a third widget to select the winner I need to load with javascript, or there another way? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/X-fIV1Wa_6EJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django Admin events
Anybody nows if django support capturing events on model admin widgets. I have a field, and when the users change it I want to make a query with that value and load to another field, but I do wanna wait to save method... Is there any way besides writing my own widgets? thanks Example Field: products on change load field price from the model price_list -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/GkROi3vy-6oJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: objects tools redirect to models def
screenshot http://professional-fighters.com/images/change-list.png the is shown the object tools of tools admin, I have to put a link into the change list template to add it, but I whant that when the button is pressed it's redirected to a python function, how can I do it? On 21 ago, 23:16, Mike Dewhirst <mi...@dewhirst.com.au> wrote: > On 22/08/2011 11:56am, Mariano DAngelo wrote:> Hi I'm new in django I'm > trying to redirect a personalize object tool > > to a function on a model module > > > how can I do this becouse alll tutorial show how to redirect to a > > link > > > thanks > > I'm not sure what you are asking about. Redirection is normally done in > your urls.py or behind the scenes by the webserver itself. In python, a > module is either a directory with source code or a file such as > models.py. Models defined in models.py can have functions or methods. > You can call them using normal python syntax. > > Could you say how new you are? Have you got the tutorial working? > > Mike -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
objects tools redirect to models def
Hi I'm new in django I'm trying to redirect a personalize object tool to a function on a model module how can I do this becouse alll tutorial show how to redirect to a link thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django on cgi virtualenv
I'm trying to put my site in my hosting. I'm using awardspace: I create a virtualenv with the necesary packets but installing mysqldb I'm getting the error: Traceback (most recent call last): File "setup.py", line 15, in ? metadata, options = get_config() File "/home/www/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "/home/www/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found and trying to enter the site get: 2002, "Can't connect to local MySQL server through socket '/var/run/ mysqld/mysqld.sock' (2)") I think mysqldb need mysql-server installed o mysql-client but I don't have root access how can I do it? the url: http://www.podiodeportes.com.ar/fmahorro/apache/django.cgi/admin/ how can I install mysql-server socket for mysqldb -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.