internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ranaroussi/yfinance

Issue:
Tkr {} tz already in cache
I am running yfinance on celery (a background worker) whenever I start two tasks at nearly the same time, I get this error:

Tkr {} tz already in cache

Some help fixing this please, @ValueRaider...

Python Version: 3.10.6
yfinance Version: 0.2.25


Discussion:
The quickest fix is to manually edit your local Python install and disable that if-statement. Enable debug mode to generate stack trace showing exactly where.

I'll patch properly asap.
@ValueRaider I really can't understand the suggested fix, so I will wait for the patch. Thx for your help!

Edit: I understood what you mean in the quick fix.

Resolving patch:
diff --git a/yfinance/utils.py b/yfinance/utils.py
--- a/yfinance/utils.py
+++ b/yfinance/utils.py
@@ -980,10 +980,14 @@ def lookup(self, tkr):
     def store(self, tkr, tz):
         if tz is None:
             self.tz_db.delete(tkr)
-        elif self.tz_db.get(tkr) is not None:
-            raise Exception("Tkr {} tz already in cache".format(tkr))
         else:
-            self.tz_db.set(tkr, tz)
+            tz_db = self.tz_db.get(tkr)
+            if tz_db is not None:
+                if tz != tz_db:
+                    get_yf_logger().debug(f'{tkr}: Overwriting cached TZ "{tz_db}" with different TZ "{tz}"')
+                    self.tz_db.set(tkr, tz)
+            else:
+                self.tz_db.set(tkr, tz)
 
     @property
     def _db_dir(self):


Test patch:
diff --git a/tests/utils.py b/tests/utils.py
new file mode 100644
--- /dev/null
+++ b/tests/utils.py
@@ -0,0 +1,51 @@
+"""
+Tests for utils
+
+To run all tests in suite from commandline:
+   python -m unittest tests.utils
+
+Specific test class:
+   python -m unittest tests.utils.TestTicker
+
+"""
+# import pandas as pd
+# import numpy as np
+
+from .context import yfinance as yf
+from .context import session_gbl
+
+import unittest
+# import requests_cache
+import tempfile
+
+
+class TestUtils(unittest.TestCase):
+    session = None
+
+    @classmethod
+    def setUpClass(cls):
+        cls.tempCacheDir = tempfile.TemporaryDirectory()
+        yf.set_tz_cache_location(cls.tempCacheDir.name)
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.tempCacheDir.cleanup()
+
+    def test_storeTzNoRaise(self):
+        # storing TZ to cache should never raise exception
+        tkr = 'AMZN'
+        tz1 = "America/New_York"
+        tz2 = "London/Europe"
+        cache = yf.utils.get_tz_cache()
+        cache.store(tkr, tz1)
+        cache.store(tkr, tz2)
+
+
+def suite():
+    suite = unittest.TestSuite()
+    suite.addTest(TestUtils('Test utils'))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main()
Repository: ranaroussi/yfinance

Issue:
[DEV] import error
Error in `dev` branch:

```
import yfinance
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "yfinance/__init__.py", line 23, in <module>
    from .ticker import Ticker
  File "yfinance/ticker.py", line 29, in <module>
    from .base import TickerBase
  File "yfinance/base.py", line 38, in <module>
    from . import utils
  File "yfinance/utils.py", line 46, in <module>
    from .base import _BASE_URL_
ImportError: cannot import name '_BASE_URL_' from partially initialized module 'yfinance.base' (most likely due to a circular import) (yfinance/base.py)
```

@ricardoprins Probably related to the PEP 8 changes.


Discussion:
I will check, but just by reading this, I can tell you that this is not due to PEP 8 changes but to a bad structure of the module; there is a circular import right there.
You introduced the circular import: https://github.com/ranaroussi/yfinance/blame/dev/yfinance/utils.py#L46

Resolving patch:
diff --git a/yfinance/base.py b/yfinance/base.py
--- a/yfinance/base.py
+++ b/yfinance/base.py
@@ -42,8 +42,7 @@
 from .scrapers.holders import Holders
 from .scrapers.quote import Quote, FastInfo
 
-_BASE_URL_ = 'https://query2.finance.yahoo.com'
-_ROOT_URL_ = 'https://finance.yahoo.com'
+from .const import _BASE_URL_, _ROOT_URL_
 
 
 class TickerBase:
diff --git a/yfinance/const.py b/yfinance/const.py
--- a/yfinance/const.py
+++ b/yfinance/const.py
@@ -1,3 +1,5 @@
+_BASE_URL_ = 'https://query2.finance.yahoo.com'
+_ROOT_URL_ = 'https://finance.yahoo.com'
 
 fundamentals_keys = {
     'financials': ["TaxEffectOfUnusualItems", "TaxRateForCalcs", "NormalizedEBITDA", "NormalizedDilutedEPS",
@@ -113,3 +115,5 @@
                   "PaymentstoSuppliersforGoodsandServices", "ClassesofCashReceiptsfromOperatingActivities",
                   "OtherCashReceiptsfromOperatingActivities", "ReceiptsfromGovernmentGrants", "ReceiptsfromCustomers"]}
 
+
+
diff --git a/yfinance/utils.py b/yfinance/utils.py
--- a/yfinance/utils.py
+++ b/yfinance/utils.py
@@ -43,7 +43,7 @@
 from dateutil.relativedelta import relativedelta
 from pytz import UnknownTimeZoneError
 
-from .base import _BASE_URL_
+from .const import _BASE_URL_
 
 try:
     import ujson as _json


Test patch:
Repository: ranaroussi/yfinance

Issue:
dev regression: ticker timezone fetch fails
### Describe bug

In `dev` branch, ticker timezone fetch fails:

> Failed to get ticker 'AAPL' reason: expected string or bytes-like object, got 'int'

Works fine in `main`.

### Simple code that reproduces your problem

``` python
import yfinance as yf
yf.enable_debug_mode()
tkr = "AAPL"
dat = yf.Ticker(tkr)
tz = dat._get_ticker_tz(proxy=None, timeout=30)
print(tz)
```

### Debug log

```
DEBUG    Entering _fetch_ticker_tz()
DEBUG     Entering get()
DEBUG      url=https://query2.finance.yahoo.com/v8/finance/chart/AAPL
DEBUG      params=frozendict.frozendict({'range': '1d', 'interval': '1d'})
DEBUG      Entering _get_cookie_and_crumb()
DEBUG       cookie_mode = 'basic'
DEBUG       Entering _get_cookie_and_crumb_basic()
DEBUG        loaded persistent cookie
DEBUG        reusing cookie
DEBUG        crumb = 'PHy.w9n0dQm'
DEBUG       Exiting _get_cookie_and_crumb_basic()
DEBUG      Exiting _get_cookie_and_crumb()
ERROR     Failed to get ticker 'AAPL' reason: expected string or bytes-like object, got 'int'
DEBUG    Exiting _fetch_ticker_tz()
None
```

### Bad data proof

_No response_

### `yfinance` version

dev

### Python version

_No response_

### Operating system

_No response_


Discussion:

Resolving patch:
diff --git a/yfinance/base.py b/yfinance/base.py
--- a/yfinance/base.py
+++ b/yfinance/base.py
@@ -1650,7 +1650,7 @@ def map_signals_to_ranges(f, f_up, f_down):
 
         return df2
 
-    def _get_ticker_tz(self,timeout, proxy=None):
+    def _get_ticker_tz(self, proxy, timeout):
         proxy = proxy or self.proxy
         if self._tz is not None:
             return self._tz
@@ -1675,7 +1675,7 @@ def _get_ticker_tz(self,timeout, proxy=None):
         return tz
 
     @utils.log_indent_decorator
-    def _fetch_ticker_tz(self, timeout, proxy=None):
+    def _fetch_ticker_tz(self, proxy, timeout):
         # Query Yahoo for fast price data just to get returned timezone
         proxy = proxy or self.proxy
         logger = utils.get_yf_logger()


Test patch:
diff --git a/tests/ticker.py b/tests/ticker.py
--- a/tests/ticker.py
+++ b/tests/ticker.py
@@ -86,7 +86,7 @@ def test_getTz(self):
 
             # Test:
             dat = yf.Ticker(tkr, session=self.session)
-            tz = dat._get_ticker_tz(proxy=None, timeout=None)
+            tz = dat._get_ticker_tz(proxy=None, timeout=5)
 
             self.assertIsNotNone(tz)
Repository: ranaroussi/yfinance

Issue:
Replace 'appdirs' dependency with 'platformdirs'
`platformdirs` is the fork to abandoned `appdirs`. https://github.com/platformdirs/platformdirs

Should be a simple drop-in replacement. https://github.com/ranaroussi/yfinance/blob/1d31e7ca016768c5a3f820c29049d3aa25132b7d/yfinance/cache.py#L4


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -61,7 +61,7 @@
     packages=find_packages(exclude=['contrib', 'docs', 'tests', 'examples']),
     install_requires=['pandas>=1.3.0', 'numpy>=1.16.5',
                       'requests>=2.31', 'multitasking>=0.0.7',
-                      'lxml>=4.9.1', 'appdirs>=1.4.4', 'pytz>=2022.5',
+                      'lxml>=4.9.1', 'platformdirs>=2.0.0', 'pytz>=2022.5',
                       'frozendict>=2.3.4', 'peewee>=3.16.2',
                       'beautifulsoup4>=4.11.1', 'html5lib>=1.1'],
     extras_require={
diff --git a/yfinance/cache.py b/yfinance/cache.py
--- a/yfinance/cache.py
+++ b/yfinance/cache.py
@@ -1,7 +1,7 @@
 import peewee as _peewee
 from threading import Lock
 import os as _os
-import appdirs as _ad
+import platformdirs as _ad
 import atexit as _atexit
 import datetime as _datetime
 import pickle as _pkl


Test patch:
diff --git a/tests/context.py b/tests/context.py
--- a/tests/context.py
+++ b/tests/context.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-import appdirs as _ad
+import platformdirs as _ad
 import datetime as _dt
 import sys
 import os
Repository: DjangoGirls/djangogirls

Issue:
Make event URLs case insensitive
From @williln in slack:

> Is there a way to make the URLs not case-sensitive? http://djangogirls.org/Portland/ leads to a 404, but http://djangogirls.org/portland/ doesn't. 



Discussion:

Resolving patch:
diff --git a/core/views.py b/core/views.py
--- a/core/views.py
+++ b/core/views.py
@@ -3,7 +3,7 @@
 import icalendar
 
 from django.http import HttpResponse, Http404
-from django.shortcuts import render, redirect
+from django.shortcuts import get_object_or_404, render, redirect
 from django.utils import timezone
 from django_date_extensions.fields import ApproximateDate
 
@@ -48,16 +48,18 @@ def event(request, city):
 
     now = timezone.now()
     now_approx = ApproximateDate(year=now.year, month=now.month, day=now.day)
-    try:
-        page = EventPage.objects.get(url=city)
-        if not (request.user.is_authenticated()
-                or request.GET.has_key('preview')):
-            if not page.is_live:
-                past = page.event.date <= now_approx
-                return render(request, "event_not_live.html",
-                              {'city': city, 'past': past})
-    except EventPage.DoesNotExist:
-        raise Http404
+    page = get_object_or_404(EventPage, url__iexact=city)
+
+    if page.url != city:
+        return redirect('core:event', city=page.url, permanent=True)
+
+    can_show = request.user.is_authenticated() or 'preview' in request.GET
+    if not page.is_live and not can_show:
+        return render(
+            request,
+            'event_not_live.html',
+            {'city': city, 'past': page.event.date <= now_approx}
+        )
 
     menu = EventPageMenu.objects.filter(page=page)
     content = EventPageContent.objects.filter(page=page, is_public=True)


Test patch:
Repository: DjangoGirls/djangogirls

Issue:
Order of the questions in the form can get mixed up
Haven't debug it yet, but just adding so I won't forget



Discussion:

Resolving patch:
diff --git a/applications/utils.py b/applications/utils.py
--- a/applications/utils.py
+++ b/applications/utils.py
@@ -1,8 +1,10 @@
+from collections import OrderedDict
+
 from django import forms
 
 
 def generate_form_from_questions(questions):
-    fields = {}
+    fields = OrderedDict()
 
     for question in questions:
         options = {


Test patch:
Repository: DjangoGirls/djangogirls

Issue:
Fix fetching city coordinates
I noticed that for a while, the script that fetches city coordinates from some API just stopped working. Didn't have time to investigate, but returned coordinates are None.



Discussion:

Resolving patch:
diff --git a/core/utils.py b/core/utils.py
--- a/core/utils.py
+++ b/core/utils.py
@@ -6,19 +6,20 @@
 
 from .models import EventPage
 
+NOMINATIM_URL = 'http://nominatim.openstreetmap.org/search'
 
-def get_coordinates_for_city(city, country):
 
-    q = '{0}, {1}'.format(city.encode('utf-8'), country.encode('utf-8'))
+def get_coordinates_for_city(city, country):
+    q = '{0}, {1}'.format(city, country)
     req = requests.get(
-        'http://nominatim.openstreetmap.org/search',
+        NOMINATIM_URL,
         params={'format': 'json', 'q': q}
     )
 
     try:
         data = req.json()[0]
         return '{0}, {1}'.format(data['lat'], data['lon'])
-    except:
+    except (IndexError, KeyError):
         return None
 
 


Test patch:
diff --git a/core/tests/test_utils.py b/core/tests/test_utils.py
new file mode 100644
--- /dev/null
+++ b/core/tests/test_utils.py
@@ -0,0 +1,54 @@
+from unittest import TestCase
+from unittest.mock import patch
+
+from core.utils import get_coordinates_for_city, NOMINATIM_URL
+
+
+@patch('requests.get')
+class GetCoordinatesForCityTest(TestCase):
+    def test_get_coordinates_for_city(self, mock_get):
+        mock_get.return_value.json.return_value = [{
+            'lat': '1.23',
+            'lon': '4.56',
+        }]
+
+        result = get_coordinates_for_city('London', 'UK')
+
+        mock_get.assert_called_once_with(
+            NOMINATIM_URL,
+            params={
+                'format': 'json',
+                'q': 'London, UK',
+            }
+        )
+        self.assertEqual(result, '1.23, 4.56')
+
+    def test_returns_none_when_no_results(self, mock_get):
+        # Results are an empty list
+        mock_get.return_value.json.return_value = []
+
+        result = get_coordinates_for_city('PretendTown', 'UK')
+
+        mock_get.assert_called_once_with(
+            NOMINATIM_URL,
+            params={
+                'format': 'json',
+                'q': 'PretendTown, UK',
+            }
+        )
+        self.assertIsNone(result)
+
+    def test_returns_none_when_invalid_results(self, mock_get):
+        # Empty dict returned in results
+        mock_get.return_value.json.return_value = [{}]
+
+        result = get_coordinates_for_city('PretendTown', 'UK')
+
+        mock_get.assert_called_once_with(
+            NOMINATIM_URL,
+            params={
+                'format': 'json',
+                'q': 'PretendTown, UK',
+            }
+        )
+        self.assertIsNone(result)
Repository: DjangoGirls/djangogirls

Issue:
Error when visiting an application form of a page that doesn't exist
![screen shot 2015-10-16 at 11 29 44 am](https://cloud.githubusercontent.com/assets/527795/10539688/544687e8-73f9-11e5-8715-58b12e08fe1d.png)



Discussion:

Resolving patch:
diff --git a/applications/decorators.py b/applications/decorators.py
--- a/applications/decorators.py
+++ b/applications/decorators.py
@@ -20,12 +20,11 @@ def decorator(request, *args, **kwargs):
                 '"City" slug must be present to user this decorator.')
 
         if not request.user.is_authenticated():
-            return redirect('core:event', kwargs.get('city')) 
+            return redirect('core:event', kwargs.get('city'))
 
         city = kwargs.get('city')
         page = get_event_page(city, request.user.is_authenticated(), False)
-        if request.user in page.event.team.all() or request.user.is_superuser:
+        if page and (request.user in page.event.team.all() or request.user.is_superuser):
             return function(request, *args, **kwargs)
-        else:
-            return HttpResponseNotFound()
+        return HttpResponseNotFound()
     return decorator


Test patch:
Repository: DjangoGirls/djangogirls

Issue:
Error when there is more than one form for a page
![screen shot 2015-10-15 at 9 33 47 am](https://cloud.githubusercontent.com/assets/527795/10508587/e6062420-731f-11e5-82e1-e8d151a19a22.png)



Discussion:

Resolving patch:
diff --git a/applications/views.py b/applications/views.py
--- a/applications/views.py
+++ b/applications/views.py
@@ -24,7 +24,7 @@ def apply(request, city):
         )
 
     try:
-        form_obj = Form.objects.get(page=page)
+        form_obj = Form.objects.filter(page=page).first()
     except Form.DoesNotExist:
         return redirect('core:event', city)
 


Test patch:
Repository: DjangoGirls/djangogirls

Issue:
Add job/meetup forms could be formatted better
_From @MarysiaLowas on July 24, 2015 19:1_

For now, all input fields in Add job/meetup forms are set to 260px but it would be nicer to have them wider. And we could also improve the forms layout but we would need to dive into crispy forms.

_Copied from original issue: djangogirlsjobs/djangogirls#68_



Discussion:
Remove 'crispy_forms' as they are deprecated. Find another library or try to use pure bootstrap.

I am working on this one :dango: 


Resolving patch:
diff --git a/djangogirls/settings.py b/djangogirls/settings.py
--- a/djangogirls/settings.py
+++ b/djangogirls/settings.py
@@ -39,7 +39,6 @@
     'easy_thumbnails',
 
     'django_countries',
-    'crispy_forms',
     'bootstrap3_datetime',
 
     'ckeditor',
@@ -173,7 +172,6 @@
 
 APPEND_SLASH = True
 
-CRISPY_TEMPLATE_PACK = 'bootstrap3'
 CKEDITOR_UPLOAD_PATH = "uploads/"
 CKEDITOR_CONFIGS = {
     'default': {
diff --git a/jobs/templatetags/__init__.py b/jobs/templatetags/__init__.py
new file mode 100644
diff --git a/jobs/templatetags/jobs_tags.py b/jobs/templatetags/jobs_tags.py
new file mode 100644
--- /dev/null
+++ b/jobs/templatetags/jobs_tags.py
@@ -0,0 +1,10 @@
+from django import template
+
+register = template.Library()
+
+@register.filter(name='addclass')
+def addclass(field, new_classes):
+
+    old_classes = field.field.widget.attrs.get('class', '')
+    classes = ' '.join([old_classes, new_classes])
+    return field.as_widget(attrs={"class": classes})


Test patch:
Repository: DjangoGirls/djangogirls

Issue:
Admin site: Add "search" to coaches
The coaches list [here](https://djangogirls.org/admin/core/coach/) has paging logic, but spans 33 pages at the moment. Add a search feature so it's easier to find the coach you need to edit. 



Discussion:

Resolving patch:
diff --git a/core/admin.py b/core/admin.py
--- a/core/admin.py
+++ b/core/admin.py
@@ -168,6 +168,7 @@ def get_form(self, request, obj=None, **kwargs):
 
 class CoachAdmin(admin.ModelAdmin):
     list_display = ('name', 'photo_display_for_admin', 'twitter_handle', 'url')
+    search_fields = ('name', 'twitter_handle', 'url')
 
     def get_queryset(self, request):
         qs = super(CoachAdmin, self).get_queryset(request)


Test patch:
Repository: DjangoGirls/djangogirls

Issue:
Adding captcha to application form
To prevent robots to fill application forms, I added simple captcha. I also modified `tests_views.py` because we have two extra fields now. Fix #211



Discussion:

Resolving patch:
diff --git a/applications/forms.py b/applications/forms.py
--- a/applications/forms.py
+++ b/applications/forms.py
@@ -1,6 +1,7 @@
 from django import forms
 from django.template.loader import render_to_string
 from django.core.mail import EmailMessage
+from captcha.fields import CaptchaField
 
 from .models import Application, Answer, Question, Score, Email
 from .utils import generate_form_from_questions
@@ -16,6 +17,7 @@ def __init__(self, *args, **kwargs):
         questions = kwargs.pop('questions')
         super(ApplicationForm, self).__init__(*args, **kwargs)
         self.fields = generate_form_from_questions(questions)
+        self.fields['captcha'] = CaptchaField()
 
 
     def save(self, *args, **kwargs):
diff --git a/djangogirls/settings.py b/djangogirls/settings.py
--- a/djangogirls/settings.py
+++ b/djangogirls/settings.py
@@ -36,6 +36,7 @@
     'djrill',
     'django_nose',
     'easy_thumbnails',
+    'captcha',
 
     'django_countries',
     'bootstrap3_datetime',
diff --git a/djangogirls/urls.py b/djangogirls/urls.py
--- a/djangogirls/urls.py
+++ b/djangogirls/urls.py
@@ -20,5 +20,6 @@
     url(r'^pages/', include('django.contrib.flatpages.urls')),
     url(r'^account/', include('django.contrib.auth.urls')),
     url(r'', include('applications.urls', namespace='applications')),
-    url(r'', include('core.urls', namespace='core'))
+    url(r'^captcha/', include('captcha.urls')),
+    url(r'', include('core.urls', namespace='core')),
 ]


Test patch:
diff --git a/applications/tests/tests_views.py b/applications/tests/tests_views.py
--- a/applications/tests/tests_views.py
+++ b/applications/tests/tests_views.py
@@ -28,9 +28,9 @@ def test_access_apply_view(self):
         resp = self.client.get(reverse('applications:apply', args=['test']))
         self.assertEqual(resp.status_code, 200)
         self.assertEqual(resp.context['form_obj'], self.form)
-        # there is one more field than default questions,
-        # because we always add newsletter optin at the end
-        self.assertEqual(len(resp.context['form'].fields), len(DEFAULT_QUESTIONS)+1)
+        # there is two more fields than default questions,
+        # because we always add newsletter option at the end and a captcha
+        self.assertEqual(len(resp.context['form'].fields), len(DEFAULT_QUESTIONS)+2)
 
         # Redirect to event page because there is no form
         self.form.delete()
Repository: DjangoGirls/djangogirls

Issue:
make it possible to change the email of applicants
We have a few applications with typos in the email field but we can't change them.



Discussion:
Can you explain exactly what is required here?

I'll work on that ticket today. :) 

For anyone looking to work on this ticket, I think a solution/workaround might be to mark the `rsvp_yes_code` and `rsvp_no_code` fields as `editable=False` in the model definition (`Application` inside `applications/models.py`).

This would work because the two fields are the ones preventing someone from changing the email in the admin (they require a value but it's not clear what to put in them).

Using `editable=False` would make both fields disapear from the form in the admin, which is OK because their value is generated automatically later in the process.


Resolving patch:
diff --git a/applications/models.py b/applications/models.py
--- a/applications/models.py
+++ b/applications/models.py
@@ -155,8 +155,8 @@ class Application(models.Model):
         choices=RSVP_STATUSES, verbose_name="RSVP status",
         default=RSVP_WAITING
     )
-    rsvp_yes_code = models.CharField(max_length=24, null=True)
-    rsvp_no_code = models.CharField(max_length=24, null=True)
+    rsvp_yes_code = models.CharField(max_length=24, null=True, blank=True)
+    rsvp_no_code = models.CharField(max_length=24, null=True, blank=True)
 
     class Meta:
         unique_together = ("form", "email")


Test patch:
Repository: DjangoGirls/djangogirls

Issue:
[organizer form] Change previous event list to a search field
When applying to organize an event, [people can tell us](https://djangogirls.org/organize/form/previous_event/) if they already organized one event.
Problem: they have to look for their event in a drop down menu with more than 200 items. It's super hard to do, especially on a phone.

We could change this field to a search field or just a regular text field.

![capture d ecran de 2017-01-19 19-07-32](https://cloud.githubusercontent.com/assets/481052/22119127/a9b93468-de7a-11e6-9e4d-be2e9b404306.png)
[organizer form] Change previous event list to a search field
When applying to organize an event, [people can tell us](https://djangogirls.org/organize/form/previous_event/) if they already organized one event.
Problem: they have to look for their event in a drop down menu with more than 200 items. It's super hard to do, especially on a phone.

We could change this field to a search field or just a regular text field.

![capture d ecran de 2017-01-19 19-07-32](https://cloud.githubusercontent.com/assets/481052/22119127/a9b93468-de7a-11e6-9e4d-be2e9b404306.png)


Discussion:

Resolving patch:
diff --git a/organize/forms.py b/organize/forms.py
--- a/organize/forms.py
+++ b/organize/forms.py
@@ -100,7 +100,8 @@ class WorkshopForm(forms.Form):
         required=True,
         max_length=200,
         widget=forms.TextInput(attrs={'class': 'compact-input'}))
-    country = LazyTypedChoiceField(choices=countries)
+    country = LazyTypedChoiceField(
+        choices=[(None, 'Choose country')] + list(countries))
     venue = forms.CharField(
         widget=forms.Textarea(attrs={'class': 'compact-input'}))
     sponsorship = forms.CharField(


Test patch: