I have a model named "Name" which stores the list of all cities present in other model named "City". How can it be done internally in the views.py without using forms. Here is the code of models.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
class Detail(models.Model):
username = models.CharField(max_length=100)
password = models.CharField(max_length=100)
def __str__(self):
return str(self.username)
class City(models.Model):
userName = models.ForeignKey(Detail, blank=True, null=True)
city1 = models.CharField(max_length=100)
city2 = models.CharField(max_length=100)
city3 = models.CharField(max_length=100)
city4 = models.CharField(max_length=100)
city5 = models.CharField(max_length=100)
def __str__(self):
return "Id No:" + str(
self.pk)+" and Name: "+str(self.userName)
class Name(models.Model):
cityval=models.CharField(max_length=100)