Pls write us your aim with this code...
Kala Rani <ranimca28@gmail.com> schrieb am So., 6. Nov. 2022, 12:15:
my models.pyclass 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.nameclass 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_nameviews.pydef center(request):locations = Locations.objects.select_related('region')td_serializer = LocationSerializer(locations,many=True)x=td_serializer.datadata = {'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].namethis.y=this.locations[i].regionthis.z=this.y + "-" +this.xthis.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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a93ef8a-4fc6-48a8-83d7-cc4ea65ae649n%40googlegroups.com.
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKGT9mx36UHjRWOTJcg586ph6JHMRmFxZ_8mSrtCw%2B0fMdoPyA%40mail.gmail.com.
No comments:
Post a Comment