Giter Site home page Giter Site logo

django-select2-forms's People

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

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-select2-forms's Issues

Setting auto_created causes makemigrations issues

The code currently sets meta.auto_created for the SortableThroughModelBase class.

Unfortunately, this means that in our app, when we have a model inheriting from SortableThroughModel, then Django's makemigrations will ignore that model, and we won't get the tables automatically created.

Worse, if we manually create the migration for this model, then a future makemigrations will try to delete it.

Unless we missed something, this means we completely lose the benefits of makemigrations, and if we start using SortableThroughModelBase then we can't rely on makemigrations any more.

Why is auto_created set this way? Is there any way to not have it set, so that makemigrations works?

Or should we be doing things differently?

Django 3 and six.

Not work with Django 3.
ImportError: cannot import name 'six' from 'django.utils

Upgrade pypi release

pypi has 2.0.1 but there's 2.0.2 in github. Could you please upgrade pypi release?

Syntax error on line 107 views.py

We had a project on Python 3.9 and the minute I started using PDM I got this warning, for some reason PDM has revealed the warning:

select2/views.py:107: SyntaxWarning: "is" with a literal. Did you mean "=="?

You shouldn't be using is to check for equality, is is for checking identity only for things like if something is None

Did you want me to send a quick patch?

Hidden field?

Why the city field is hidden? I render the form via {{ form.as_p }}

<input type="hidden" name="city" data-placeholder="None" class="django-select2" data-sortable="false" id="id_city" data-select2-options="{&quot;ajax&quot;: {&quot;url&quot;: &quot;/select2/fetch_items/users/user/city/&quot;, &quot;dataType&quot;: &quot;json&quot;, &quot;quietMillis&quot;: 200}, &quot;allowClear&quot;: true}" data-init-selection-url="/select2/init_selection/users/user/city/" />
city = select2.fields.ForeignKey(City, blank=True, null=True, ajax=True, search_field='name', js_options={'quiet_millis': 200}, on_delete=models.PROTECT)

select2.jquery_ready.js makes $ jquery object inaccessible from other scripts

I'm not super proficient at JavaScript, but from what I can tell, any page on which I load the select2.jquery_ready.js file, the '$' jquery object becomes undefined. I've validated this with code elsewhere on the page, removing all other scripts, and trying to access '$' via the console. Also, when reassigning the variable just after loading the script with 'var $ = jQuery', everything works as expected. I can't tell which part of the file might be causing this.

Field rendering fails when URLs are not present

I'm using your wonderful library for a simple ChoiceField. However, using it in this way:

from select2.fields import ChoiceField
class MyForm(forms.Form):
    something = ChoiceField(choices=('what', 'ever'))

will result in an exception in line 115 of widgets.py when rendering the widget in a template.

There are two problems with that line:

  1. This attribute should only be used when ajax is enabled.
  2. The reverse URL is only available when the supplied urls.py is added to the site's urls. This, however, isn't documented.

I'll prepare some edits that should resolve the problem. However, since I'm only using and testing the changes with a simple ChoiceField, don't trust them too far.

cannot import name ReverseManyRelatedObjectsDescriptor

  • python 2.7.6
  • django 1.9.5
File "/home/user/site/app/models.py", line 14, in <module>
    import select2.fields
File "/opt/py27/lib/site-packages/select2/fields.py", line 10, in <module>
    from .models.descriptors import SortableReverseManyRelatedObjectsDescriptor
File "/opt/py27/lib/site-packages/select2/models/descriptors.py", line 4, in <module>
    from django.db.models.fields.related import ReverseManyRelatedObjectsDescriptor
ImportError: cannot import name ReverseManyRelatedObjectsDescriptor

Version 2.1.0 on pypi?

One of the projects that I'm working on is running into an issue with the unicode calls in views.py. These were fixed 3 months ago on master and the 2.1.0 release seems to contain these fixes.

However, pypi only has version 2.0.2 listed so I can't install 2.1.0 with pip. Is there a timeline for when 2.1.0 will be pushed to pypi?

Select2 4.0

We're in the process of finalizing the 4.0 release and are aiming to have it done by the end of this month at the latest.

https://select2.github.io/

Since I'm not very familiar with this plugin, I can't really judge how easy it is going to be to migrate over to the new version.

Events are binded to the wrong form when adding an inline form in javascript

(django: 1.8.9, django-select2-forms: HEAD)

How to reproduce:

  • Create an admin view with a M2M in an inline form (should do with both tabular and stacked, but tested only with stacked)
  • The inline form has a select2 field (should do with all the select2 fields but tested only with Select2ManyToMany)
  • Open the admin view
  • In the inline add a new form with the "Add anothert" link
  • A new form is added in javascript
  • Click in the select2 field to open the widget

Observed behavior

  • The widget open in the top left of the page
  • You can select the options of the widget
  • The options do not fill in the input of the new form
  • When you save form the selected options are not saved

Expected behavior

  • The widget should work for the dynamically added forms as for a regular form

Explanation

The event is binded to the hidden form that is used to instanciate the new form when the user click on the "Add another". When a new form is instanciated its id is dynamically changed.
When the event is trigger it still target the hidden form and not the new one. You can see that the options are added to the hidden form rather than the new one.

How to solve

Make sure that the events are not binded to the hidden form
Dynamically bind the field on the dynamic form. This should be easier with the new`formset:addedandformset:removed`` jQuery events in Django 1.9 django/django@1335aa2

unicode problem

related_name=_('name')

related.py", line 1782, in contribute_to_related_class
setattr(cls, related.get_accessor_name(), self.related_accessor_class(relat
d))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordi
al not in range(128)

Minor bug in validation of ajax 'page' parameter

I noticed this in select2/Select2View.py

            try:
                page = int(page)
            except TypeError:
                raise InvalidParameter("Invalid page '%s' passed")
            else:
                if page < 1:
                    raise InvalidParameter("Invalid page '%s' passed")

The value of page needs to be interpolated into both exception messages.

Weird import bug

In [1]: import select2

In [2]: select2.fields
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-6ec2b8b5794a> in <module>()
----> 1 select2.fields

AttributeError: 'module' object has no attribute 'fields'

In [3]: dir(select2)
Out[3]:
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 '__version__',
 '__version_info__']

In [4]: import select2.fields

In [5]: dir(select2)
Out[5]:
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 '__version__',
 '__version_info__',
 'fields',
 'models',
 'utils',
 'widgets']

Old PyPi version

PyPi has an older version of the library which can't be used with Django 1.9.

Make 'Hold down "Control", or "Command" on a Mac, to select more than one.' hideable.

The MultipleSelect still shows

Hold down "Control", or "Command" on a Mac, to select more than one.

help_text. It doesn't hurt holding down Control, but it isn't really needed if Select2 kicks in.

I use modernizr, so putting the "Hold down Control" message in a span with a class of "controlmsg" would be great. Then I can hide it with

.js .controlmsg {
    display: none;
}

and still have it gracefully there when javascript is disabled.

Any better idea for the controlmsg classname? Or another solution for the issue? Perhaps <noscript> tags are still allowed?

autocomplete options render in admin but has no options inline

I'm using Django 1.11 and the select2 form autosuggests and completes perfectly in admin, but on my HTML page it doesn't.

In HTML, my form field is called tags and I'm using

{{forms.media}} 
{{forms.tags}}

forms.py

...
tags = select2.fields.MultipleChoiceField(Tag,overlay="Choose several skills...")
...

models.py

...
tags = select2.fields.ManyToManyField(Tag,overlay="Choose several skills...",ajax=True,search_field="name")
...

Document that form.media should be put in the templates.

I like how you don't render <script> in the widget (which is what django-select2 does) as it enables me to put all javascript at the end of the document, using {{form.media.js}} and css in the head using {{form.media.css}}

This should be documented somewhere.

Not possible to create model EntryAuthors(select2.models.SortableThroughModel)

Hi,
I have installed the django-select2-forms in my django project and I have problem to create model
EntryAuthors, I have been developing my application in django 1.8.2. My problem comes with m2m field where I need to have ability to store order of elements. When I set models: Author and Entry from first example it works fine, but when I try to add middle table EntryAuthors I can't create migration for this table and migrate it. My problem comes with EntryAuthors(select2.models.SortableThroughModel) code in bracket. Can you check this issue, or create simple project for example m2m with storing order with your modul in django 1.8 and put somewhere?

Error cannot import name 'force_unicode' in django 1.9

I have a error in the moment: import select2.fields

File "C:\Python34\lib\site-packages\select2\fields.py", line 7, in
from django.utils.encoding import force_unicode
ImportError: cannot import name 'force_unicode'

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.