import csv
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.base import View
import urllib.request
import json
from parser4.models import Twogis


class View(View):

    def parse(request, *args, **kwargs):
        response = HttpResponse(content_type='text/csv')
        response['Content-Disposition'
            ] = 'attachment; filename="somefilename.csv"'
        writer = csv.writer(response)
        writer.writerow(['oid', 'address', 'name', 'lat', 'lon'])
        twogiss = Twogis.objects.all()
        for twogis in twogiss:
            writer.writerow([twogis.oid, twogis.address, twogis.name,
                twogis.lat, twogis.lon])
        return response

    def truncate(request, *args, **kwargs):
        Twogis.objects.all().delete()
        return HttpResponse('sad')

    def count(request, *args, **kwargs):
        return HttpResponse(len(Twogis.objects.all()))

    def distinct(request, *args, **kwargs):
        k = ''
        for name in Twogis.objects.order_by('oid').distinct('oid'):
            k += str(name.oid) + str(name.name) + str(name.address) + str(name
                .lat) + str(name.lon) + '<br>'
        return HttpResponse(str(len(Twogis.objects.order_by('oid').distinct
            ('oid'))) + '<br>' + k)

5db9d4966cd74736590334b25e3ed74a377cd985
<mask token>


class View(View):
    <mask token>

    def truncate(request, *args, **kwargs):
        Twogis.objects.all().delete()
        return HttpResponse('sad')

    def count(request, *args, **kwargs):
        return HttpResponse(len(Twogis.objects.all()))
    <mask token>

<mask token>


class View(View):
    <mask token>

    def truncate(request, *args, **kwargs):
        Twogis.objects.all().delete()
        return HttpResponse('sad')

    def count(request, *args, **kwargs):
        return HttpResponse(len(Twogis.objects.all()))

    def distinct(request, *args, **kwargs):
        k = ''
        for name in Twogis.objects.order_by('oid').distinct('oid'):
            k += str(name.oid) + str(name.name) + str(name.address) + str(name
                .lat) + str(name.lon) + '<br>'
        return HttpResponse(str(len(Twogis.objects.order_by('oid').distinct
            ('oid'))) + '<br>' + k)

<mask token>


class View(View):

    def parse(request, *args, **kwargs):
        response = HttpResponse(content_type='text/csv')
        response['Content-Disposition'
            ] = 'attachment; filename="somefilename.csv"'
        writer = csv.writer(response)
        writer.writerow(['oid', 'address', 'name', 'lat', 'lon'])
        twogiss = Twogis.objects.all()
        for twogis in twogiss:
            writer.writerow([twogis.oid, twogis.address, twogis.name,
                twogis.lat, twogis.lon])
        return response

    def truncate(request, *args, **kwargs):
        Twogis.objects.all().delete()
        return HttpResponse('sad')

    def count(request, *args, **kwargs):
        return HttpResponse(len(Twogis.objects.all()))

    def distinct(request, *args, **kwargs):
        k = ''
        for name in Twogis.objects.order_by('oid').distinct('oid'):
            k += str(name.oid) + str(name.name) + str(name.address) + str(name
                .lat) + str(name.lon) + '<br>'
        return HttpResponse(str(len(Twogis.objects.order_by('oid').distinct
            ('oid'))) + '<br>' + k)

import csv
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.base import View
import urllib.request
import json
from parser4.models import Twogis


class View(View):

    def parse(request, *args, **kwargs):
        response = HttpResponse(content_type='text/csv')
        response['Content-Disposition'
            ] = 'attachment; filename="somefilename.csv"'
        writer = csv.writer(response)
        writer.writerow(['oid', 'address', 'name', 'lat', 'lon'])
        twogiss = Twogis.objects.all()
        for twogis in twogiss:
            writer.writerow([twogis.oid, twogis.address, twogis.name,
                twogis.lat, twogis.lon])
        return response

    def truncate(request, *args, **kwargs):
        Twogis.objects.all().delete()
        return HttpResponse('sad')

    def count(request, *args, **kwargs):
        return HttpResponse(len(Twogis.objects.all()))

    def distinct(request, *args, **kwargs):
        k = ''
        for name in Twogis.objects.order_by('oid').distinct('oid'):
            k += str(name.oid) + str(name.name) + str(name.address) + str(name
                .lat) + str(name.lon) + '<br>'
        return HttpResponse(str(len(Twogis.objects.order_by('oid').distinct
            ('oid'))) + '<br>' + k)
