I found a sample contained in a rar archive with a media file included
(2 css and js) which the svn source does not have.
I changed my urls, forms and base.html to reflect that from the
example but when i reload the page it changes the default m2m field
with a text field with a plus sign next to it. If i try to add
something nothing happens.
Here's the example:
forms.py
from django import forms
from apps.spares.models import Category, Spare
from ajax_m2m_widget import AjaxMultiSelect
class MyForm(forms.Form):
spares = forms.Field(widget=AjaxMultiSelect(db_field.verbose_name,
Spare, '/spares/spare/auto/'))
categories = forms.Field(widget=AjaxMultiSelect
(db_field.verbose_name, Category, '/spares/category/auto/'))
urls.py
from django.conf.urls.defaults import *
from apps.utils.ajax_m2m_widget import auto_complete_view
from models import Spare, Category
def spare_auto_query_func(q):
return Spare.objects.filter(name__startswith=q)
def category_auto_query_func(q):
return Category.objects.filter(name__startswith=q)
urlpatterns = patterns('apps.spares.views',
(r'^spare/auto/$', auto_complete_view, {'query_func':
spare_auto_query_func, 'desc_field': 'name', 'id_field': 'id'}),
(r'^category/auto/$', auto_complete_view, {'query_func':
category_auto_query_func, 'desc_field': 'name', 'id_field': 'id'}),
last i added the fallowing to my base.html
<script src="/media/js/jquery.js"></script>
<script src="/media/js/jquery.autocomplete.js"></script>
<script src="/media/js/jquery.bgiframe.min.js"></script>
<link rel="stylesheet" href="/media/css/jquery.autocomplete.css"/>
<link rel="stylesheet" href="/media/css/ajax_m2m_widget.css"/>
thanks,
regards,
On Jun 25, 11:45 am, jhugo <[email protected]> wrote:
> I want to use this widget instead of the default one from the many to
> many field but don't know how to. Do you have an example that can get
> me started.
>
> Thanks,
>
> - Hugo
>
> On Jun 25, 11:39 am, "Gabriel ." <[email protected]> wrote:
>
> > On Thu, Jun 25, 2009 at 12:33 PM, jhugo<[email protected]> wrote:
>
> > > Hi,
>
> > > I am trying to use the ajax_m2m_widget from djangoplus but there is
> > > very little information could anyone help me?
>
> > > Thanks,
>
> > That depends of what kind of help do you need. Please be more specific.
>
> > --
> > Kind Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---