Code Monkey home page Code Monkey logo

django-parsley's People

Contributors

akshar-raaj avatar alilozano avatar bhaskar234 avatar blueyed avatar charettes avatar dheerosaur avatar gollum23 avatar jproffitt avatar kmmbvnr avatar kyogesh avatar litchfield avatar mauricioabreu avatar nlhkabu avatar rameshugar avatar samkuehn avatar satyaakam avatar scottwoodall avatar shabda avatar treyhunner avatar tuxcanfly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-parsley's Issues

Parsley does not seem to do anything for me (django 1.6, python 3.3.2), no errors either

I'm using django-pipeline so I copied the parsley js file to my app's static folder.

I have it setup like so:

PIPELINE_JS = {
    'main': {
        'source_filenames': (
            'javascript/vendor/bootstrap-3.0.3.min.js',
            'javascript/vendor/parsley.min.js',
        ),
        'output_filename': 'javascript/main.js',
    },
}

I am also loading jquery 1.10.2 through a CDN. jquery is being loaded in the <head> of the page and the rest is being loaded at the bottom.

I'm using a model form like so:

@parsleyfy
class FooForm(ModelForm):
    class Meta:
        model = Foo

It is being set with form_class inside of a CreateView view.

I have the templates setup like so:

            <form parsley-validate method="post">{% csrf_token %}
                {% for field in form %}
                        {{ field.errors }}
                        {{ field.label_tag }} {{ field }}
                {% endfor %}
                <input type="submit" value="Add this foo"/></a>
            </form>

But when I load the page there are no parsley attributes in the html, no errors in the console and all of the static assets are reachable. What's going on?

no docs on localization

There are no docs on localization, and it's possible: download locale files , include them in html, add js:

window.ParsleyValidator.setLocale('{{ STRIPPED_LOCALE }}');

I think that documentaion is needed. Maybe locale files should be included too.

install failed in pip version > 1.4

pip install django-parsley failed when pip version > 1.4

Downloading/unpacking django-parsley
  Could not find a version that satisfies the requirement django-parsley (from versions: 0.0.2a0, 0.0.1a0)
Cleaning up...
No distributions matching the version for django-parsley

Could you update a new package in pypi ?

pip install django-parsley replaces Django 1.8.3 with 1.8

I can't have Django 1.8.3 if I have django-parsley in my requirements file. Is this as intended? If not, perhaps changing

install_requires=["Django>=1.3,<=1.8"]

to

install_requires=["Django>=1.3,<1.9"]

or

install_requires=["Django>=1.3,<=1.8.6"]  # 1.8.6 is the latest 1.8 as of now

in setup.py would work? As it is, I can't have it my requirements file which makes automated deployments annoying. There are some import security updates in 1.8.2 and 1.8.3.

Actually, I can have it in the requirements file if I move django-parsley to the top, although Django 1.8 is unnecessarily installed first.

Add support for MultiValueField

I'm trying to get parsley working with a 3-widget phone number field similar to the one shown in the MultiValueField example in the documentation.

Setting min_length and max_length of 3, 3, and 4 for each field respectively (for US phone numbers) doesn't result in data-minlength and data-maxlength being specified because parsley is only run on the top level fields (not the ones inside the multi-value field).

Support for Django 1.9

Django 1.9 is already released and trying to install Django-parsely would make it rollback to 1.8

parsley-error-message instead of django-parsley-error-message

In version 0.7 it won't show a custom error message declared like this:

from django.utils.translation import ugettext_lazy as _
...
        self.fields['num'] = forms.CharField(
            required=False, max_length=15, label=_("Kennzeichnung"),
            widget=forms.TextInput(attrs={'class': 'form-control', 'pattern': '[0-9]{15,15}',
                                          'title': _('Eine Kennzeichnung besteht nur aus Zahlen!'),
                                          # fixing django-parsley bug 'parsley-error-message' (missing data):
                                          'data-parsley-error-message':_('Eine Chipnummer besteht nur aus Zahlen!')
                                          }
                                   )
        )

Solution is to add data-parsley-error-message="message" instead of parsley-error-message="message" to the html code.

Validations not runned before save

We would like to use parsley to do client side form validation in our django admin interface. This works quite well. However, we have to click to submit button before the validations are runned. This is probably because the trigger is set to false (https://github.com/agiliq/Django-parsley/blob/master/parsley/static/parsley/js/parsley.js#L131). Is it possible to change this trigger to 'change' in some way, without modifying the static files?

Would be really great to hear from you

Can I use this to validate if one of two fields is filled in?

Hi, great module!

I was wondering if I could use this to validate client-side if one of two fields from the form were used (only one of both is required).

So let's say you can either upload a file or a provide a link, so I want to validate that only one of these two is filled.

Thanks!

Checkbox/radio button support

I'm getting duplicated error messages under the first choice when I use choice widgets like RadioSelect and CheckboxSelectMultiple. I guess this means we need to add mincheck to the final element only.

image

ImportError: No module named six

While running python manage.py shell and doing from parsley.tests.forms import TextForm, I get ImportError. So six should be added in requirements.

Create a new PyPI release

There have been a lot of changes to django-parsley since the current version on PyPI. Maybe it's time for a new release? Maybe 0.0.3 or 0.1.0?

Use pytest for tests?

The current runtests.py script does not work for Django 1.7 (or 1.8?) anymore, and while at it I've wondered what's your opinion on using pytest for tests?

Parsley version confusion data-parsley-* vs parsley-*

The docs say "If you're using parsley.js < 1.2, make sure to set the parsley_namespace Meta attribute to data"

Parsley.js 2 uses data-parsley-, it's parsley.js 1 that uses parsley-

This is extremely confusing. The doc needs to be updated ASAP.

Long decimal field

Hi,

When using a DecimalField() in form like:
amount = forms.DecimalField(max_digits=12, decimal_places=2, required=True, max_value=999999999999.99, min_value=-999999999999.99)

I get this as attributes in the input text, which doesn't work with parlseyjs:
data-parsley-max="1e+12" data-parsley-min="-1e+12"

Support for parsley remote?

Hi, thanks a lot for this amazing plugin!

What would be the best way to have custom validation based on the back end using parsley remote?

Thanks!

Custom Error on form field?

I've got a form field which parsley validates correctly but returns "this field is required." I'm attempting to return my own custom error message for this field and I have this in my Meta class in the forms.py:

    parsley_extras = {
        'category': {
            'error-message': 'Category is required.',
        },
    }

Can someone tell me what I'm doing wrong?

Unable to populate drop down dynamically

Here is my code:

forms.py

from parsley.decorators import parsleyfy

def get_state_choices():
    #return tuple of states

@parsleyfy
class NewForm(ModelForm):
    state = forms.ChoiceField(widget = forms.Select( choices = get_state_choices() ) )
    class Meta:
        model = MyModel
        fields('state',)
    def __init__(self, *args, **kwargs):
        super(NewForm, self).__init__(*args, **kwargs)
        self.fields['state'] = forms.ChoiceField(
            choices=get_state_choices() )

What I need is to populate the state field from database as a drop down. It was working fine until I put @parsleyfy decorator. Now the function which return the tuple of states is not getting called.

Parsley works but my form continues to submit

I'm using django-parsley in a lot of places on a site of mine and for whatever reason I just noticed that on one form (the rest seem to be fine) I can click submit on a blank form and parsley displays the errors as it should, but then my form continues to submit anyway. Any ideas why this may happen? I've checked all my parsley settings, etc., and it doesn't appear that I'm doing anything wrong but maybe i'm overlooking something. Here's my code:

from parsley.decorators import parsleyfy

@parsleyfy
class PostSubmitForm(forms.ModelForm):
summary = forms.CharField(max_length=10000, required=False, widget=forms.Textarea, error_messages={'max_length': 'The body of a text post can have at most 10000 characters (it has %(show_value)d).'})

def is_valid(self):
    form = super(PostSubmitForm, self).is_valid()
    return form

class Meta:
    model = Post
    fields = ('title', 'summary', 'category', 'pin', 'url')




<form data-parsley-validate action="/submit/" method="post" id="new-post" enctype="multipart/form-data">
    {% csrf_token %}
    <fieldset>
        <input type="hidden" value="{{ selected_img }}" class="selected-img-src" name="selected-img-src" size="100" />
        <div class="form-field url-field">
            <p class="url-helper">Sharing a link? Enter the URL (then hit the tab button or click out) and we'll try to return some images so you can pick one that's relevent for your post.</p>
            <label for="link-url">URL</label>
            <input type="text" name="url" value="{% if form.url.value %}{{ form.url.value }}{% endif %}" class="" id="post-url" placeholder="http://www.domain.com" />
            <div class="searching"></div>
            <div class="url-error"></div>
            <div id="images" class="review-images"></div>
        </div>
        <div class="form-field">
            <label for="id_category">Category <span class="required">*</span></label>
            {{ form.category }}
            {% if form.category.errors %}<span class="parsley-required">Category is required</span>{% endif %}
        </div>
        <div class="form-field">
            <label for="title">Title <span class="required">*</span></label>
            <input type="text" id="title" name="title" value="{% if form.title.value %}{{ form.title.value }}{% endif %}" size="100" data-parsley-required="true" data-parsley-required-message="Please enter a title for your post." />
            {% if form.title.errors %}<span class="parsley-required">Title is required</span>{% endif %}
        </div>
        <div class="form-field">
            <label for="summary">Body</label>
            <textarea name="summary" id="summary" cols="30" rows="10" maxlength="10000">{% if form.summary.value %}{{ form.summary.value }}{% endif %}</textarea>
        </div>
        {% if user.is_superuser %}
        <div class="form-field">
            <label for="username_list">Select an existing user</label>
            <select name="username_list">
                <option disabled selected>-- None --</option>
                {% for user in my_users %}
                <option value="{{ user.username }}" >{{ user.username }}</option>
                {% endfor %}
            </select>
        </div>
        <div class="form-field">
            <label for="username">or Enter a new username</label>
            <input type="text" name="username" />
            <label for="mugshot">New User Mugshot URL when entered a new username</label>
            <input type="text" name="mugshot" />
        </div>
        <div class="form-field pin-submit">
            <label for="id_pin">{{ form.pin }}Pin?</label>
        </div>
        {% endif %}
        <div class="form-field form-actions">
            <input type="submit" value="Submit Post" />
        </div>          
    </fieldset>
</form>

pip Build Fails

This request seems to fix this issue ... though it seems it must not be updated at pip.

2f6ba99

When attempting to install via pip,

(asdf_virtual)#prggmr… (django-parsley)$:→ pip install django-parsley
Downloading/unpacking django-parsley
  Running setup.py egg_info for package django-parsley
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/Users/prggmr/Lab/Envs/asdf_virtual/build/django-parsley/setup.py", line 116, in <module>
        long_description=read("README.md"),
      File "/Users/prggmr/Lab/Envs/asdf_virtual/build/django-parsley/setup.py", line 11, in read
        return open(os.path.join(os.path.dirname(__file__), fname)).read()
    IOError: [Errno 2] No such file or directory: '/Users/prggmr/Lab/Envs/asdf_virtual/build/django-parsley/README.md'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/Users/prggmr/Lab/Envs/asdf_virtual/build/django-parsley/setup.py", line 116, in <module>

    long_description=read("README.md"),

  File "/Users/prggmr/Lab/Envs/asdf_virtual/build/django-parsley/setup.py", line 11, in read

    return open(os.path.join(os.path.dirname(__file__), fname)).read()

IOError: [Errno 2] No such file or directory: '/Users/prggmr/Lab/Envs/asdf_virtual/build/django-parsley/README.md'

Problem with select fields attributes generation in django admin

I'm starting with django-parsley, it's a very nice app to develop django projects. It's very easy to configure and to use. But I have a problem using django-parsley to generate the client parsley validation in the django admin, I have this bug with django 1.6.1 and 1.6.7. The problem is related with select field parsley generation, all input fields are generated correctly, and the parsley.js validation works fine, but the data-parsley attribute of the select fields are missing.
I debugged for long time the django source and the html tags generated for the select fields don't contain the data-parsley attributes.
For now, I'm not using django-parsely for the django admin in my applications because not all fields are validated correctly.
I've searched online and I can't find any other developer comment regarding this problem. If anybody have this problem, or is able to find the solution, I'll be happy to use it.

Docs don't explain full installation steps or other necessary prerequisites to using django-parsley

Having a basic issue after installing django-parsley - the following error is displaying when I try to run the python manage.py runserver command:

from parsley.decorators import parsleyfy
ModuleNotFoundError: No module named 'parsley'

If parsley is a different dependency that must be installed in the project, could the docs be updated to reflect that? I can't figure out what to do to get this working.

Example of Custom-validators

Hi,

I appreciate the documentation however there is only example of using built-in validators on the Advanced Usage section. We will appreciate more if there are also an example of custom validators

Regards,
Dean

Admin: javascript error: "You must bind Parsley on an existing element." / update parsley

I have experimented with using django-parsley in the admin with Django 1.6.

I am seeing the error "You must bind Parsley on an existing element." in the Firefox console.

This appears to get triggered via the following code from parsley.js:

if (false !== ParsleyUtils.get(window, 'ParsleyConfig.autoBind'))
  $(document).ready(function () {
    // Works only on `data-parsley-validate`.
    $('[data-parsley-validate]').parsley();

I have then tried setting ParsleyConfig.autoBind = false, but there appears to be a problem with ParsleyUtils.get, which returns undefined for false.

This appears to be fixed in Parsley 2.0.2.

Also, parsley() is only called in 2.0.2 automatically, if matching elements have been found:

if (false !== ParsleyUtils.get(window, 'ParsleyConfig.autoBind'))
  $(document).ready(function () {
    // Works only on `data-parsley-validate`.
    if ($('[data-parsley-validate]').length)
      $('[data-parsley-validate]').parsley();
  });

Given this, and that there are probably more bug fixes in the latest parsley release, it should get updated with django-parsley.

I will provide a pull request for this.

Parsley on PyPI has no staticmedia.

The 0.1 release on PyPI doesn't include the static folder inside the parsley app, so everything throws a 404 on trying to load the JavaScript libraries.

> mkvirtualenv parsleytest
> workon parsleytest
> pip install django-parsley
[... install proceeds ...]
> cd lib/python2.7/site-packages/parsley
> tree
.
├── __init__.py
├── __init__.pyc
├── decorators.py
├── decorators.pyc
├── mixins.py
├── mixins.pyc
├── models.py
├── models.pyc
└── tests
    ├── __init__.py
    ├── __init__.pyc
    ├── admin.py
    ├── admin.pyc
    ├── forms.py
    ├── forms.pyc
    ├── models.py
    ├── models.pyc
    ├── tests.py
    ├── tests.pyc
    ├── views.py
    └── views.pyc

parsley_student table

Can you please put managed = False in Student model's Meta so it doesn't get created in db, or just remove the model. Thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.