django smart-select

492 views
Skip to first unread message

Dr.Linux

unread,
Aug 2, 2011, 3:53:09 AM8/2/11
to Django users
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!

H.İbrahim Yılmaz

unread,
Aug 2, 2011, 7:43:42 AM8/2/11
to Django users
Any help pls?

2011/8/2 Dr.Linux <prehi...@gmail.com>



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

H.İbrahim Yılmaz

unread,
Aug 4, 2011, 4:23:55 AM8/4/11
to Django users
Any help?

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



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

Tom Evans

unread,
Aug 4, 2011, 9:41:24 AM8/4/11
to django...@googlegroups.com
On Thu, Aug 4, 2011 at 9:23 AM, H.İbrahim Yılmaz <prehi...@gmail.com> wrote:
> Any help?
>

The question/what is wrong is unclear.

I would have thought the number of people using this particular
package is probably not high enough to be randomly answered on a
django mailing list. Have you tried contacting the author for support?

Cheers

Tom

H.İbrahim Yılmaz

unread,
Aug 4, 2011, 6:20:30 PM8/4/11
to django...@googlegroups.com
I tried many times. No answered what is the unclear? i cant understand... What didn't you understand?

2011/8/4 Tom Evans <tevans.uk@googlemail.com>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




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

H.İbrahim Yılmaz

unread,
Aug 4, 2011, 6:32:07 PM8/4/11
to django...@googlegroups.com
O.K. just a simple question:

How can i chain available_color field to color_name field?

Cheers...

2011/8/5 H.İbrahim Yılmaz <prehi...@gmail.com>

YusufSalahAdDin

unread,
Feb 9, 2015, 1:00:36 AM2/9/15
to django...@googlegroups.com, prehi...@gmail.com
I have the same question, Did you solve it?
Reply all
Reply to author
Forward
0 new messages