Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @csrf_exempt
- @http.json_response()
- def country(request):
- """
- Get countries
- """
- try:
- coun = Country.objects.all()
- except Country.DoesNotExist:
- raise Http404("country does not exist")
- return [item.full() for item in coun]
- class Country(models.Model):
- """
- """
- country_id = models.IntegerField()
- name = models.CharField(max_length=50)
- def full(self):
- obj = {
- "country":self.name,
- "country_id": self.country_id
- #"cities": self.cities
- }
- return obj
- def __unicode__(self):
- return self.name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement