Skip to content

Commit 81e883f

Browse files
committed
Update to Markdown Readme
For your comfort.
1 parent b1d3d6b commit 81e883f

File tree

2 files changed

+89
-74
lines changed

2 files changed

+89
-74
lines changed

README.rst

Lines changed: 88 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,139 @@
11
Django intl-tel-input
22
=====================
33

4-
.. image:: https://travis-ci.org/benmurden/django-intl-tel-input.svg?branch=master
5-
:target: https://travis-ci.org/benmurden/django-intl-tel-input
6-
.. image:: https://img.shields.io/codecov/c/github/benmurden/django-intl-tel-input.svg
7-
:target: https://codecov.io/gh/benmurden/django-intl-tel-input
4+
[![image]]
85

9-
A Django form widget for international telephone numbers based on the jQuery plugin `intl-tel-input`_.
6+
[![image][1]]
107

11-
This is a new package, so it doesn't implement all the features of
12-
intl-tel-input. However, it is well tested, and has been stable in production.
8+
A Django form widget for international telephone numbers based on the
9+
jQuery plugin [intl-tel-input].
10+
11+
This is a new package, so it doesn\'t implement all the features of
12+
intl-tel-input. However, it is well tested, and has been stable in
13+
production.
1314

1415
Version support
1516
---------------
1617

1718
Tested on the following versions of Python and Django.
1819

19-
Python: 2.7, 3.3, 3.4, 3.5, 3.6
20+
Python: 2.7, 3.4, 3.5, 3.6
2021
Django: 1.8, 1.9, 1.10, 1.11
2122

2223
Installation
2324
------------
2425

2526
Install from PyPI.
2627

27-
.. code:: shell
28-
29-
pip install django-intl-tel-input
28+
``` {.sourceCode .shell}
29+
pip install django-intl-tel-input
30+
```
3031

3132
Add intl-tel-input to your INSTALLED\_APPS, so Django can find the init
3233
script.
3334

34-
.. code:: python
35-
36-
...
37-
INSTALLED_APPS += ('intl_tel_input',)
38-
...
35+
``` {.sourceCode .python}
36+
...
37+
INSTALLED_APPS += ('intl_tel_input',)
38+
...
39+
```
3940

4041
Usage
4142
-----
4243

43-
Simply add ``IntlTelInputWidget`` to your form field.
44+
Simply add `IntlTelInputWidget` to your form field.
4445

45-
.. code:: python
46+
``` {.sourceCode .python}
47+
from intl_tel_input.widgets import IntlTelInputWidget
4648
47-
from intl_tel_input.widgets import IntlTelInputWidget
48-
49-
class MyForm(forms.ModelForm):
50-
class Meta:
51-
model = MyModel
52-
fields = ['foo', 'bar']
53-
widgets = {
54-
'bar': IntlTelInputWidget()
55-
}
56-
...
49+
class MyForm(forms.ModelForm):
50+
class Meta:
51+
model = MyModel
52+
fields = ['foo', 'bar']
53+
widgets = {
54+
'bar': IntlTelInputWidget()
55+
}
56+
...
57+
```
5758

5859
With a standard form:
5960

60-
.. code:: python
61-
62-
class MyForm(forms.Form):
63-
tel_number = forms.CharField(widget=IntlTelInputWidget())
61+
``` {.sourceCode .python}
62+
class MyForm(forms.Form):
63+
tel_number = forms.CharField(widget=IntlTelInputWidget())
6464
65-
...
65+
...
66+
```
6667

6768
Form media
6869
----------
6970

70-
Include ``{{ form.media.css }}`` in the ``<head>`` of your template. This will ensure all styles are parsed before the widget is displayed.
71+
Include `{{ form.media.css }}` in the `<head>` of your template. This
72+
will ensure all styles are parsed before the widget is displayed.
7173

72-
If you have included jQuery at the end of your document, then don't
74+
If you have included jQuery at the end of your document, then don\'t
7375
forget to update the template where this widget appears with a
74-
``{{ form.media.js }}``. Put it in a block that allows it to come after
76+
`{{ form.media.js }}`. Put it in a block that allows it to come after
7577
jQuery.
7678

77-
If you're using `crispy-forms`_, the static content will be inserted automatically beside the input. To prevent this, be sure to set ``include_media = False`` on your form helper.
79+
If you\'re using [crispy-forms], the static content will be inserted
80+
automatically beside the input. To prevent this, be sure to set
81+
`include_media = False` on your form helper.
82+
83+
``` {.sourceCode .python}
84+
class MyForm(forms.Form):
85+
...
86+
def __init__(self, *args, **kwargs):
87+
self.helper = FormHelper()
88+
self.helper.include_media = False
89+
...
90+
```
91+
92+
If you need to load all JS in the head, you can make the `init.js`
93+
script wait for the document to be ready with the following snippet.
94+
95+
``` {.sourceCode .javascript}
96+
jQuery(document).ready(
97+
{{ form.media.js }}
98+
);
99+
```
100+
101+
All this assumes your form context variable is called `form`.
102+
103+
[image]: https://travis-ci.org/benmurden/django-intl-tel-input.svg?branch=master
104+
[![image]]: https://travis-ci.org/benmurden/django-intl-tel-input
105+
[1]: https://img.shields.io/codecov/c/github/benmurden/django-intl-tel-input.svg
106+
[![image][1]]: https://codecov.io/gh/benmurden/django-intl-tel-input
107+
[intl-tel-input]: https://github.com/jackocnr/intl-tel-input
108+
[crispy-forms]: https://github.com/django-crispy-forms/django-crispy-forms
78109

79-
.. code:: python
80-
81-
class MyForm(forms.Form):
82-
...
83-
def __init__(self, *args, **kwargs):
84-
self.helper = FormHelper()
85-
self.helper.include_media = False
86-
...
87-
88-
If you need to load all JS in the head, you can make the ``init.js`` script
89-
wait for the document to be ready with the following snippet.
110+
Options
111+
=======
90112

91-
.. code:: javascript
113+
The widget can be invoked with keyword arguments which translate to the
114+
options available in intl-tel-input.
92115

93-
jQuery(document).ready(
94-
{{ form.media.js }}
95-
);
96-
97-
All this assumes your form context variable is called ``form``.
116+
allow\_dropdown
98117

99-
.. _intl-tel-input: https://github.com/jackocnr/intl-tel-input
100-
.. _crispy-forms: https://github.com/django-crispy-forms/django-crispy-forms
118+
: Shows the country dropdown. Default: `True`
101119

102-
Options
103-
-------
120+
default\_code
104121

105-
The widget can be invoked with keyword arguments which translate to the options
106-
available in intl-tel-input.
122+
: Country code selected by default. Overridden when using
123+
`auto_geo_ip`. Default: `'us'`
107124

108-
allow_dropdown
109-
Shows the country dropdown.
110-
Default: ``True``
125+
preferred\_countries
111126

112-
default_code
113-
Country code selected by default. Overridden when using ``auto_geo_ip``.
114-
Default: ``'us'``
127+
: Array of countries that will always appear at the top of the
128+
dropdown. Default: `['us', 'gb']`
115129

116-
preferred_countries
117-
Array of countries that will always appear at the top of the dropdown.
118-
Default: ``['us', 'gb']``
130+
auto\_geo\_ip
119131

120-
auto_geo_ip
121-
When True, `freegeoip`_ will be used to autodetect the user's country via Ajax. There is a limit of 15,000 queries per hour, so it should not be used on high-traffic sites. Alternatively use `pygeoip`_, detect server-side, then set the ``default_code``.
122-
Default: ``False``
132+
: When True, [freegeoip] will be used to autodetect the user\'s
133+
country via Ajax. There is a limit of 15,000 queries per hour, so it
134+
should not be used on high-traffic sites. Alternatively use
135+
[pygeoip], detect server-side, then set the `default_code`. Default:
136+
`False`
123137

124-
.. _freegeoip: https://freegeoip.net
125-
.. _pygeoip: https://pypi.python.org/pypi/pygeoip
138+
[freegeoip]: https://freegeoip.net
139+
[pygeoip]: https://pypi.python.org/pypi/pygeoip

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
license='BSD License',
1717
description='A Django form widget implementing intl-tel-input.',
1818
long_description=README,
19+
long_description_content_type="text/markdown",
1920
url='https://github.com/benmurden/django-intl-tel-input',
2021
author='Benjamin Murden',
2122
author_email='[email protected]',

0 commit comments

Comments
 (0)