with a Foreign Key field, one-to-many relationship:

https://docs.djangoproject.com/en/3.0/topics/db/examples/many_to_one/

Antje

On 4/16/20 6:52 AM, shreehari Vaasistha L wrote:
> how can i use model x values as choices for model y ?
>
> for eg:
> |
> classcountries(models.Model):
>  country =models.CharField(max_length=200)
>
>  def__str__(self):
>  returnself.country
>
> classUser(AbstractUser):
>  """User model."""
>
>  username =None
>  full_name =models.CharField(_("Full
> Name"),max_length=50,default="Full Name")
>  country_choices =models.CharField(choices=countries
> |
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/683251c6-27ab-4454-90d6-532fdcc749ce%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/683251c6-27ab-4454-90d6-532fdcc749ce%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6aeed6e-de34-f8f6-ce26-31151d4dee83%40gmail.com.

Reply via email to