Re: Trying to render images from database

2023-03-10 Thread Michael Starr
I don't understand what you mean. There are no images. There's no img src 
except in code. I can't just right click on it because it's not there.

And I know the src of the image, because I'm the one who coded it. Also it 
spits it out when I print the coded url. This was all in a previous post in 
this thread.

On Tuesday, March 7, 2023 at 4:09:04 PM UTC-8 Red Plant wrote:

> If not, check each img src using your browser's dev tools.
>
> On Wed, Mar 8, 2023 at 8:07 AM Red Plant  wrote:
>
>> Have you checked each img src?
>>
>> On Wed, Mar 8, 2023 at 6:17 AM Michael Starr  wrote:
>>
>>> I am using FireFox.
>>>
>>> On Tuesday, March 7, 2023 at 2:11:38 PM UTC-8 Michael Starr wrote:
>>>
 this.window.gBrowserInit is undefined ext-browser.js:1134
 get activeTab chrome://browser/content/parent/ext-browser.js:1134
 candidates chrome://extensions/content/parent/ext-tabs-base.js:2091
 next self-hosted:1743
 query chrome://extensions/content/parent/ext-tabs-base.js:2113
 next self-hosted:1743
 from self-hosted:516
 query chrome://browser/content/parent/ext-tabs.js:1000
 query self-hosted:1359
 result resource://gre/modules/ExtensionParent.jsm:1156
 withCallContextData resource://gre/modules/ExtensionParent.jsm:639
 result resource://gre/modules/ExtensionParent.jsm:1155
 withPendingBrowser resource://gre/modules/ExtensionParent.jsm:649
 result resource://gre/modules/ExtensionParent.jsm:1154
 callAndLog resource://gre/modules/ExtensionParent.jsm:1107
 recvAPICall resource://gre/modules/ExtensionParent.jsm:1153
 AsyncFunctionNext self-hosted:810


 On Tuesday, March 7, 2023 at 1:58:12 PM UTC-8 Red Plant wrote:

> What's showing on the browser console?
>
> If you're using chrome, press F12 to open developer tools, then find 
> the console tab.
>
> On Wed, Mar 8, 2023, 1:31 AM Michael Starr  wrote:
>
>> Well, my privilege of posting "" on SO was revoked so I can't get my 
>> questions answered anymore. So I guess I just won't be a developer now. 
>> Or 
>> the alternative, reinvent all code and the internet.
>> The answer the dude gave me wasn't sufficient and he was like, 
>> "Accept the answer!" Devious prick. And then he was like "share your 
>> code 
>> with me!" And what he does is copy your code into his github account and 
>> claim he "helped" you.
>> Blah. What a loser.
>> So anyway, it still shows img alt text BUT now when I upload a photo 
>> into the pet_photo object, it appends a six digit ASCII text thingy to 
>> the 
>> filename, so the filename isn't actually correct even, anymore.
>> So many problems. Django is NOT the api for perfectionists with 
>> deadlines.
>> Mike
>>
>> On Saturday, March 4, 2023 at 3:31:30 PM UTC-8 Michael Starr wrote:
>>
>>> Thank you Sandip. I missed that.
>>>
>>> In any case I have revamped the code with some help from stack 
>>> overflow here 
>>> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>>> However the image alt text instead of the image displays! So weird! 
>>>
>>> class PetOwnerDetailView(DetailView):
>>> model = PetOwner
>>> context_object_name = "owner"
>>> template_name = "pet_owner_profile.html"
>>> def get_context_data(self, *args, **kwargs):
>>> context = super().get_context_data(**kwargs)
>>> pets = Pet.objects.all()
>>> pet_data = {}
>>> for pet in pets:
>>> pet_data[pet] = PetPhoto.objects.filter(pets=pet)
>>> context['pet_data'] = pet_data
>>> return context
>>>
>>> {% extends "base.html" %}
>>> {% block header %}
>>> {% endblock %}
>>> {% block content %}
>>> {{ owner.name }}
>>> {{ owner.age }}
>>> {{ owner.location }}
>>> {{ owner.profile_photo }}
>>> {% for pet in owner.pets.all %}
>>> {{ pet.name }}
>>> {{ pet.animaltype }}
>>> {{ pet.age }}
>>> 
>>> {{ pet.name }} Photos
>>> {% for pet, photos in pet_data.items %}
>>> {{ pet.name }}
>>> {% for photo in photos %}
>>> 
>>> {% endfor %}
>>> {% endfor %}
>>> {% endfor %}
>>> {% endblock %}
>>>
>>> [image: Screenshot 2023-03-04 153038.png]
>>>
>>> So close yet so far! Argh! lol
>>>
>>> Mike
>>>
>>> On Saturday, March 4, 2023 at 1:37:26 AM UTC-8 Sandip Bhattacharya 
>>> wrote:
>>>
 Are you sure this is the right query? This is looking for pet 
 owners with the name “pets”. 

 pets = PetOwner.objects.filter(name = "pets”) 

 Perhaps, you mean: 
 pets 

Re: Trying to render images from database

2023-03-07 Thread Michael Starr
I am using FireFox.

On Tuesday, March 7, 2023 at 2:11:38 PM UTC-8 Michael Starr wrote:

> this.window.gBrowserInit is undefined ext-browser.js:1134
> get activeTab chrome://browser/content/parent/ext-browser.js:1134
> candidates chrome://extensions/content/parent/ext-tabs-base.js:2091
> next self-hosted:1743
> query chrome://extensions/content/parent/ext-tabs-base.js:2113
> next self-hosted:1743
> from self-hosted:516
> query chrome://browser/content/parent/ext-tabs.js:1000
> query self-hosted:1359
> result resource://gre/modules/ExtensionParent.jsm:1156
> withCallContextData resource://gre/modules/ExtensionParent.jsm:639
> result resource://gre/modules/ExtensionParent.jsm:1155
> withPendingBrowser resource://gre/modules/ExtensionParent.jsm:649
> result resource://gre/modules/ExtensionParent.jsm:1154
> callAndLog resource://gre/modules/ExtensionParent.jsm:1107
> recvAPICall resource://gre/modules/ExtensionParent.jsm:1153
> AsyncFunctionNext self-hosted:810
>
>
> On Tuesday, March 7, 2023 at 1:58:12 PM UTC-8 Red Plant wrote:
>
>> What's showing on the browser console?
>>
>> If you're using chrome, press F12 to open developer tools, then find the 
>> console tab.
>>
>> On Wed, Mar 8, 2023, 1:31 AM Michael Starr  wrote:
>>
>>> Well, my privilege of posting "" on SO was revoked so I can't get my 
>>> questions answered anymore. So I guess I just won't be a developer now. Or 
>>> the alternative, reinvent all code and the internet.
>>> The answer the dude gave me wasn't sufficient and he was like, "Accept 
>>> the answer!" Devious prick. And then he was like "share your code with me!" 
>>> And what he does is copy your code into his github account and claim he 
>>> "helped" you.
>>> Blah. What a loser.
>>> So anyway, it still shows img alt text BUT now when I upload a photo 
>>> into the pet_photo object, it appends a six digit ASCII text thingy to the 
>>> filename, so the filename isn't actually correct even, anymore.
>>> So many problems. Django is NOT the api for perfectionists with 
>>> deadlines.
>>> Mike
>>>
>>> On Saturday, March 4, 2023 at 3:31:30 PM UTC-8 Michael Starr wrote:
>>>
 Thank you Sandip. I missed that.

 In any case I have revamped the code with some help from stack overflow 
 here 
 https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
 However the image alt text instead of the image displays! So weird! 

 class PetOwnerDetailView(DetailView):
 model = PetOwner
 context_object_name = "owner"
 template_name = "pet_owner_profile.html"
 def get_context_data(self, *args, **kwargs):
 context = super().get_context_data(**kwargs)
 pets = Pet.objects.all()
 pet_data = {}
 for pet in pets:
 pet_data[pet] = PetPhoto.objects.filter(pets=pet)
 context['pet_data'] = pet_data
 return context

 {% extends "base.html" %}
 {% block header %}
 {% endblock %}
 {% block content %}
 {{ owner.name }}
 {{ owner.age }}
 {{ owner.location }}
 {{ owner.profile_photo }}
 {% for pet in owner.pets.all %}
 {{ pet.name }}
 {{ pet.animaltype }}
 {{ pet.age }}
 
 {{ pet.name }} Photos
 {% for pet, photos in pet_data.items %}
 {{ pet.name }}
 {% for photo in photos %}
 
 {% endfor %}
 {% endfor %}
 {% endfor %}
 {% endblock %}

 [image: Screenshot 2023-03-04 153038.png]

 So close yet so far! Argh! lol

 Mike

 On Saturday, March 4, 2023 at 1:37:26 AM UTC-8 Sandip Bhattacharya 
 wrote:

> Are you sure this is the right query? This is looking for pet owners 
> with the name “pets”. 
>
> pets = PetOwner.objects.filter(name = "pets”) 
>
> Perhaps, you mean: 
> pets = PetOwner.pets.all() 
>
> - Sandip 
>
> > On Mar 3, 2023, at 8:08 PM, Michael Starr  
> wrote: 
> > 
> > I think this solution 
> > 
> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>  
> > should work but for some reason python got messed up on my laptop 
> when I went mobile at the coffee shop. The PYTHONPATH got deleted the 
> .venv 
> environment was deleted but still displayed and I'm getting a ton of 
> system 
> bugs trying to run python makemigrations or python migrate. 
> > 
> > Frustrating. I am using the python repair tool in the python 
> installer to repair python. Will let you know if the solution works after 
> I 
> get my environment back up and workin.g 
> > On Friday, March 3, 2023 at 2:01:03 PM UTC-8 Michael Starr wrote: 
> > It's not working. 
> > class 

Re: Trying to render images from database

2023-03-07 Thread Michael Starr
this.window.gBrowserInit is undefined ext-browser.js:1134
get activeTab chrome://browser/content/parent/ext-browser.js:1134
candidates chrome://extensions/content/parent/ext-tabs-base.js:2091
next self-hosted:1743
query chrome://extensions/content/parent/ext-tabs-base.js:2113
next self-hosted:1743
from self-hosted:516
query chrome://browser/content/parent/ext-tabs.js:1000
query self-hosted:1359
result resource://gre/modules/ExtensionParent.jsm:1156
withCallContextData resource://gre/modules/ExtensionParent.jsm:639
result resource://gre/modules/ExtensionParent.jsm:1155
withPendingBrowser resource://gre/modules/ExtensionParent.jsm:649
result resource://gre/modules/ExtensionParent.jsm:1154
callAndLog resource://gre/modules/ExtensionParent.jsm:1107
recvAPICall resource://gre/modules/ExtensionParent.jsm:1153
AsyncFunctionNext self-hosted:810


On Tuesday, March 7, 2023 at 1:58:12 PM UTC-8 Red Plant wrote:

> What's showing on the browser console?
>
> If you're using chrome, press F12 to open developer tools, then find the 
> console tab.
>
> On Wed, Mar 8, 2023, 1:31 AM Michael Starr  wrote:
>
>> Well, my privilege of posting "" on SO was revoked so I can't get my 
>> questions answered anymore. So I guess I just won't be a developer now. Or 
>> the alternative, reinvent all code and the internet.
>> The answer the dude gave me wasn't sufficient and he was like, "Accept 
>> the answer!" Devious prick. And then he was like "share your code with me!" 
>> And what he does is copy your code into his github account and claim he 
>> "helped" you.
>> Blah. What a loser.
>> So anyway, it still shows img alt text BUT now when I upload a photo into 
>> the pet_photo object, it appends a six digit ASCII text thingy to the 
>> filename, so the filename isn't actually correct even, anymore.
>> So many problems. Django is NOT the api for perfectionists with deadlines.
>> Mike
>>
>> On Saturday, March 4, 2023 at 3:31:30 PM UTC-8 Michael Starr wrote:
>>
>>> Thank you Sandip. I missed that.
>>>
>>> In any case I have revamped the code with some help from stack overflow 
>>> here 
>>> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>>> However the image alt text instead of the image displays! So weird! 
>>>
>>> class PetOwnerDetailView(DetailView):
>>> model = PetOwner
>>> context_object_name = "owner"
>>> template_name = "pet_owner_profile.html"
>>> def get_context_data(self, *args, **kwargs):
>>> context = super().get_context_data(**kwargs)
>>> pets = Pet.objects.all()
>>> pet_data = {}
>>> for pet in pets:
>>> pet_data[pet] = PetPhoto.objects.filter(pets=pet)
>>> context['pet_data'] = pet_data
>>> return context
>>>
>>> {% extends "base.html" %}
>>> {% block header %}
>>> {% endblock %}
>>> {% block content %}
>>> {{ owner.name }}
>>> {{ owner.age }}
>>> {{ owner.location }}
>>> {{ owner.profile_photo }}
>>> {% for pet in owner.pets.all %}
>>> {{ pet.name }}
>>> {{ pet.animaltype }}
>>> {{ pet.age }}
>>> 
>>> {{ pet.name }} Photos
>>> {% for pet, photos in pet_data.items %}
>>> {{ pet.name }}
>>> {% for photo in photos %}
>>> >> >
>>> {% endfor %}
>>> {% endfor %}
>>> {% endfor %}
>>> {% endblock %}
>>>
>>> [image: Screenshot 2023-03-04 153038.png]
>>>
>>> So close yet so far! Argh! lol
>>>
>>> Mike
>>>
>>> On Saturday, March 4, 2023 at 1:37:26 AM UTC-8 Sandip Bhattacharya wrote:
>>>
 Are you sure this is the right query? This is looking for pet owners 
 with the name “pets”. 

 pets = PetOwner.objects.filter(name = "pets”) 

 Perhaps, you mean: 
 pets = PetOwner.pets.all() 

 - Sandip 

 > On Mar 3, 2023, at 8:08 PM, Michael Starr  
 wrote: 
 > 
 > I think this solution 
 > 
 https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
  
 > should work but for some reason python got messed up on my laptop 
 when I went mobile at the coffee shop. The PYTHONPATH got deleted the 
 .venv 
 environment was deleted but still displayed and I'm getting a ton of 
 system 
 bugs trying to run python makemigrations or python migrate. 
 > 
 > Frustrating. I am using the python repair tool in the python 
 installer to repair python. Will let you know if the solution works after 
 I 
 get my environment back up and workin.g 
 > On Friday, March 3, 2023 at 2:01:03 PM UTC-8 Michael Starr wrote: 
 > It's not working. 
 > class PetOwnerDetailView(DetailView): 
 > model = PetOwner 
 > context_object_name = "owner" 
 > template_name = "pet_owner_profile.html" 
 > def get_context_data(self, *args, **kwargs): 
 > context = super().get_context_data(**kwargs) 

Re: Trying to render images from database

2023-03-07 Thread Red Plant
What's showing on the browser console?

If you're using chrome, press F12 to open developer tools, then find the
console tab.

On Wed, Mar 8, 2023, 1:31 AM Michael Starr  wrote:

> Well, my privilege of posting "" on SO was revoked so I can't get my
> questions answered anymore. So I guess I just won't be a developer now. Or
> the alternative, reinvent all code and the internet.
> The answer the dude gave me wasn't sufficient and he was like, "Accept the
> answer!" Devious prick. And then he was like "share your code with me!" And
> what he does is copy your code into his github account and claim he
> "helped" you.
> Blah. What a loser.
> So anyway, it still shows img alt text BUT now when I upload a photo into
> the pet_photo object, it appends a six digit ASCII text thingy to the
> filename, so the filename isn't actually correct even, anymore.
> So many problems. Django is NOT the api for perfectionists with deadlines.
> Mike
>
> On Saturday, March 4, 2023 at 3:31:30 PM UTC-8 Michael Starr wrote:
>
>> Thank you Sandip. I missed that.
>>
>> In any case I have revamped the code with some help from stack overflow
>> here
>> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>> However the image alt text instead of the image displays! So weird!
>>
>> class PetOwnerDetailView(DetailView):
>> model = PetOwner
>> context_object_name = "owner"
>> template_name = "pet_owner_profile.html"
>> def get_context_data(self, *args, **kwargs):
>> context = super().get_context_data(**kwargs)
>> pets = Pet.objects.all()
>> pet_data = {}
>> for pet in pets:
>> pet_data[pet] = PetPhoto.objects.filter(pets=pet)
>> context['pet_data'] = pet_data
>> return context
>>
>> {% extends "base.html" %}
>> {% block header %}
>> {% endblock %}
>> {% block content %}
>> {{ owner.name }}
>> {{ owner.age }}
>> {{ owner.location }}
>> {{ owner.profile_photo }}
>> {% for pet in owner.pets.all %}
>> {{ pet.name }}
>> {{ pet.animaltype }}
>> {{ pet.age }}
>> 
>> {{ pet.name }} Photos
>> {% for pet, photos in pet_data.items %}
>> {{ pet.name }}
>> {% for photo in photos %}
>> 
>> {% endfor %}
>> {% endfor %}
>> {% endfor %}
>> {% endblock %}
>>
>> [image: Screenshot 2023-03-04 153038.png]
>>
>> So close yet so far! Argh! lol
>>
>> Mike
>>
>> On Saturday, March 4, 2023 at 1:37:26 AM UTC-8 Sandip Bhattacharya wrote:
>>
>>> Are you sure this is the right query? This is looking for pet owners
>>> with the name “pets”.
>>>
>>> pets = PetOwner.objects.filter(name = "pets”)
>>>
>>> Perhaps, you mean:
>>> pets = PetOwner.pets.all()
>>>
>>> - Sandip
>>>
>>> > On Mar 3, 2023, at 8:08 PM, Michael Starr  wrote:
>>> >
>>> > I think this solution
>>> >
>>> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>>> > should work but for some reason python got messed up on my laptop when
>>> I went mobile at the coffee shop. The PYTHONPATH got deleted the .venv
>>> environment was deleted but still displayed and I'm getting a ton of system
>>> bugs trying to run python makemigrations or python migrate.
>>> >
>>> > Frustrating. I am using the python repair tool in the python installer
>>> to repair python. Will let you know if the solution works after I get my
>>> environment back up and workin.g
>>> > On Friday, March 3, 2023 at 2:01:03 PM UTC-8 Michael Starr wrote:
>>> > It's not working.
>>> > class PetOwnerDetailView(DetailView):
>>> > model = PetOwner
>>> > context_object_name = "owner"
>>> > template_name = "pet_owner_profile.html"
>>> > def get_context_data(self, *args, **kwargs):
>>> > context = super().get_context_data(**kwargs)
>>> > context['pet_photos'] = {}
>>> > pets = PetOwner.objects.filter(name = "pets")
>>> > for pet in pets:
>>> > context['pet_photos'][pet] = []
>>> > for photo in pet.pet_photos:
>>> > context['pet_photos'][pet] += photo
>>> > # context['pet_photos'] = {pet1: [photo1, photo2, photo3], pet2:
>>> [photo1, photo2]}
>>> > return context
>>> >
>>> > {% extends "base.html" %}
>>> > {% block header %}
>>> > {% endblock %}
>>> > {% block content %}
>>> > {{ owner.name }}
>>> > {{ owner.age }}
>>> > {{ owner.location }}
>>> > {{ owner.profile_photo }}
>>> > {% for pet in owner.pets.all %}
>>> > {{ pet.name }}
>>> > {{ pet.animaltype }}
>>> > {{ pet.age }}
>>> > 
>>> > {% for photo in pet_photos.pet.photos %}
>>> > 
>>> > {% endfor %}
>>> > {% endfor %}
>>> > {% endblock %}
>>> >
>>> >
>>> > Nothing shows up. I've tried a million and a half ways to iterate over
>>> the data structure I've created to store pets as keys and photos in a list
>>> as values in get_context_data for 'pet_photos' but nothing ever displays.
>>> >
>>> > Then there's the question of like, are my directory structure and
>>> settings file correct.
>>> >
>>> > STATIC_URL = 

Re: Trying to render images from database

2023-03-07 Thread Michael Starr
this https://docs.djangoproject.com/en/4.1/topics/files/ seems useful, but 
isn't really for me.
Mike

On Tuesday, March 7, 2023 at 9:31:02 AM UTC-8 Michael Starr wrote:

> Well, my privilege of posting "" on SO was revoked so I can't get my 
> questions answered anymore. So I guess I just won't be a developer now. Or 
> the alternative, reinvent all code and the internet.
> The answer the dude gave me wasn't sufficient and he was like, "Accept the 
> answer!" Devious prick. And then he was like "share your code with me!" And 
> what he does is copy your code into his github account and claim he 
> "helped" you.
> Blah. What a loser.
> So anyway, it still shows img alt text BUT now when I upload a photo into 
> the pet_photo object, it appends a six digit ASCII text thingy to the 
> filename, so the filename isn't actually correct even, anymore.
> So many problems. Django is NOT the api for perfectionists with deadlines.
> Mike
>
> On Saturday, March 4, 2023 at 3:31:30 PM UTC-8 Michael Starr wrote:
>
>> Thank you Sandip. I missed that.
>>
>> In any case I have revamped the code with some help from stack overflow 
>> here 
>> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>> However the image alt text instead of the image displays! So weird! 
>>
>> class PetOwnerDetailView(DetailView):
>> model = PetOwner
>> context_object_name = "owner"
>> template_name = "pet_owner_profile.html"
>> def get_context_data(self, *args, **kwargs):
>> context = super().get_context_data(**kwargs)
>> pets = Pet.objects.all()
>> pet_data = {}
>> for pet in pets:
>> pet_data[pet] = PetPhoto.objects.filter(pets=pet)
>> context['pet_data'] = pet_data
>> return context
>>
>> {% extends "base.html" %}
>> {% block header %}
>> {% endblock %}
>> {% block content %}
>> {{ owner.name }}
>> {{ owner.age }}
>> {{ owner.location }}
>> {{ owner.profile_photo }}
>> {% for pet in owner.pets.all %}
>> {{ pet.name }}
>> {{ pet.animaltype }}
>> {{ pet.age }}
>> 
>> {{ pet.name }} Photos
>> {% for pet, photos in pet_data.items %}
>> {{ pet.name }}
>> {% for photo in photos %}
>> 
>> {% endfor %}
>> {% endfor %}
>> {% endfor %}
>> {% endblock %}
>>
>> [image: Screenshot 2023-03-04 153038.png]
>>
>> So close yet so far! Argh! lol
>>
>> Mike
>>
>> On Saturday, March 4, 2023 at 1:37:26 AM UTC-8 Sandip Bhattacharya wrote:
>>
>>> Are you sure this is the right query? This is looking for pet owners 
>>> with the name “pets”. 
>>>
>>> pets = PetOwner.objects.filter(name = "pets”) 
>>>
>>> Perhaps, you mean: 
>>> pets = PetOwner.pets.all() 
>>>
>>> - Sandip 
>>>
>>> > On Mar 3, 2023, at 8:08 PM, Michael Starr  wrote: 
>>> > 
>>> > I think this solution 
>>> > 
>>> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>>>  
>>> > should work but for some reason python got messed up on my laptop when 
>>> I went mobile at the coffee shop. The PYTHONPATH got deleted the .venv 
>>> environment was deleted but still displayed and I'm getting a ton of system 
>>> bugs trying to run python makemigrations or python migrate. 
>>> > 
>>> > Frustrating. I am using the python repair tool in the python installer 
>>> to repair python. Will let you know if the solution works after I get my 
>>> environment back up and workin.g 
>>> > On Friday, March 3, 2023 at 2:01:03 PM UTC-8 Michael Starr wrote: 
>>> > It's not working. 
>>> > class PetOwnerDetailView(DetailView): 
>>> > model = PetOwner 
>>> > context_object_name = "owner" 
>>> > template_name = "pet_owner_profile.html" 
>>> > def get_context_data(self, *args, **kwargs): 
>>> > context = super().get_context_data(**kwargs) 
>>> > context['pet_photos'] = {} 
>>> > pets = PetOwner.objects.filter(name = "pets") 
>>> > for pet in pets: 
>>> > context['pet_photos'][pet] = [] 
>>> > for photo in pet.pet_photos: 
>>> > context['pet_photos'][pet] += photo 
>>> > # context['pet_photos'] = {pet1: [photo1, photo2, photo3], pet2: 
>>> [photo1, photo2]} 
>>> > return context 
>>> > 
>>> > {% extends "base.html" %} 
>>> > {% block header %} 
>>> > {% endblock %} 
>>> > {% block content %} 
>>> > {{ owner.name }} 
>>> > {{ owner.age }} 
>>> > {{ owner.location }} 
>>> > {{ owner.profile_photo }} 
>>> > {% for pet in owner.pets.all %} 
>>> > {{ pet.name }} 
>>> > {{ pet.animaltype }} 
>>> > {{ pet.age }} 
>>> >  
>>> > {% for photo in pet_photos.pet.photos %} 
>>> >  
>>> > {% endfor %} 
>>> > {% endfor %} 
>>> > {% endblock %} 
>>> > 
>>> > 
>>> > Nothing shows up. I've tried a million and a half ways to iterate over 
>>> the data structure I've created to store pets as keys and photos in a list 
>>> as values in get_context_data for 'pet_photos' but nothing ever displays. 
>>> > 
>>> > Then there's the question of like, are my directory 

Re: Trying to render images from database

2023-03-07 Thread Michael Starr
Well, my privilege of posting "" on SO was revoked so I can't get my 
questions answered anymore. So I guess I just won't be a developer now. Or 
the alternative, reinvent all code and the internet.
The answer the dude gave me wasn't sufficient and he was like, "Accept the 
answer!" Devious prick. And then he was like "share your code with me!" And 
what he does is copy your code into his github account and claim he 
"helped" you.
Blah. What a loser.
So anyway, it still shows img alt text BUT now when I upload a photo into 
the pet_photo object, it appends a six digit ASCII text thingy to the 
filename, so the filename isn't actually correct even, anymore.
So many problems. Django is NOT the api for perfectionists with deadlines.
Mike

On Saturday, March 4, 2023 at 3:31:30 PM UTC-8 Michael Starr wrote:

> Thank you Sandip. I missed that.
>
> In any case I have revamped the code with some help from stack overflow 
> here 
> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
> However the image alt text instead of the image displays! So weird! 
>
> class PetOwnerDetailView(DetailView):
> model = PetOwner
> context_object_name = "owner"
> template_name = "pet_owner_profile.html"
> def get_context_data(self, *args, **kwargs):
> context = super().get_context_data(**kwargs)
> pets = Pet.objects.all()
> pet_data = {}
> for pet in pets:
> pet_data[pet] = PetPhoto.objects.filter(pets=pet)
> context['pet_data'] = pet_data
> return context
>
> {% extends "base.html" %}
> {% block header %}
> {% endblock %}
> {% block content %}
> {{ owner.name }}
> {{ owner.age }}
> {{ owner.location }}
> {{ owner.profile_photo }}
> {% for pet in owner.pets.all %}
> {{ pet.name }}
> {{ pet.animaltype }}
> {{ pet.age }}
> 
> {{ pet.name }} Photos
> {% for pet, photos in pet_data.items %}
> {{ pet.name }}
> {% for photo in photos %}
> 
> {% endfor %}
> {% endfor %}
> {% endfor %}
> {% endblock %}
>
> [image: Screenshot 2023-03-04 153038.png]
>
> So close yet so far! Argh! lol
>
> Mike
>
> On Saturday, March 4, 2023 at 1:37:26 AM UTC-8 Sandip Bhattacharya wrote:
>
>> Are you sure this is the right query? This is looking for pet owners with 
>> the name “pets”. 
>>
>> pets = PetOwner.objects.filter(name = "pets”) 
>>
>> Perhaps, you mean: 
>> pets = PetOwner.pets.all() 
>>
>> - Sandip 
>>
>> > On Mar 3, 2023, at 8:08 PM, Michael Starr  wrote: 
>> > 
>> > I think this solution 
>> > 
>> https://stackoverflow.com/questions/75632266/displaying-an-image-stored-in-a-django-database
>>  
>> > should work but for some reason python got messed up on my laptop when 
>> I went mobile at the coffee shop. The PYTHONPATH got deleted the .venv 
>> environment was deleted but still displayed and I'm getting a ton of system 
>> bugs trying to run python makemigrations or python migrate. 
>> > 
>> > Frustrating. I am using the python repair tool in the python installer 
>> to repair python. Will let you know if the solution works after I get my 
>> environment back up and workin.g 
>> > On Friday, March 3, 2023 at 2:01:03 PM UTC-8 Michael Starr wrote: 
>> > It's not working. 
>> > class PetOwnerDetailView(DetailView): 
>> > model = PetOwner 
>> > context_object_name = "owner" 
>> > template_name = "pet_owner_profile.html" 
>> > def get_context_data(self, *args, **kwargs): 
>> > context = super().get_context_data(**kwargs) 
>> > context['pet_photos'] = {} 
>> > pets = PetOwner.objects.filter(name = "pets") 
>> > for pet in pets: 
>> > context['pet_photos'][pet] = [] 
>> > for photo in pet.pet_photos: 
>> > context['pet_photos'][pet] += photo 
>> > # context['pet_photos'] = {pet1: [photo1, photo2, photo3], pet2: 
>> [photo1, photo2]} 
>> > return context 
>> > 
>> > {% extends "base.html" %} 
>> > {% block header %} 
>> > {% endblock %} 
>> > {% block content %} 
>> > {{ owner.name }} 
>> > {{ owner.age }} 
>> > {{ owner.location }} 
>> > {{ owner.profile_photo }} 
>> > {% for pet in owner.pets.all %} 
>> > {{ pet.name }} 
>> > {{ pet.animaltype }} 
>> > {{ pet.age }} 
>> >  
>> > {% for photo in pet_photos.pet.photos %} 
>> >  
>> > {% endfor %} 
>> > {% endfor %} 
>> > {% endblock %} 
>> > 
>> > 
>> > Nothing shows up. I've tried a million and a half ways to iterate over 
>> the data structure I've created to store pets as keys and photos in a list 
>> as values in get_context_data for 'pet_photos' but nothing ever displays. 
>> > 
>> > Then there's the question of like, are my directory structure and 
>> settings file correct. 
>> > 
>> > STATIC_URL = '/static/' 
>> > STATIC_ROOT = os.path.join(BASE_DIR, 'static/') 
>> > 
>> > pet_memorial/static/ is the file path. I don't know if that's right or 
>> it needs to be in the project sub-directory. It's impossible to figure this 
>> out online. No one explains 

Trying to render images from database

2023-03-03 Thread Michael Starr
It's not working.
class PetOwnerDetailView(DetailView):
model = PetOwner
context_object_name = "owner"
template_name = "pet_owner_profile.html"
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
context['pet_photos'] = {}
pets = PetOwner.objects.filter(name = "pets")
for pet in pets:
context['pet_photos'][pet] = []
for photo in pet.pet_photos:
context['pet_photos'][pet] += photo
# context['pet_photos'] = {pet1: [photo1, photo2, photo3], pet2: 
[photo1, photo2]}
return context

{% extends "base.html" %}
{% block header %}
{% endblock %}
{% block content %}
{{ owner.name }}
{{ owner.age }}
{{ owner.location }}
{{ owner.profile_photo }}
{% for pet in owner.pets.all %}
{{ pet.name }}
{{ pet.animaltype }}
{{ pet.age }}

{% for photo in pet_photos.pet.photos %}

{% endfor %}
{% endfor %}
{% endblock %}


Nothing shows up. I've tried a million and a half ways to iterate over the 
data structure I've created to store pets as keys and photos in a list as 
values in get_context_data for 'pet_photos' but nothing ever displays.

Then there's the question of like, are my directory structure and settings 
file correct.

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

pet_memorial/static/ is the file path. I don't know if that's right or it 
needs to be in the project sub-directory. It's impossible to figure this 
out online. No one explains these simple simple things CLEARLY.

So frustrating.

Michael



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/df428834-55c9-4657-b734-e300d55929fdn%40googlegroups.com.