choicefield


Set the width of items list in ChoiceBox JavaFX

社会主义新天地 提交于 2020-01-17 08:21:27
问题 I'd like to see the list of items the same width like it's title: But actual picture is: And I haven't found any styles of ChoiceBox's item list in scene builder. Is there any style to add in css file to make items list the same width and position? Current styles: ChoiceBox { -fx-min-width: 28px; -fx-min-height: 42px; -fx-font-size: 16px; -fx-background-radius: 0; -fx-background-color: #ffffff; -fx-border-width: 1px; -fx-region-background: #000000 / -fx-mark-color: #757575; -fx-border-color:

Django: Filter for get_foo_display in a Queryset

自闭症网瘾萝莉.ら 提交于 2020-01-09 19:30:08
问题 I've been trying to filter a queryset on a simple model but with no luck so far. Here is my model: class Country(models.Model): COUNTRY_CHOICES = ( ('FR', _(u'France')), ('VE', _(u'Venezuela')), ) code = models.CharField(max_length=2, choices=COUNTRY_CHOICES) def __unicode__(self): return self.get_code_display() And I would like to do something like: Country.objects.filter(get_code_display__icontains="france") Country.objects.filter(code__display__icontains="france") Country.objects.filter

Django: Filter for get_foo_display in a Queryset

北战南征 提交于 2020-01-09 19:29:41
问题 I've been trying to filter a queryset on a simple model but with no luck so far. Here is my model: class Country(models.Model): COUNTRY_CHOICES = ( ('FR', _(u'France')), ('VE', _(u'Venezuela')), ) code = models.CharField(max_length=2, choices=COUNTRY_CHOICES) def __unicode__(self): return self.get_code_display() And I would like to do something like: Country.objects.filter(get_code_display__icontains="france") Country.objects.filter(code__display__icontains="france") Country.objects.filter

How can i pass custom object to form using Django

泄露秘密 提交于 2019-12-24 07:58:06
问题 I am new to django, I created my custom user(auth_user) model. I need to create student registration form using custom user model according to my custom object I have two models Title, User like this: from django.db import models #from django.contrib.auth.models import User from django.contrib.auth import get_user_model from django.db.models.signals import post_save from django.contrib.auth.models import AbstractUser class Title(models.Model): value = models.CharField(max_length=100, null

Django ModelChoiceField using distinct values from one model attribute

不羁岁月 提交于 2019-12-22 09:31:39
问题 so I'm working on a django application where I have a model Event. Each Event has some attributes, say one of them is "hostname" (which I will use throughout as an example). I need to implement search functionality where a user can search for all events that has hostname == some_value, e.g. hostname == "myhost.foo.bar". Now, I wanted to allow the user to select among the valid options (i.e. the hostnames that actually exist in one or more event) in a combobox in the search form, so I use

Django forms choicefield automatically generated choices

拟墨画扇 提交于 2019-12-21 22:55:05
问题 I have a form (forms.Form) that automatically generates the choices for its own choicefield as such: class UserForm(forms.Form): def generate_choices(): from vn.account.models import UserProfile up = UserProfile.objects.filter(user__isnull=True) choices = [('0','--')] choices += ([(s.id ,'%s %s (%s), username: %s, email: %s' % (s.first_name, s.last_name, s.company_name, s.username, s.email)) for s in up]) return choices user = forms.ChoiceField(label=_('Select from interest form'), choices

How to get the label of a choice in a Django forms ChoiceField?

╄→гoц情女王★ 提交于 2019-12-18 10:08:20
问题 I have a ChoiceField, now how do I get the "label" when I need it? class ContactForm(forms.Form): reason = forms.ChoiceField(choices=[("feature", "A feature"), ("order", "An order")], widget=forms.RadioSelect) form.cleaned_data["reason"] would only give me "feature" or "order" or so. 回答1: This may help: reason = form.cleaned_data['reason'] reason = dict(form.fields['reason'].choices)[reason] 回答2: See the docs on Model.get_FOO_display(). So, should be something like : ContactForm.get_reason

Django ChoiceField

泪湿孤枕 提交于 2019-12-17 08:48:16
问题 I'm trying to solve following issue: I have a web page that can see only moderators. Fields displayed on this page (after user have registered): Username, First name+Last name, Email, Status, Relevance, etc. I need to display table with information of all users stored in db with this fields, but two of fields have choices, so I want to make option that moderators can choose another option and after clicking on "Update" button this fields will be updated for selected user. I can to display all

Django ChoiceField

孤街浪徒 提交于 2019-12-17 08:48:03
问题 I'm trying to solve following issue: I have a web page that can see only moderators. Fields displayed on this page (after user have registered): Username, First name+Last name, Email, Status, Relevance, etc. I need to display table with information of all users stored in db with this fields, but two of fields have choices, so I want to make option that moderators can choose another option and after clicking on "Update" button this fields will be updated for selected user. I can to display all

How to display choicefield select widget on template?

孤人 提交于 2019-12-12 04:09:42
问题 This is my view: CHOICES = (('10','10'), ('20','20'),('30','30'), ('50','50')) class Droplist (forms.Form): number = forms.ChoiceField(choices = CHOICES) def page_objects(request): if request.method == 'POST': # If the form has been submitted... form = Droplist(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass pass #pages = form.cleaned_data['value'] #return AutoPaginateNode(paginate_by=pages) # Redirect after POST else: form = Droplist() # An

工具导航Map