예제 #1
0
    def load(self, request):
        '''Import a CSV file containing countries.'''
        countries = request.FILES
        reader = csv.reader(countries['csv'])
        for row in reader:
            c = Country(name=row[0], special=bool(row[1]))
            c.save()

        return HttpResponseRedirect(reverse('admin:core_country_changelist'))
예제 #2
0
    def load(self, request):
        '''Import a CSV file containing countries.'''
        countries = request.FILES
        reader = csv.reader(
            countries['csv'].read().decode('utf-8').splitlines())
        for row in reader:
            special = False if row[1] == '0' or row[
                1] == 'False' or not row[1] else True
            c = Country(name=row[0], special=special)
            c.save()

        return HttpResponseRedirect(reverse('admin:core_country_changelist'))
예제 #3
0
def new_country(**kwargs):
    c = Country(
        name=kwargs.pop('name', 'TestCountry'),
        special=kwargs.pop('special', False))
    c.save()
    return c
예제 #4
0
파일: test.py 프로젝트: m-j-mcdonald/huxley
 def new_country(**kwargs):
     c = Country(name=kwargs.pop("name", "TestCountry"), special=kwargs.pop("special", False))
     c.save()
     return c