I want to get region_name field values in my template.its .giving null value

On Sunday, November 6, 2022 at 8:31:42 PM UTC+5:30 [email protected] 
wrote:

> Pls write us your aim with this code...
>
> Kala Rani <[email protected]> schrieb am So., 6. Nov. 2022, 12:15:
>
>> my models.py
>>
>> class Locations(models.Model):
>> region = models.ForeignKey(Regions, 
>> on_delete=models.CASCADE,blank=True,null=True)
>> name = models.CharField(max_length=255)
>> active_flag = models.BooleanField(default=True)
>> created_at = models.DateTimeField(auto_now_add = True)
>> updated_at = models.DateTimeField(auto_now=True)
>>
>> def __str__(self):
>> return self.name
>>
>>
>> class Regions(models.Model):
>> region_name = models.CharField(max_length=255)
>> working_hours_per_day = models.CharField(max_length=255,null=True)
>> days_per_week = models.CharField(max_length=255,null=True)
>> hours_per_week = models.CharField(max_length=255,null=True)
>> week_per_month = models.CharField(max_length=255,null=True)
>> hours_per_month = models.CharField(max_length=255,null=True)
>> days_per_year = models.CharField(max_length=255,null=True)
>> weeks_per_year = models.CharField(max_length=255,null=True)
>> active_flag = models.BooleanField(default=True)
>> show_flag = models.BooleanField(default=True)
>> created_at = models.DateTimeField(auto_now_add = True)
>> updated_at = models.DateTimeField(auto_now=True)
>>
>> def __str__(self):
>> return self.region_name
>>
>>
>> views.py
>>
>> def center(request):
>> locations = Locations.objects.select_related('region')
>> td_serializer = LocationSerializer(locations,many=True)
>> x=td_serializer.data
>> data = {
>> 'td':td_serializer.data,
>> #'centers':center_serializer.data,
>> } 
>> return response.Response(data,status.HTTP_200_OK)
>>
>>
>>
>>
>> template:
>>
>> fetchLocationsList(){
>> this.$axios.$post('/projects/chcenter',config).then(response => {
>> if(response){
>> this.locations =response.td;
>> for(let i=0;i <this.locations.length; i++){
>> this.x=this.locations[i].name
>> this.y=this.locations[i].region
>> this.z=this.y + "-" +this.x
>> this.result.push(this.z)
>>
>>
>> How to get region_name ?
>>
>>
>>
>>
>> -- 
>> 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 [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3a93ef8a-4fc6-48a8-83d7-cc4ea65ae649n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/3a93ef8a-4fc6-48a8-83d7-cc4ea65ae649n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/18a95ad8-854a-4efb-bb2f-9ae3bda4ebe0n%40googlegroups.com.

Reply via email to