The models.py it's like this:
class OrdenDeCompra(models.Model):
proveedor = models.ForeignKey(Ficha)
and i have some like this in my forms.py:
class OrdenDeCompraForm(forms.ModelForm):
proveedor = forms.ModelChoiceField(Ficha.objects.all(),
widget=forms.FilteringSelect())
any sugestion? regards :)
you first have to create a new file where you define your model-
stores, e.g. 'stores.py' in Django's project folder:
from myapp.models import OrdenDeCompra
from dojango.data.modelstore import *
class OrdenDeCompraStore(Store):
proveedor = StoreField()
class Meta(object):
objects = OrdenDeCompra.objects.all()
label = 'proveedor'
Now you can easily query your store within a Django view like this
('myapp/views.py'):
from stores import OrdenDeCompraStore
def compra_store(request):
store = OrdenDeCompraStore()
return HttpResponse( '{}&&\n' + store.to_json(),
mimetype='application/json' )
And of course this has to be wired up within your 'urls.py':
urlpatterns = patterns('',
url(r'^compra-store/$', 'myapp.views.compra_store', name='compra-
store'),
...
)
Pointing your browser to http://localhost:8000/compra-store now serves
a FilteringSelect-compatible JSON-file that can be wired with a
FilteringSelect within your form.
class OrdenDeCompraForm(forms.ModelForm):
provedoor = FilteringSelectStore("/compra-store")
Don't know if this FilteringSelectStore ist available within dojango
0.4.6 already, so i would recommend that you should use the version
from SVN. FilteringSelectStore is using the
dojo.data.ItemFileReadStore as default, where no server-side querying/
paging is done.
Greetings, Tobias
On Feb 24, 11:39 pm, klipstein <tobias.klipst...@googlemail.com>
wrote:
> Hi Enrique,
>
> you first have to create a new file where you define your model-
> stores, e.g. 'stores.py' in Django's project folder:
>
> from myapp.models import OrdenDeCompra
> from dojango.data.modelstore import *
>
> class OrdenDeCompraStore(Store):
> proveedor = StoreField()
>
> class Meta(object):
> objects = OrdenDeCompra.objects.all()
> label = 'proveedor'
>
> Now you can easily query your store within a Django view like this
> ('myapp/views.py'):
>
> from stores import OrdenDeCompraStore
> def compra_store(request):
> store = OrdenDeCompraStore()
> return HttpResponse( '{}&&\n' + store.to_json(),
> mimetype='application/json' )
>
> And of course this has to be wired up within your 'urls.py':
> urlpatterns = patterns('',
> url(r'^compra-store/$', 'myapp.views.compra_store', name='compra-
> store'),
> ...
> )
>
> Pointing your browser tohttp://localhost:8000/compra-storenow serves