Hi Mitul,
Can you clarify a little bit more your question?
What are you trying to resolve?
You asked: "How it will be done...?" It is not clear what exactly you are trying to be done.
I guess that it my be saving cities into model 'cityval' fields. Am I correct?
If so you can do something like that:
Name(cityval=''.join([city.city1, city.city2, ...])).save()
Regards,
Constantine C.
On Sat, Sep 30, 2017 at 5:39 AM, Mitul Tyagi <mitultyagi45@gmail.com> wrote:
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_literalsfrom django.db import modelsclass 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) "
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5d83ea00- .e613-4b86-830f-262b1db4ce99% 40googlegroups.com
For more options, visit https://groups.google.com/d/optout .
Sincerely yours,
Constantine C
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK52boUvLwA4yELOr%3D%3DVqQJrT7G_n9-%3Dq%2Bqcutu%3DUrdDXf_GFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment