Hi! Thanks for your response! I feel I have gone about this in a very odd 
way. I don't think that it is actually the answer but it works now. 
I am able to get the information out now without errors. What is your 
thought approaching it this way? Thank you for your time and help!
I am hoping that someone might be able to tell me a better way to do this:
 
Counter = aichatbox_response2.objects.filter().count()
for i in range(1,Counter+1):
        v = views_aichatbox_class
        n = nickname_aichatbox_class
        #i = image_url2_class
        r = response2_text_class
        a = aichatbox_input2_class
        p = pw_aichatbox_class
        l = link_aichatbox_class
        e = email_aichatbox_class
        if i == 1:
            v2 = str(v.objects.all()[:i])
            n2 = str(n.objects.all()[:i])
            #i2 = str(i.objects.all()[:i])
            #r2 = str(r.objects.all()[:i])
            a2 = str(a.objects.all()[:i])
            #p2 = str(p.objects.all()[:i])
            l2 = str(l.objects.all()[:i])
            e2 = str(e.objects.all()[:i])
        else:
            v2 = str(v.objects.all()[i-1:i])
            n2 = str(n.objects.all()[i-1:i])
            a2 = str(a.objects.all()[i-1:i])
            
            l2 = str(l.objects.all()[i-1:i])
            e2 = str(e.objects.all()[i-1:i])
    
        v2 = v2[35:len(v2)-3]
        n2 = n2[38:len(n2)-3]
        
        
        a2 = a2[36:len(a2)-3]
        
        l2 = l2[34:len(l2)-3]
        e2 = e2[35:len(e2)-3]

Best wishes,

Corey



On Wednesday, April 18, 2018 at 10:20:15 AM UTC-5, Derek wrote:
>
>
> You will need to gve an example of your struggles (witth code being used 
> to pull info, and with error traces) before we can help; all you have shown 
> is model code. 
>
> On Sunday, 15 April 2018 05:55:21 UTC+2, coreyj...@gmail.com wrote:
>>
>> Dear all,
>>
>> I am really struggling with pulling information out of a class object. I 
>> have tried doing this with FK field, proxy models (shown below as I feel 
>> this is the closest to working), etc. and cannot get it to work. I cannot 
>> pull the information from my database. I would greatly appreciate help. 
>> What I want is to have access to all of these fields independently. I feel 
>> like what I have should work but I cannot get the information out of my 
>> proxy models (shown below). I see what I want in the admin, however. How 
>> can I get the information out independently? 
>>
>> class aichatbox_input2(models.Model):    
>>     aichatbox_input2_text = models.CharField(max_length=2000) 
>>     def __str__(self):
>>         return self.aichatbox_input2_text
>>
>>
>> class aichatbox_response2(models.Model):    
>>     image_url2 =models.CharField(max_length=1000, default='https://www.
>> ') 
>>     response2_text = models.CharField(max_length=1000) 
>>     aichatbox_response_input2 = models.ManyToManyField(aichatbox_input2)  
>>     views_aichatbox = models.IntegerField(default=0)
>>     pw_aichatbox = models.CharField(max_length=12, default='000000')
>>     link_aichatbox = models.CharField(max_length=250, default='None')
>>     nickname_aichatbox = models.CharField(max_length=100, 
>> default='Pseudonym')
>>     email_aichatbox = models.EmailField(max_length=100, default='
>> bl...@blank.com')
>>
>>     
>>
>>     def __str__(self):
>>      
>>         return u'%s %s' % (self.response2_text, self.image_url2) 
>>   
>> class image_url2_class(aichatbox_response2):
>>     class Meta:
>>         proxy = True
>>     def __str__(self):
>>         return self.image_url2
>>
>> class response2_text_class(aichatbox_response2):
>>     class Meta:
>>         proxy = True
>>     def __str__(self):
>>         return self.response2_text
>>
>> class aichatbox_response_input2_class(aichatbox_response2):
>>     class Meta:
>>         proxy = True
>>     def __str__(self):
>>         return self.aichatbox_response_input2
>>
>> class views_aichatbox_class(aichatbox_response2):     
>>     class Meta:
>>         proxy = True
>>     
>>     def __str__(self):
>>         return str(self.views_aichatbox)            # is it best to have 
>> this be str() here? I don't know of a better way to do this...
>>
>> class pw_aichatbox_class(aichatbox_response2):
>>     class Meta:
>>         proxy = True
>>     def __int__(self):
>>         return self.pw_aichatbox
>>
>> class link_aichatbox_class(aichatbox_response2):
>>     class Meta:
>>         proxy = True
>>     def __str__(self):
>>         return self.link_aichatbox
>>
>> class nickname_aichatbox_class(aichatbox_response2):
>>     class Meta:
>>         proxy = True
>>     def __str__(self):
>>         return self.nickname_aichatbox
>>
>> class email_aichatbox_class(aichatbox_response2):
>>     class Meta:
>>         proxy = True
>>     def __str__(self):
>>         return self.email_aichatbox
>>
>>

-- 
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+unsubscr...@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/a71419d2-0dfc-42e0-a608-144521e14b97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to