Friday, April 1, 2016

Re: Redefine html properties in widget

On the server-side I use validators for controlling valid values.

But if I use TextInput, such:

'quantity': TextInput(attrs={'min': 1}),

It works fine in html source code.

Full source code you can find below:




class Foods(models.Model):




        def __str__(self):


                return self.name




        name = models.CharField(max_length=200)


        quantity = models.PositiveSmallIntegerField(default=1, validators=[


        MinValueValidator(1)])


        quandesc = models.CharField(max_length=3, choices=(('Item', 'Qty'),


        ('Kilo', 'Kg.'), ('Litr', 'L.')), default='Item')


        comment = models.TextField(blank=True)


        to_ods = models.BooleanField(default=False)


        to_email = models.BooleanField(default=False)


        foodlist = models.ManyToManyField('FoodList')


class FoodForm(ModelForm):




        class Meta:


                model = Foods


                fields = '__all__'


                widgets = {


                        'quantity': NumberInput(attrs={'min': 1}),


                        'comment': TextInput(),


                }


Can you write me simple example how I must use min. value for html form?

четверг, 31 марта 2016 г., 19:24:06 UTC+3 пользователь Tim Graham написал:
Some attributes such as IntegerField.min_value need to be customized on the field rather than the widget. This will ensure that validation is also done server-side. (see https://github.com/django/django/blob/f3595b25496691966d4ff858a3b395735ad85a6e/django/forms/fields.py#L278-L285 for example)

On Thursday, March 31, 2016 at 11:47:34 AM UTC-4, Denis Makarov wrote:
Hello!

I have my own ModelForm with widgets in Meta class.

class Meta:

 model
= Foods

 fields
= '__all__'

 widgets
= {

 
'quantity': NumberInput(attrs={'min': 1, 'max': 10, 'name': "quantity2"}),

 
'comment': TextInput(),

 
}


My quantity field have NumberInput as standard.

I want to redefine html properties such name and min value.

But when I did this (code above), my fiend quantity have old values (name and min value). Max value correct.

<p><label for="id_quantity">Quantity:</label> <input id="id_quantity" max="10" min="0" name="quantity" type="number" value="1" /></p>

Django (1.9.4)

What's wrong?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f8e0d39e-e6ab-4446-9bd5-886fdae680b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: django admin_tools et file edition

One part of the configuration can be loaded from the database and it works well. 

I have to edit some files of asterisk ipbx.
 
May be I can overload save / load methodes of djaongo model ?

Or make a "service for file " into server side of my application, à la "restful"  ?


Le jeudi 31 mars 2016 22:31:44 UTC+2, Alex Heyden a écrit :
CKEditor is appropriate for files that need solid typography and formatting. If you're looking for something simpler, Markdown is a common solution. Markdown is a markup syntax widespread on internet forums.

None of those really address "configuration files," though. Is fancy formatting actually the problem you're trying to solve? Are you trying to find a way to save and edit files on a hard drive? Save text to a database to affect the behavior of your website? Something else?

On Thu, Mar 31, 2016 at 11:51 AM, vassilux <v.gont...@gmail.com> wrote:
Hi alls,
It is my first django project and   I look for a solution to edit files, for exemple allow to an "advanced user" editing configuration files.


I looked into django-ckeditor  but it is not clear for the moment

Where  I can look for informations / examples ?


Thanks





--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5d9fda07-2a03-4fe9-8046-e853fd616943%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/19ca0367-da06-496b-adb6-2a2a07c5efa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.