Any help?

2011/8/2 H.İbrahim Yılmaz <prehisto...@gmail.com>

> Any help pls?
>
> 2011/8/2 Dr.Linux <prehisto...@gmail.com>
>
> Hi all,
>>
>> I'm so sorry for this e-mail. May be you answered similar questions
>> many times. But I really need your help to learn how it's works.
>>
>> There is a little problem with third-level(?) models (or many times
>> related models) in admin area with django-smart-selects plugin. I
>> don't know what does matter :)
>>
>> This my colors model
>>
>> from django.db import models
>>
>> class Colors(models.Model):
>>   color_name = models.CharField(max_length=50
>> )
>>
>>    def __unicode__(self):
>>        return self.color_name
>>
>> This my Cars models
>>
>> from django.db import models
>>
>> class Cars(models.Model):
>>    car_model = models.CharField(max_length=50
>> )
>>    car_colors = models.ManytoManyField(Colors, related_name='Car
>> Colors')
>>
>>    def __unicode__(self):
>>        return self.car_model
>> O.K. Let's see my CarsData Model.
>>
>> This my CarsData models
>>
>> from django.db import models
>>
>> class CarsData(models.Model):
>>    car_barcode= models.CharField(max_length=5
>> 0)
>>    available_color = ChainedForeignKey(
>>                   Cars,
>>                   chained_field="car_model",
>>                   chained_model_field="car_colors",
>>                   show_all=False,
>>                   auto_choose=True
>>                 )
>>
>>    def __unicode__(self):
>>        return self.car_barcode
>> My admin.py looks like that:
>>
>> from django.contrib import admin
>> from django import forms
>> from myapp.models import *
>>
>> class CarsDataAdminForm(forms.ModelForm):
>>
>>    class Meta:
>>        model = CarsData
>>    def __init__(self, *arg, **kwargs):
>>        super(CarsDataAdminForm, self).__init__(*arg, **kwargs)
>>        self.fields['available_color'].choices =
>> [(csc.id,csc.car_colors) for csc in Cars.objects.all()]
>>
>> class CarsDataAdmin(admin.ModelAdmin):
>>    form = CarsDataAdminForm
>>
>> admin.site.register(CarsData,CarsDataAdmin)
>>
>>
>> Is there anyway to show in the ChoiceField 'just' color_name field
>> datas? I see just car_model because i have to set it :
>>
>> def __unicode__(self):
>>    return self.car_model
>>
>>
>> Can you please give me an example?
>>
>> Many thanks!
>
>
>
>
> --
> http://www.arkeoloji.web.tr
>



-- 
http://www.arkeoloji.web.tr

-- 
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.

Reply via email to