First I'd like to say that I think the autocomplete_light package is a nice, well maintained package but I am having some issues with it as a relative novice.
I upgraded my version of autocomplete_light using 'pip install django-autocomplete-light'.
As far as I was aware this shouldn't install v2 or the dev version of the project - reading from this link.
Checking the site-packages dir in my Virtual Env I've installed the following: django_autocomplete_light-2.0.0a8-py2.7.egg-info
Is there an alternative to check the version? For example can I do something like this?
python manage.py shell
import autocomplete_light
print autocomplete_light.VERSION
(which doesn't work)
My main problem is that after the upgrade I'm seeing the following error message in my django project:
'module' object has no attribute 'get_widgets_dict'
My forms.py looks like this:
from django.db import models
from django import forms
from django.forms import ModelForm
import autocomplete_light
from vehicle_admin_ac3.models import mycar
class mycarForm(autocomplete_light.ModelForm):
year = forms.DateField(widget=forms.TextInput(attrs=
{
'id':'datepicker'
}))
class Meta:
widgets = autocomplete_light.get_widgets_dict(mycar)
model = mycar
exclude = ['owner', 'uploaded']
I looked on the documentation which mentions why you should not use widget directly anymore but I didn't see a clear explanation how to fix my problem
I decided to download and install what I thought was the latest v2 test_project using the following commands:
AUTOCOMPLETE_LIGHT_VERSION="v2"
rm -rf autocomplete_light_env/
virtualenv autocomplete_light_env
source autocomplete_light_env/bin/activate
pip install -e git+git://github.com/yourlabs/django-autocomplete-light.git@$AUTOCOMPLETE_LIGHT_VERSION#egg=autocomplete_light
cd autocomplete_light_env/src/autocomplete-light/test_project
pip install -r requirements.txt
./manage.py runserver
The example at /non_admin/widget/add/ does what I want but when I check form.py for this exmaple it uses the same approach that I used previously.
from django import forms
import autocomplete_light
from models import Widget
# in the case of this example, we could just have:
# WidgetForm = autocomplete_light.modelform_factory(Widget)
# but we'll not use this shortcut
class WidgetForm(forms.ModelForm):
class Meta:
widgets = autocomplete_light.get_widgets_dict(Widget)
model = Widget
I'm quite confused now where I need to go to fix my code or to get a simple example for what I want to do. I'd appreciate any information or guidance.