On Sat, Jul 4, 2009 at 2:42 PM, Carlos Eduardo Sotelo Pinto < csot...@aqpglug.org.pe> wrote:
> > Hi people... I have this traceback error and i am something lost, thanks > > Environment: > Request Method: GET > Request URL: http://127.0.0.1:8000/support/helping/product/1/1 > Django Version: 1.0.2 final > Python Version: 2.5.2 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.admin', > 'django.contrib.webdesign', > 'jaamsa.app.support'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware') > > > Traceback: > File "/var/lib/python-support/python2.5/django/core/handlers/base.py" > in get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "/mnt/devel/djprojects/jaamsa/../jaamsa/app/support/views.py" in > product > 52. pmform = ProductModelForm(maker_filter=maker_id, > data=None, instance=ProductModel) > File "/mnt/devel/djprojects/jaamsa/../jaamsa/app/support/forms.py" in > __init__ > 54. super(ProductModelForm, self).__init__(*args, **kwargs) > File "/var/lib/python-support/python2.5/django/forms/models.py" in __init__ > 216. object_data = model_to_dict(instance, opts.fields, > opts.exclude) > File "/var/lib/python-support/python2.5/django/forms/models.py" in > model_to_dict > 138. data[f.name] = f.value_from_object(instance) > File > "/var/lib/python-support/python2.5/django/db/models/fields/__init__.py" > in value_from_object > 332. return getattr(obj, self.attname) > > Exception Type: AttributeError at /support/helping/product/1/1 > Exception Value: type object 'ProductModel' has no attribute 'id' > > > > #----model > class ProductModel (models.Model): > maker = models.ForeignKey(Maker) > product_type = models.ForeignKey(ProductType) > name = models.CharField(u'Modelo', max_length=32) > created = models.DateTimeField(u'Creado', auto_now_add=True) > modified = models.DateTimeField(u'Modificado', auto_now=True) > def __unicode__(self): > return self.name > > #---- form > class ProductModelForm(forms.ModelForm): > product_model = forms.ModelChoiceField(ProductModel.objects.all(), > None, u'Modelo') > class Meta: > model = ProductModel > exclude = ['maker', 'product_type'] > def __init__(self, maker_filter, *args, **kwargs): > self.base_fields['product_model'].query = > ProductModel.objects.all().filter(maker=maker_filter) > self.base_fields['product_model'].widget.choices = > self.base_fields['product_model'].choices > super(ProductModelForm, self).__init__(*args, **kwargs) > > #---- view > def product(request, maker_id, product_type_id): > if request.method == 'POST': > pmform = ProductModelForm(request.POST) > if mform.is_valid(): > maker = topic = mform.cleaned_data['maker'] > path = '/support/helping/product/%s' % maker > return HttpResponseRedirect(path) > else: > pmform = ProductModelForm(maker_filter=maker_id, data=None, > instance=ProductModel) > return render_to_response('helping.html', {'mform': pmform}) > > > -- > Carlos Eduardo Sotelo Pinto a.k.a. krlos > GNULinux RU #379182 || GNULinux RM #277661 > GNULinux Arequipa Users Group || Debian Arequipa Users Group > -- > http://krlosaqp.blogspot.com > pgp.rediris.es 0xF8554F6B > GPG FP:697E FAB8 8E83 1D60 BBFB 2264 9E3D 5761 F855 4F6B > > > > You're passing the class MyModel, instead of either an instance of MyModel (MyModel()) or None. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---