Skip to content Skip to sidebar Skip to footer

Django ForeignKey Show Data From PostgreSQL

i have a db in PostgreSQL which is connecting 2 different tables lets call them TBL1 ( TBL1 is a table for all types ) and TBL2( TBL2 is a table for e.g. cars ), TBL1 and TBL2 have

Solution 1:

So after doing some more research , i have stumbled upon link , where it's nicely explained how you can edit the choices "inline" inside admin.py , although i was waisting time trying to add the data from model.py

class FooForm(forms.ModelForm):
class Meta:
    model = Foo

def __init__(self, *args, **kwargs):
    super(FooForm, self).__init__(*args, **kwargs)
    current_state = self.instance.state
    ...construct available_choices based on current state...
    self.fields['state'].choices = available_choices

And it worked just as i hoped to work :)

So thanks a lot guys for trying to help, i'm not python/django dev, so this all are not similar syntax to me at all :)

Best all


Post a Comment for "Django ForeignKey Show Data From PostgreSQL"