-
Notifications
You must be signed in to change notification settings - Fork 317
more structured quick start #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
acef399
79c301e
d77d0b3
d1e9df5
71ff4df
695c985
05616af
75fc6cd
70ca7b2
b618ee9
ca57ebf
2984192
945b3f5
25197fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ stages: | |
|
|
||
| jobs: | ||
| include: | ||
| - python: "3.5" | ||
| - python: "3.7" | ||
| env: TOXENV=docs | ||
| addons: | ||
| apt: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| Contributing | ||
| ============ | ||
|
|
||
| This package uses the pyTest test runner. To run the tests locally simply run:: | ||
|
|
||
| python setup.py test | ||
|
|
||
| If you need to the development dependencies installed of you local IDE, you can run:: | ||
|
|
||
| python setup.py develop | ||
|
|
||
| Documentation pull requests welcome. The Sphinx documentation can be compiled via:: | ||
|
|
||
| python setup.py build_sphinx | ||
|
|
||
| Bug reports welcome, even more so if they include a correct patch. Much | ||
| more so if you start your patch by adding a failing unit test, and correct | ||
| the code until zero unit tests fail. | ||
|
|
||
| The list of supported Django and Python version can be found in the CI suite setup. | ||
| Please make sure to verify that none of the linters or tests failed, before you submit | ||
| a patch for review. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .. include:: ../CONTRIBUTING.rst |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,12 @@ Overview | |
| .. automodule:: django_select2 | ||
| :members: | ||
|
|
||
| Assumptions | ||
| ----------- | ||
|
|
||
| * You have a running Django up and running. | ||
| * You have form fully working without Django-Select2. | ||
|
|
||
| Installation | ||
| ------------ | ||
|
|
||
|
|
@@ -17,11 +23,12 @@ Installation | |
|
|
||
| 2. Add ``django_select2`` to your ``INSTALLED_APPS`` in your project settings. | ||
|
|
||
| 3. Add ``django_select`` to your ``urlconf``:: | ||
|
|
||
| 3. Add ``django_select`` to your ``urlconf`` **if** you use any | ||
| :class:`ModelWidgets <.django_select2.forms.ModelSelect2Mixin>`:: | ||
| path('select2/', include('django_select2.urls')), | ||
|
|
||
| url(r'^select2/', include('django_select2.urls')), | ||
| You can safely skip this one if you do not use any | ||
| :class:`ModelWidgets <.django_select2.forms.ModelSelect2Mixin>` | ||
|
|
||
| Quick Start | ||
| ----------- | ||
|
|
@@ -30,19 +37,22 @@ Here is a quick example to get you started: | |
|
|
||
| 0. Follow the installation instructions above. | ||
|
|
||
| 1. Add a select2 widget to the form. For example if you wanted Select2 with multi-select you would use | ||
| ``Select2MultipleWidget`` | ||
| Replacing:: | ||
| 1. Replace native Django forms widgets with one of the several ``django_select2.form`` widgets. | ||
| Start by importing them into your ``forms.py``, right next to Django own ones:: | ||
|
|
||
| class MyForm(forms.Form): | ||
| things = ModelMultipleChoiceField(queryset=Thing.objects.all()) | ||
| from django import forms | ||
| from django_select2 import forms as s2forms | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call to include the imports. I always forget 👍 |
||
|
|
||
| with:: | ||
| Then let's assume you have a model with a choice, a :class:`.ForeignKey`, and a | ||
| :class:`.ManyToManyField`, you would add this information to your Form Meta | ||
| class:: | ||
|
|
||
| from django_select2.forms import Select2MultipleWidget | ||
|
|
||
| class MyForm(forms.Form): | ||
| things = ModelMultipleChoiceField(queryset=Thing.objects.all(), widget=Select2MultipleWidget) | ||
| widgets = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please include the entire code example, otherwise people will be confused.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't written it yet. I'll review the PR in its entirety, and come back to you soon (36h).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 36h went by, and I'm still busy on the project I'm working at. (mfrasca/ghini) |
||
| 'category': s2forms.Select2Widget, | ||
| 'author': s2forms.ModelSelect2Widget(model=auth.get_user_model(), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You did not import |
||
| search_fields=['first_name__istartswith', 'last_name__icontains']), | ||
| 'attending': s2forms.ModelSelect2MultipleWidget … | ||
| } | ||
|
|
||
| 2. Add the CSS to the ``head`` of your Django template:: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ Contents: | |
| get_started | ||
| django_select2 | ||
| extra | ||
| CONTRIBUTING | ||
|
|
||
| Indices and tables | ||
| ================== | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.