Re: ForeignKey as dropdown list, get user's choice
First you say that the field "is being rendered on the template as dropdown list", and then "it's not rendered as a classic html select" How is it rendered? Isn't html select a drop-down list? By the way models.ForeignKey is a model field, not a form field. How is your form defined? 2012/7/24 mapapage: > Hello! > I have a form including a field: veh_id1 = models.ForeignKey(Vehicles)) that > is being rendered on the template as dropdown list. > Now I want according to the user's choice in that list some other fields of > my form to be auto-completed and displayed on the template before the form > submission. > I guess that I should use ajax for that. But I really don't know how I will > access that user's choice in veh_id1 since it's not rendered as a classic > html select and I don't have id for each choice etc. Sry if my question is > dump but I'm new to all that and now I'm stuck. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/F6XpJXQ70UoJ. > 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. -- 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.
Re: Can't access members in a template
Note, that u1 is not a model instance, but a QuerySet object To get a model you should call manager's "get" method rather than "filter" replace: u1 = User.objects.filter(id=u) with: u1 = User.objects.get(id=u) 2012/7/23 twelve_o_clock: > I tried that and it still did not work. Also, {{u}} and {{i}} without spaces > works, but it doesn't work when I try to access the member of something like > {{ u.name }}. > > On Monday, July 23, 2012 9:14:24 AM UTC-7, Kurtis wrote: >> >> Try: {{ u.name }} (with spaces) >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/8Xvau8WcTm8J. > > 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. -- 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.
Re: Models, field like a list
Hi, If you want to retrieve list of related models with one to many relation, you can do it with related manager, without adding a field to model A. So, if you have model B like this: class B(models.Model): a = models.ForeignKey(A) you can get related B objects like this: a_instance.b_set.all() But if you want to have an array field in your model (so that array data will be stored in the same table that stores model data), your db backend must support it and you must extend Django to support this functionality. That's probably not what you want. 2012/3/19 Xavier Pegenaute: > Hi, > > I was thinking to use a field like a list [] of another object. But I have > no a clear idea which field type should I use. Any idea? > > Ex: > class A: > bClasses = models.() # list of Foreign keys from B > > > I am not looking for a ManyToMany Field. > > Thanks, > Xavi > > -- > 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. > -- 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.
Change language prefix of current page in template
Hi. In my project i use i18n_patterns to prepend language code to every url. There are two languages available: en, ru. I want to create a link on every page to the same page but in different language. For example, there should be link to /ru/spam/eggs/ from /en/spam/eggs/. In other words, I need to change the language prefix of current request path in a template. Can it be done with url template tag? I found an example in the docs, that shows how to make urls to a particular view in all available languages, but i don't know what the path to view is, because i'm placing this link in a base template. -- 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.