View Full Version : extjs 4.1 and django foreign-key

24 May 2012, 10:34 PM
I wrote a Waiter app in extjs4.1 which connects to Django
In my Django waiter model there is a customer field which is a foreign-key from customer model

In Extjs 4.1 in waiter/Edit.js define somthing like this

Ext.define('WAITER.view.waiter.Edit', {
extend: 'Ext.window.Window',
alias : 'widget.waiteredit',

requires: ['Ext.form.Panel','Ext.form.field.Text'],

title : 'Edit Waiter',
layout: 'fit',
autoShow: true,
width: 280,

iconCls: 'icon-user',

initComponent: function() {
this.items = [
xtype: 'form',
padding: '5 5 0 5',
border: false,
style: 'background-color: #fff;',

fieldDefaults: {
anchor: '100%',
labelAlign: 'left',
allowBlank: false,
combineErrors: true,
msgTarget: 'side'

items: [
xtype: 'textfield',
name : 'id',
fieldLabel: 'id',

name : 'customer',
xtype: 'combo',
fieldLabel: 'customer',


and also in my store folder I define Waiters.js and Customer.js . when in Edit.js In customer fields I
define store:'Customers',

I got this error
Uncaught TypeError: Cannot call method 'on' of undefined

also I wnat to know is there any method to handle Django Foreign-key in extjs4.1

25 May 2012, 2:18 PM
Do you have stores defined in your controller?
stores : [ 'Customers' ],

Store have no knowledge of table keys. You can specify idPropery: 'id' // unique field id


26 May 2012, 2:09 AM
tnx I added store to my controller and it works now