Re: Difficulty Rendering a Form

2023-05-17 Thread Michael Starr
I disagree. I think it's a mess. Also I'm banned from youtube for posting 
spoken word poems.

Thank you for being useless.

Mike

On Tuesday, May 16, 2023 at 12:06:23 PM UTC-7 Ammar Mohammed wrote:

> Hi Mr Starr
> The documentation is very clear and helpful. 
> Check the forms section 
>
> https://docs.djangoproject.com/en/4.2/ref/forms/api/#outputting-forms-as-html
>
> Note that you should put your form variable in a double curly Like 
> this :
>
> 
> {{ signup_form }}
> <\form>
>
> Regards 
> Ammar Mohammed 
> Whatsapp: 
> wa.me/249113075979 
>
>
>
> On Tue, May 16, 2023, 20:55 Michael Starr  wrote:
>
>> I am having difficulty rendering a form. Does anyone have a CONCISE 
>> tutorial for me?
>>
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/045cd9f2-20c2-4ecd-b5fe-409604d249fdn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/045cd9f2-20c2-4ecd-b5fe-409604d249fdn%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12707b96-883d-4d36-8029-080622aba4e3n%40googlegroups.com.


Difficulty Rendering a Form

2023-05-16 Thread Michael Starr
I am having difficulty rendering a form. Does anyone have a CONCISE 
tutorial for me?

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/045cd9f2-20c2-4ecd-b5fe-409604d249fdn%40googlegroups.com.


Re: Form Page URL Not Found

2023-05-01 Thread Michael Starr
Thanks, Albert!
Mike

On Monday, May 1, 2023 at 4:44:39 PM UTC-7 ALBERT ASHABA AHEEBWA wrote:

> Oh, just realized Dylan had already answered url bit 
>
>
>
>
> Best Regards,
>
> Albert Ashaba Aheebwa
> +256 781 435857 <+256%20781%20435857>
>
> On Tue, 2 May 2023, 02:41 ALBERT ASHABA AHEEBWA,  
> wrote:
>
>>
>> Hi Michael,
>>
>> On the issue, of urls, Django uses some kind of regex expression to know 
>> which view to render. And because it's python, it reads from top - bottom. 
>> So the two urls "pet/..." are colliding. Change one url to confirm the 
>> suspicions.
>>
>> On your query of when to Use FormView or CreateView, if you need to save 
>> data to the database, always use CreateView. But if all you need is capture 
>> data and do something with it, like send an email, then FormView is for 
>> you.. Or a normal FBV can work too 
>>
>>
>> Best Regards,
>>
>> Albert
>>
>> On Tue, 2 May 2023, 02:21 Michael Starr,  wrote:
>>
>>> I made some progress on the error.
>>> It's a view error. It's thrown by PetDetailView (which isn't even being 
>>> called with this url call or this template), and it can't find the context 
>>> object name that I defined as pet, which is stupid, because I defined it, 
>>> it's not a memory lookup.
>>> QED Django is bad.
>>>
>>> Mike
>>>
>>> On Sunday, April 30, 2023 at 1:43:02 PM UTC-7 Michael Starr wrote:
>>>
>>>> Hi Alberta. Thank you for the wonderful resource. I like concise 
>>>> information displays.
>>>>
>>>> Can you explain, by any chance, when a FormView and when a CreateView 
>>>> are used? The tutorials also say use CreateView, but I went for what was 
>>>> more logical to me--and it didn't work. But that may not have been the 
>>>> reason it didn't work. The docstring for the CreateView is a little 
>>>> ambiguous. To put it here, " View for creating a new object, with a 
>>>> response rendered by a template." What do they mean by new object? 
>>>> Whereas for FormView, it is clear: " A view for displaying a form and 
>>>> rendering a template response." This seems more appropriate.
>>>>
>>>> The {{ form }} is polish on the nail. I need my URL to be found first.
>>>>
>>>> But thank you for the tangential improvements.
>>>>
>>>> Michael
>>>>
>>>> On Sunday, April 30, 2023 at 12:27:00 AM UTC-7 ALBERT ASHABA AHEEBWA 
>>>> wrote:
>>>>
>>>>> Hi there,
>>>>> Yes you need to add {{form}} to your html. I didn't see your models.py 
>>>>> file, but let's assume that's okay too.
>>>>>
>>>>> If you are going to use cbv(class based views), The upload view should 
>>>>> inherit from the CreateView. Try this amazing resource to learn more,
>>>>>
>>>>> https://ccbv.co.uk/
>>>>>
>>>>> And also don't forget to add the form attr 
>>>>> enctype='multipart/form-data' since it's a file upload field. 
>>>>>
>>>>>
>>>>>
>>>>> Best Regards,
>>>>>
>>>>> Albert Ashaba Aheebwa
>>>>> +256 781 435857 <+256%20781%20435857>
>>>>>
>>>>> On Sun, 30 Apr 2023, 05:20 Michael Starr,  
>>>>> wrote:
>>>>>
>>>>>> To contribute to my own answer, but not to answer the question:
>>>>>> I forgot that Django can automatically render HTML forms using the 
>>>>>> tagging language.
>>>>>>
>>>>>> From the Django Docs 
>>>>>> https://docs.djangoproject.com/en/4.1/topics/forms/()
>>>>>> *The template¶ 
>>>>>> <https://docs.djangoproject.com/en/4.1/topics/forms/#the-template>* 
>>>>>>
>>>>>> *We don’t need to do much in our name.html template:*
>>>>>> * {% csrf_token %} {{ form 
>>>>>> }}   *
>>>>>>
>>>>>> *All the form’s fields and their attributes will be unpacked into 
>>>>>> HTML markup from that {{ form }} by Django’s template language.*
>>>>>> I will use this to update my template context. But I don't think this 
>>>>>> is the cause of the url routing error.
>>>>>> Michael
>>>>>> On S

Re: Form Page URL Not Found

2023-05-01 Thread Michael Starr
Man that one always gets me. I forget, often, that computers are simple 
automatons that obey logical rules.

Thank you, good sir.

Michael

On Monday, May 1, 2023 at 4:26:04 PM UTC-7 Dylan Reinhold wrote:

> Ill bite.
>
> urlpatterns = [
> path("pet//", views.PetDetailView.as_view(), name = 
> "pet_profile"),
> path("owner//", views.PetOwnerDetailView.as_view(), name = 
> "owner_profile"),
> path("pet/photoupload/", views.PetPhotoUploadView.as_view(), name = 
> "photo_upload"),
> ]
>
> You if you are going to url /pet/photoupload/ that is going to call the 
> first one and process "photoupload" as the slug.
> Move the photoupload above the the wildcard  entry.
>
> Dylan
>
> On Mon, May 1, 2023 at 4:21 PM Michael Starr  
> wrote:
>
>> I made some progress on the error.
>> It's a view error. It's thrown by PetDetailView (which isn't even being 
>> called with this url call or this template), and it can't find the context 
>> object name that I defined as pet, which is stupid, because I defined it, 
>> it's not a memory lookup.
>> QED Django is bad.
>>
>> Mike
>>
>> On Sunday, April 30, 2023 at 1:43:02 PM UTC-7 Michael Starr wrote:
>>
>>> Hi Alberta. Thank you for the wonderful resource. I like concise 
>>> information displays.
>>>
>>> Can you explain, by any chance, when a FormView and when a CreateView 
>>> are used? The tutorials also say use CreateView, but I went for what was 
>>> more logical to me--and it didn't work. But that may not have been the 
>>> reason it didn't work. The docstring for the CreateView is a little 
>>> ambiguous. To put it here, " View for creating a new object, with a 
>>> response rendered by a template." What do they mean by new object? 
>>> Whereas for FormView, it is clear: " A view for displaying a form and 
>>> rendering a template response." This seems more appropriate.
>>>
>>> The {{ form }} is polish on the nail. I need my URL to be found first.
>>>
>>> But thank you for the tangential improvements.
>>>
>>> Michael
>>>
>>> On Sunday, April 30, 2023 at 12:27:00 AM UTC-7 ALBERT ASHABA AHEEBWA 
>>> wrote:
>>>
>>>> Hi there,
>>>> Yes you need to add {{form}} to your html. I didn't see your models.py 
>>>> file, but let's assume that's okay too.
>>>>
>>>> If you are going to use cbv(class based views), The upload view should 
>>>> inherit from the CreateView. Try this amazing resource to learn more,
>>>>
>>>> https://ccbv.co.uk/
>>>>
>>>> And also don't forget to add the form attr 
>>>> enctype='multipart/form-data' since it's a file upload field. 
>>>>
>>>>
>>>>
>>>> Best Regards,
>>>>
>>>> Albert Ashaba Aheebwa
>>>> +256 781 435857 <+256%20781%20435857>
>>>>
>>>> On Sun, 30 Apr 2023, 05:20 Michael Starr,  
>>>> wrote:
>>>>
>>>>> To contribute to my own answer, but not to answer the question:
>>>>> I forgot that Django can automatically render HTML forms using the 
>>>>> tagging language.
>>>>>
>>>>> From the Django Docs 
>>>>> https://docs.djangoproject.com/en/4.1/topics/forms/()
>>>>> *The template¶ 
>>>>> <https://docs.djangoproject.com/en/4.1/topics/forms/#the-template>* 
>>>>>
>>>>> *We don’t need to do much in our name.html template:*
>>>>> * {% csrf_token %} {{ form }} 
>>>>>   *
>>>>>
>>>>> *All the form’s fields and their attributes will be unpacked into HTML 
>>>>> markup from that {{ form }} by Django’s template language.*
>>>>> I will use this to update my template context. But I don't think this 
>>>>> is the cause of the url routing error.
>>>>> Michael
>>>>> On Saturday, April 29, 2023 at 6:27:33 PM UTC-7 Michael Starr wrote:
>>>>>
>>>>>> This isn't the exact name of the error; I'm sure you all have 
>>>>>> encountered the bad URL error before. But, it tells me it can't find the 
>>>>>> pet matching the query (I'm making a pet website), and it checked the 
>>>>>> urls 
>>>>>> in the order listed below. I mean, you know, in the order in the urls.py 
>>>>>> file.
>

Re: Form Page URL Not Found

2023-05-01 Thread Michael Starr
I made some progress on the error.
It's a view error. It's thrown by PetDetailView (which isn't even being 
called with this url call or this template), and it can't find the context 
object name that I defined as pet, which is stupid, because I defined it, 
it's not a memory lookup.
QED Django is bad.

Mike

On Sunday, April 30, 2023 at 1:43:02 PM UTC-7 Michael Starr wrote:

> Hi Alberta. Thank you for the wonderful resource. I like concise 
> information displays.
>
> Can you explain, by any chance, when a FormView and when a CreateView are 
> used? The tutorials also say use CreateView, but I went for what was more 
> logical to me--and it didn't work. But that may not have been the reason it 
> didn't work. The docstring for the CreateView is a little ambiguous. To put 
> it here, " View for creating a new object, with a response rendered by a 
> template." What do they mean by new object? Whereas for FormView, it is 
> clear: " A view for displaying a form and rendering a template response." 
> This seems more appropriate.
>
> The {{ form }} is polish on the nail. I need my URL to be found first.
>
> But thank you for the tangential improvements.
>
> Michael
>
> On Sunday, April 30, 2023 at 12:27:00 AM UTC-7 ALBERT ASHABA AHEEBWA wrote:
>
>> Hi there,
>> Yes you need to add {{form}} to your html. I didn't see your models.py 
>> file, but let's assume that's okay too.
>>
>> If you are going to use cbv(class based views), The upload view should 
>> inherit from the CreateView. Try this amazing resource to learn more,
>>
>> https://ccbv.co.uk/
>>
>> And also don't forget to add the form attr enctype='multipart/form-data' 
>> since it's a file upload field. 
>>
>>
>>
>> Best Regards,
>>
>> Albert Ashaba Aheebwa
>> +256 781 435857 <+256%20781%20435857>
>>
>> On Sun, 30 Apr 2023, 05:20 Michael Starr,  wrote:
>>
>>> To contribute to my own answer, but not to answer the question:
>>> I forgot that Django can automatically render HTML forms using the 
>>> tagging language.
>>>
>>> From the Django Docs 
>>> https://docs.djangoproject.com/en/4.1/topics/forms/()
>>> *The template¶ 
>>> <https://docs.djangoproject.com/en/4.1/topics/forms/#the-template>* 
>>>
>>> *We don’t need to do much in our name.html template:*
>>> * {% csrf_token %} {{ form }} 
>>>   *
>>>
>>> *All the form’s fields and their attributes will be unpacked into HTML 
>>> markup from that {{ form }} by Django’s template language.*
>>> I will use this to update my template context. But I don't think this is 
>>> the cause of the url routing error.
>>> Michael
>>> On Saturday, April 29, 2023 at 6:27:33 PM UTC-7 Michael Starr wrote:
>>>
>>>> This isn't the exact name of the error; I'm sure you all have 
>>>> encountered the bad URL error before. But, it tells me it can't find the 
>>>> pet matching the query (I'm making a pet website), and it checked the urls 
>>>> in the order listed below. I mean, you know, in the order in the urls.py 
>>>> file.
>>>>
>>>> Another url works from the project urls.py file, but this url is in the 
>>>> app urls.py file. But it does check the imported urls.
>>>>
>>>> This url should be routing to a form template which is connected to a 
>>>> form view to update a photo object in my models.
>>>>
>>>> I'm not sure which files would be relevant to share. Here are the ones 
>>>> I'm guessing may help:
>>>>
>>>> project urls.py
>>>> from django.contrib import admin
>>>> from django.urls import path, include
>>>> from . import views
>>>> from django.conf.urls.static import static
>>>> from django.conf import settings
>>>>
>>>> urlpatterns = [
>>>> path('admin/', admin.site.urls),
>>>> path('home/', views.HomeView.as_view(), name='home_view'),
>>>> path('', include('pet_profile.urls')),
>>>> ]
>>>>
>>>> app urls.py
>>>> from django.contrib import admin
>>>> from django.urls import path
>>>> from pet_profile import views
>>>>
>>>> urlpatterns = [
>>>> path("pet//", views.PetDetailView.as_view(), name = 
>>>> "pet_profile"),
>>>> path("owner//", views.PetOwnerDetailView.as_view(), 
>>>> name = "owner_profile"

Re: Form Page URL Not Found

2023-04-30 Thread Michael Starr
Hi Alberta. Thank you for the wonderful resource. I like concise 
information displays.

Can you explain, by any chance, when a FormView and when a CreateView are 
used? The tutorials also say use CreateView, but I went for what was more 
logical to me--and it didn't work. But that may not have been the reason it 
didn't work. The docstring for the CreateView is a little ambiguous. To put 
it here, " View for creating a new object, with a response rendered by a 
template." What do they mean by new object? Whereas for FormView, it is 
clear: " A view for displaying a form and rendering a template response." 
This seems more appropriate.

The {{ form }} is polish on the nail. I need my URL to be found first.

But thank you for the tangential improvements.

Michael

On Sunday, April 30, 2023 at 12:27:00 AM UTC-7 ALBERT ASHABA AHEEBWA wrote:

> Hi there,
> Yes you need to add {{form}} to your html. I didn't see your models.py 
> file, but let's assume that's okay too.
>
> If you are going to use cbv(class based views), The upload view should 
> inherit from the CreateView. Try this amazing resource to learn more,
>
> https://ccbv.co.uk/
>
> And also don't forget to add the form attr enctype='multipart/form-data' 
> since it's a file upload field. 
>
>
>
> Best Regards,
>
> Albert Ashaba Aheebwa
> +256 781 435857 <+256%20781%20435857>
>
> On Sun, 30 Apr 2023, 05:20 Michael Starr,  wrote:
>
>> To contribute to my own answer, but not to answer the question:
>> I forgot that Django can automatically render HTML forms using the 
>> tagging language.
>>
>> From the Django Docs 
>> https://docs.djangoproject.com/en/4.1/topics/forms/()
>> *The template¶ 
>> <https://docs.djangoproject.com/en/4.1/topics/forms/#the-template>* 
>>
>> *We don’t need to do much in our name.html template:*
>> * {% csrf_token %} {{ form }} 
>>   *
>>
>> *All the form’s fields and their attributes will be unpacked into HTML 
>> markup from that {{ form }} by Django’s template language.*
>> I will use this to update my template context. But I don't think this is 
>> the cause of the url routing error.
>> Michael
>> On Saturday, April 29, 2023 at 6:27:33 PM UTC-7 Michael Starr wrote:
>>
>>> This isn't the exact name of the error; I'm sure you all have 
>>> encountered the bad URL error before. But, it tells me it can't find the 
>>> pet matching the query (I'm making a pet website), and it checked the urls 
>>> in the order listed below. I mean, you know, in the order in the urls.py 
>>> file.
>>>
>>> Another url works from the project urls.py file, but this url is in the 
>>> app urls.py file. But it does check the imported urls.
>>>
>>> This url should be routing to a form template which is connected to a 
>>> form view to update a photo object in my models.
>>>
>>> I'm not sure which files would be relevant to share. Here are the ones 
>>> I'm guessing may help:
>>>
>>> project urls.py
>>> from django.contrib import admin
>>> from django.urls import path, include
>>> from . import views
>>> from django.conf.urls.static import static
>>> from django.conf import settings
>>>
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> path('home/', views.HomeView.as_view(), name='home_view'),
>>> path('', include('pet_profile.urls')),
>>> ]
>>>
>>> app urls.py
>>> from django.contrib import admin
>>> from django.urls import path
>>> from pet_profile import views
>>>
>>> urlpatterns = [
>>> path("pet//", views.PetDetailView.as_view(), name = 
>>> "pet_profile"),
>>> path("owner//", views.PetOwnerDetailView.as_view(), name 
>>> = "owner_profile"),
>>> path("pet/photoupload/", views.PetPhotoUploadView.as_view(), name = 
>>> "photo_upload"),
>>> ]
>>> url in question is the bottom one (photo_upload)
>>>
>>> template (photo_upload.html)
>>> 
>>> 
>>> 
>>>
>>> 
>>> 
>>> Upload a photo of your pet: 
>>> 
>>> 
>>>
>>> app views
>>> from django.shortcuts import render
>>> from django.views.generic import (ListView,
>>>   DetailView, FormView)
>>> from pet_profile.models import PetOwner, Pet, PetPhoto, PetStory
>>> from pet_profile.forms import PhotoUploadFor

Re: Form Page URL Not Found

2023-04-29 Thread Michael Starr
To contribute to my own answer, but not to answer the question:
I forgot that Django can automatically render HTML forms using the tagging 
language.

>From the Django Docs https://docs.djangoproject.com/en/4.1/topics/forms/()
*The template¶ 
<https://docs.djangoproject.com/en/4.1/topics/forms/#the-template>* 

*We don’t need to do much in our name.html template:*
* {% csrf_token %} {{ form }} 
  *

*All the form’s fields and their attributes will be unpacked into HTML 
markup from that {{ form }} by Django’s template language.*
I will use this to update my template context. But I don't think this is 
the cause of the url routing error.
Michael
On Saturday, April 29, 2023 at 6:27:33 PM UTC-7 Michael Starr wrote:

> This isn't the exact name of the error; I'm sure you all have encountered 
> the bad URL error before. But, it tells me it can't find the pet matching 
> the query (I'm making a pet website), and it checked the urls in the order 
> listed below. I mean, you know, in the order in the urls.py file.
>
> Another url works from the project urls.py file, but this url is in the 
> app urls.py file. But it does check the imported urls.
>
> This url should be routing to a form template which is connected to a form 
> view to update a photo object in my models.
>
> I'm not sure which files would be relevant to share. Here are the ones I'm 
> guessing may help:
>
> project urls.py
> from django.contrib import admin
> from django.urls import path, include
> from . import views
> from django.conf.urls.static import static
> from django.conf import settings
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('home/', views.HomeView.as_view(), name='home_view'),
> path('', include('pet_profile.urls')),
> ]
>
> app urls.py
> from django.contrib import admin
> from django.urls import path
> from pet_profile import views
>
> urlpatterns = [
> path("pet//", views.PetDetailView.as_view(), name = 
> "pet_profile"),
> path("owner//", views.PetOwnerDetailView.as_view(), name = 
> "owner_profile"),
> path("pet/photoupload/", views.PetPhotoUploadView.as_view(), name = 
> "photo_upload"),
> ]
> url in question is the bottom one (photo_upload)
>
> template (photo_upload.html)
> 
> 
> 
>
> 
> 
> Upload a photo of your pet: 
> 
> 
>
> app views
> from django.shortcuts import render
> from django.views.generic import (ListView,
>   DetailView, FormView)
> from pet_profile.models import PetOwner, Pet, PetPhoto, PetStory
> from pet_profile.forms import PhotoUploadForm
>
> class PetOwnerListView(ListView):
> model = PetOwner
> context_object_name = "owner_list"
> template_name = "home.html"
>
> 
> # def all_pet_photos(request):
> # pets = Pet.objects.all()
> # pet_data = {}
> # for pet in pets:
> # pet_data[pet] = PetPhoto.objects.filter(pets=pet)
> # context = {'pet_data': pet_data}
> # return render(request, 'pet_owner_profile.html', context)
>
> 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
>
> class PetListView(ListView):
> model = Pet
> context_object_name = "pet_list"
>
> class PetDetailView(DetailView):
> model = Pet
> context_object_name = "pet"
>
> class PetPhotoUploadView(FormView):
> template_name = "photo_upload.html"
> form_class = PhotoUploadForm
>
> class PetPhotoListView(ListView):
> model = PetPhoto
> context_object_name = "pet_photo_list"
>
> class PetPhotoDetailView(DetailView):
> model = PetPhoto
> context_object_name = "pet_photo"
>
> class PetStoryListView(ListView):
> model = PetStory
> context_object_name = "pet_story_list"
>
> class PetStoryDetailView(DetailView):
> model = PetStory
> context_object_name = "pet_story"
>
> view in question is PetPhotoUploadView
>
> Thanks in advance.
> 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/6c5ead2a-764e-4fa8-a903-a86ae5def321n%40googlegroups.com.


Form Page URL Not Found

2023-04-29 Thread Michael Starr
This isn't the exact name of the error; I'm sure you all have encountered 
the bad URL error before. But, it tells me it can't find the pet matching 
the query (I'm making a pet website), and it checked the urls in the order 
listed below. I mean, you know, in the order in the urls.py file.

Another url works from the project urls.py file, but this url is in the app 
urls.py file. But it does check the imported urls.

This url should be routing to a form template which is connected to a form 
view to update a photo object in my models.

I'm not sure which files would be relevant to share. Here are the ones I'm 
guessing may help:

project urls.py
from django.contrib import admin
from django.urls import path, include
from . import views
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
path('admin/', admin.site.urls),
path('home/', views.HomeView.as_view(), name='home_view'),
path('', include('pet_profile.urls')),
]

app urls.py
from django.contrib import admin
from django.urls import path
from pet_profile import views

urlpatterns = [
path("pet//", views.PetDetailView.as_view(), name = 
"pet_profile"),
path("owner//", views.PetOwnerDetailView.as_view(), name = 
"owner_profile"),
path("pet/photoupload/", views.PetPhotoUploadView.as_view(), name = 
"photo_upload"),
]
url in question is the bottom one (photo_upload)

template (photo_upload.html)






Upload a photo of your pet: 



app views
from django.shortcuts import render
from django.views.generic import (ListView,
  DetailView, FormView)
from pet_profile.models import PetOwner, Pet, PetPhoto, PetStory
from pet_profile.forms import PhotoUploadForm

class PetOwnerListView(ListView):
model = PetOwner
context_object_name = "owner_list"
template_name = "home.html"


# def all_pet_photos(request):
# pets = Pet.objects.all()
# pet_data = {}
# for pet in pets:
# pet_data[pet] = PetPhoto.objects.filter(pets=pet)
# context = {'pet_data': pet_data}
# return render(request, 'pet_owner_profile.html', context)

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

class PetListView(ListView):
model = Pet
context_object_name = "pet_list"

class PetDetailView(DetailView):
model = Pet
context_object_name = "pet"

class PetPhotoUploadView(FormView):
template_name = "photo_upload.html"
form_class = PhotoUploadForm

class PetPhotoListView(ListView):
model = PetPhoto
context_object_name = "pet_photo_list"

class PetPhotoDetailView(DetailView):
model = PetPhoto
context_object_name = "pet_photo"

class PetStoryListView(ListView):
model = PetStory
context_object_name = "pet_story_list"

class PetStoryDetailView(DetailView):
model = PetStory
context_object_name = "pet_story"

view in question is PetPhotoUploadView

Thanks in advance.
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/3c1afbb6-847f-43e0-97ce-c5c8719dfefen%40googlegroups.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-29 Thread Michael Starr
And yeah, django is installed in the venv.
Michael

On Saturday, April 29, 2023 at 10:40:01 AM UTC-7 Michael Starr wrote:

> Thanks. I already have a venv, to answer the first post, and the second, 
> yes, it says 3.11.2. I think VSCode just has a bug. It doesn't bother me 
> and my app works in all other respects. Thank you for the input.
>
> Michael
>
> On Friday, April 28, 2023 at 7:11:57 AM UTC-7 ALBERT ASHABA AHEEBWA wrote:
>
>> This is a wild suggestion, but as someone here mentioned, your vscode 
>> might be pointing to the wrong interpreter.
>>
>> Check at the bottom bar of your vscode with a .py file open. Next to 
>> {}python you should see what environment you are using. 
>>
>> eg. 3.11.3 64-bit or 3.11.3('.venv':venv)
>>
>> The latter is what you are looking for. If it's not, click on whatever is 
>> there and on popup, select the appropriate. 
>>
>>
>>
>> Best Regards,
>>
>> Albert Ashaba Aheebwa
>> +256 781 435857 <+256%20781%20435857>
>>
>> On Thu, 27 Apr 2023, 23:48 Michael Starr,  wrote:
>>
>>> I did pip install django on my venv, which is activated, and it reported 
>>> already installed. But the following modules are reporting the error in the 
>>> subject line:
>>> django.db
>>> models
>>> django.utils.crypto
>>> django.urls
>>> django.contrib
>>> admin
>>> django.shortcuts
>>> django.views.generic
>>>
>>> I don't know what's wrong. My server runs in development mode (not in 
>>> production yet), but there havev been some bugs that are hard to imagine 
>>> are caused by this, but still (images not loading, CSS not loading).
>>>
>>> Thanks.
>>>
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f310b434-83df-44ed-b847-0676d36c3441n%40googlegroups.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-29 Thread Michael Starr
Thanks. I already have a venv, to answer the first post, and the second, 
yes, it says 3.11.2. I think VSCode just has a bug. It doesn't bother me 
and my app works in all other respects. Thank you for the input.

Michael

On Friday, April 28, 2023 at 7:11:57 AM UTC-7 ALBERT ASHABA AHEEBWA wrote:

> This is a wild suggestion, but as someone here mentioned, your vscode 
> might be pointing to the wrong interpreter.
>
> Check at the bottom bar of your vscode with a .py file open. Next to 
> {}python you should see what environment you are using. 
>
> eg. 3.11.3 64-bit or 3.11.3('.venv':venv)
>
> The latter is what you are looking for. If it's not, click on whatever is 
> there and on popup, select the appropriate. 
>
>
>
> Best Regards,
>
> Albert Ashaba Aheebwa
> +256 781 435857 <+256%20781%20435857>
>
> On Thu, 27 Apr 2023, 23:48 Michael Starr,  wrote:
>
>> I did pip install django on my venv, which is activated, and it reported 
>> already installed. But the following modules are reporting the error in the 
>> subject line:
>> django.db
>> models
>> django.utils.crypto
>> django.urls
>> django.contrib
>> admin
>> django.shortcuts
>> django.views.generic
>>
>> I don't know what's wrong. My server runs in development mode (not in 
>> production yet), but there havev been some bugs that are hard to imagine 
>> are caused by this, but still (images not loading, CSS not loading).
>>
>> Thanks.
>>
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8bfb55ff-a550-4fe1-9ec5-73074f3de264n%40googlegroups.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-27 Thread Michael Starr
Thank you for the replies. I am overwhelmed right now but will check back 
on them later.

I think you two are right that it's the IDE. It's VSCode (I don't know what 
version). I was just suspicious b/c there were some strange bugs in my 
django project. I won't worry about it. If it annoys me I'll redirect the 
pointers.

Michael

On Thursday, April 27, 2023 at 3:27:31 PM UTC-7 Khaleel Ahmed H. M. Shariff 
wrote:

> Hi Michael 
>
> May Peace, Blessings & Mercy of Almighty God be on you!
>
> do you know how to modify the sys.path to add the directory where the 
> listed modules are installed?
>
> On Linux/UNIX
> Execute the find command to locate the directory where the modules are 
> installed and include the same in the path
>
> On windows 
> Execute the dir/s to locate the directory where the modules are installed 
> and include the same in the path
>
> Best of luck
>
> God Bless You!
> God Bless India!!
> --
>
> Love & Regards
> Dr. (h.c.) Khaleel Ahmed H. M.
>
> +91-9845007864 <+91%2098450%2007864>
>
> Taming Python
>
>
> https://www.amazon.in/Taming-Python-comfortable-writing-Scripts-ebook/dp/B08T6PQG7M
>
> ---
>
> Human Life is Precious
> Koran Surah Ma'idah Chapter 5 Verse 32:
> If anyone killed a person, not in retaliation of murder, or (and) to 
> spread mischief in the land - it would be as if he killed all mankind, & if 
> anyone saved a life, it would be as if he saved the life of all mankind.
>
> On Fri, 28 Apr 2023 at 2:54 AM, Reddy Tintaya  wrote:
>
>> Should I suppose that it appears like error only in your editor, but the 
>> app runs with no problem?
>> I guess the error is that your IDE is not pointing to the correct python 
>> interpreter
>>
>>
>> On 27 Apr 2023, at 16:05, Michael Starr  wrote:
>>
>> I did pip install django on my venv, which is activated, and it reported 
>> already installed. But the following modules are reporting the error in the 
>> subject line:
>> django.db
>> models
>> django.utils.crypto
>> django.urls
>> django.contrib
>> admin
>> django.shortcuts
>> django.views.generic
>>
>> I don't know what's wrong. My server runs in development mode (not in 
>> production yet), but there havev been some bugs that are hard to imagine 
>> are caused by this, but still (images not loading, CSS not loading).
>>
>> Thanks.
>>
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com?utm_medium=email_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 django-users...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/2FFAC08F-0BC9-44B6-98B2-97A8978AB3DC%40momnt.com
>>  
>> <https://groups.google.com/d/msgid/django-users/2FFAC08F-0BC9-44B6-98B2-97A8978AB3DC%40momnt.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52f5968e-2e0d-4f64-8fb3-5bbd2ef70bean%40googlegroups.com.


Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-27 Thread Michael Starr
I did pip install django on my venv, which is activated, and it reported 
already installed. But the following modules are reporting the error in the 
subject line:
django.db
models
django.utils.crypto
django.urls
django.contrib
admin
django.shortcuts
django.views.generic

I don't know what's wrong. My server runs in development mode (not in 
production yet), but there havev been some bugs that are hard to imagine 
are caused by this, but still (images not loading, CSS not loading).

Thanks.

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/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com.


Report a Django bug how

2023-04-13 Thread Michael Starr
Hi, I double checked my code and Django is not displaying images. I'd like 
to report the bug but I need to be a django employee to do that. So, if 
anyone knows anyone on linkedin that works for django, tell them images 
don't display (on an operating system).

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/aa4c364c-24cd-44f8-b593-36b5349e7f7cn%40googlegroups.com.


Re: Image uploaded to database but not displaying

2023-04-12 Thread Michael Starr
I checked my settings.py folder backward and forward; nothing seems odd. 
The media_root and media_url are very self-explanatory, and correct afaik.
And if you're going to tell me to add static url stuff to my urls.py, read 
what David said above.
Michael

On Wednesday, April 12, 2023 at 1:21:23 PM UTC-7 Michael Starr wrote:

> settings.py
> """
> Django settings for pet_memorial project.
>
> Generated by 'django-admin startproject' using Django 2.2.12.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/2.2/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/2.2/ref/settings/
> """
>
> import os
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = '1eovl-=7pwb6e1*c7y@6@s7n0+ig)mxos2im3b_+^%3+rdze'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'pet_profile'
> ]
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/2.2/howto/static-files/
>
> STATIC_URL = 'static/'
> STATIC_ROOT = os.path.join(BASE_DIR, STATIC_URL)
> MEDIA_URL = 'media/'
> MEDIA_ROOT = os.path.join(BASE_DIR, MEDIA_URL)
>
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'pet_memorial.urls'
>
>
> TEMPLATE_PROJECT_DIR = os.path.join(BASE_DIR,
> 'pet_memorial/templates/pet_memorial/')
> TEMPLATE_APP_DIR = os.path.join(BASE_DIR,
> 'pet_profile/templates/pet_profile/')
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [TEMPLATE_PROJECT_DIR, TEMPLATE_APP_DIR],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'pet_memorial.wsgi.application'
>
>
> # Database
> # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> }
> }
>
>
> # Password validation
> # 
> https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
> ,
> },
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.MinimumLengthValidator',
> },
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.CommonPasswordValidator',
> },
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.NumericPasswordValidator',
> },
> ]
>
>
> # Internationalization
> # https://docs.djangoproject.com/en/2.2/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
>
>
>
> urls.py (in project folder)
> from django.contrib import admin
> from django.urls import path, include
> from . import views
> from django.conf.urls.static import static
> from django.conf import settings
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('home/', views.HomeView.as_view(), name='home_view'),
> path('', include('pet_profile.urls')),
> ]
>
> urls.py (in app folder)
> from django.contrib import admin
> from django.

Re: Image uploaded to database but not displaying

2023-04-12 Thread Michael Starr
ngs. In production, 
either or both may be served externally to django.

By default, MEDIA serving is not configured in Django settings, but there 
are many mentions of static files with a dozen or so possible configuration 
items. These are there because such configuration is important right at the 
start of developing a Django app.

If you need information on media handling though, you need to go back to 
the Django docs as there are no hints on how to do this in the default 
generated configuration.

The point is - do not confuse the two, and definitely do not try to tangle 
both as it will eventually lead to problems. Configure media separately 
from static and you will not encounter any of those problems, especially so 
when you get to deploying to production where you may wish to handle them 
differently (serving from cloud vs locally and choice of what served each 
etc and a myriad of other choices).

So, back to your problem, I would guess that you are simply missing a url 
handler for your media files at path(‘media/‘,…(, and the path stored in 
your db is almost definitely correct. The handler you will probably use in 
development mode will look something like your dev static files config, 
except for MEDIA_URL and pointing to the file system location where they 
are actually being uploaded.

HTH,
David



From: Michael Starr 
Reply: django...@googlegroups.com 
Date: 12 April 2023 at 18:00:56
To: Django users 
Subject:  Image uploaded to database but not displaying 

I am finding that the url of files stored in a database with Django is 
automated to /media/[filename], which is neat, because that keeps it 
organized and from images being everywhere. However, only the alt text of 
my file shows--the url is correct but the image doesn't show. I've tried 
using static, as well as just {{ image.url }} and neither method worked for 
me. Also, which method is correct? Can we frikkin decide already? :P

Thank you.
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...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4d1c1c52-c4d8-4f46-8333-adc673095fc1n%40googlegroups.com
 
<https://groups.google.com/d/msgid/django-users/4d1c1c52-c4d8-4f46-8333-adc673095fc1n%40googlegroups.com?utm_medium=email_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 django-users...@googlegroups.com.

To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE5VhgU%2BCLvoawzUZrb22PBTDi3-%2ByQDCUzHWesOQRawFky5Nw%40mail.gmail.com
 
<https://groups.google.com/d/msgid/django-users/CAE5VhgU%2BCLvoawzUZrb22PBTDi3-%2ByQDCUzHWesOQRawFky5Nw%40mail.gmail.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fa7db884-5031-4b51-bb17-a2b7dafa8336n%40googlegroups.com.


Re: Image uploaded to database but not displaying

2023-04-12 Thread Michael Starr
Thank you for the perspective, David. That is good to know--that media and 
static are so different. Yes, in engineering, a separation of functions is 
often beneficial to the system. Same with software, I suppose.
However, the Django docs on managing files at 
https://docs.djangoproject.com/en/4.1/topics/files/ are very thin, tbh. 
They don't even display an example of rendering a user-uploaded image. They 
just do some REPL-type stuff. I am, as far as the extent of my knowledge 
goes, following the instructions on media_root and media_url, and they make 
it seem like it should be really simple. Either that or they're leaving out 
huge chunks of logic. I wouldn't put it past them that it be the latter.
And for all those involved and the lord and savior, I am not yet on 
production. FYI.

Michael

On Tuesday, April 11, 2023 at 11:58:23 PM UTC-7 David Nugent wrote:

> It is very important to understand the difference between “static” and 
> “media”. The two are somewhat similar, and the code to handle (serve) each 
> is even almost identical. Conceptually though they are quite different 
> things.
>
> static files are assets provided by your app and served to satisfy the 
> direct needs of your app - e.g. javascript, css and other assets which 
> never change, updated or rendered.
> media files are more fluid things, usually uploaded or processed files, 
> objects delivered by the application that are not a core part of rendering 
> web pages.
>
> Both STATIC_URL and MEDIA_URL are set up in your settings. In production, 
> either or both may be served externally to django.
>
> By default, MEDIA serving is not configured in Django settings, but there 
> are many mentions of static files with a dozen or so possible configuration 
> items. These are there because such configuration is important right at the 
> start of developing a Django app.
>
> If you need information on media handling though, you need to go back to 
> the Django docs as there are no hints on how to do this in the default 
> generated configuration.
>
> The point is - do not confuse the two, and definitely do not try to tangle 
> both as it will eventually lead to problems. Configure media separately 
> from static and you will not encounter any of those problems, especially so 
> when you get to deploying to production where you may wish to handle them 
> differently (serving from cloud vs locally and choice of what served each 
> etc and a myriad of other choices).
>
> So, back to your problem, I would guess that you are simply missing a url 
> handler for your media files at path(‘media/‘,…(, and the path stored in 
> your db is almost definitely correct. The handler you will probably use in 
> development mode will look something like your dev static files config, 
> except for MEDIA_URL and pointing to the file system location where they 
> are actually being uploaded.
>
> HTH,
> David
>
>
>
> From: Michael Starr 
> Reply: django...@googlegroups.com 
> Date: 12 April 2023 at 18:00:56
> To: Django users 
> Subject:  Image uploaded to database but not displaying 
>
> I am finding that the url of files stored in a database with Django is 
>> automated to /media/[filename], which is neat, because that keeps it 
>> organized and from images being everywhere. However, only the alt text of 
>> my file shows--the url is correct but the image doesn't show. I've tried 
>> using static, as well as just {{ image.url }} and neither method worked for 
>> me. Also, which method is correct? Can we frikkin decide already? :P
>>
>> Thank you.
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/4d1c1c52-c4d8-4f46-8333-adc673095fc1n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/4d1c1c52-c4d8-4f46-8333-adc673095fc1n%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ad9095fc-f0f0-4d8a-bff6-2a6e3426c869n%40googlegroups.com.


Tutorial for a Django web store

2023-04-12 Thread Michael Starr
Does anyone know of a good tutorial (preferably with github files) that 
teaches you how to make a web store in Django? It seems like a basic 
literacy skill for Django programming.

Let me know.

Thanks.
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/4dd45d1b-58f6-40d4-b227-955ec8bb00a5n%40googlegroups.com.


Image uploaded to database but not displaying

2023-04-12 Thread Michael Starr
I am finding that the url of files stored in a database with Django is 
automated to /media/[filename], which is neat, because that keeps it 
organized and from images being everywhere. However, only the alt text of 
my file shows--the url is correct but the image doesn't show. I've tried 
using static, as well as just {{ image.url }} and neither method worked for 
me. Also, which method is correct? Can we frikkin decide already? :P

Thank you.
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/4d1c1c52-c4d8-4f46-8333-adc673095fc1n%40googlegroups.com.


Re: Using the URLconf defined in iblogs.urls, Django tried these URL patterns, in this order:

2023-04-11 Thread Michael Starr
You probably weren't careful enough following instructions. The beginner's 
tutorial is self-contained and allows a complete Django project to be made. 
Re-read everything word-for-word and then come back with some hypotheses 
for us to test for you.
Michael

On Tuesday, April 4, 2023 at 9:44:38 AM UTC-7 Tanveer wrote:

> 0
> 
>
> I know this question has been asked before, but I haven't found an answer 
> that solves my situation.
>
> I'm looking at the Django tutorial, and I've set up the first URLs exactly 
> as the tutorial has it, word for word, but when I go to 
> http://127.0.0.1:8000/, it gives me this error: but when i go to 
> http://127.0.0.1:8000/admin/ its working fine,where and what i am doing 
> wrong? i am using python version 3.11.1 please let me know for any other 
> info
> urls.py
>
> from django.contrib import admin
> from django.urls import path, include
> from django.conf.urls.static import static
> from django.conf import settings
> from .views import home
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', home)
>   ]
>
> views.py
> from django.http import HttpResponse
> from django.shortcuts import render
>
> # Create your views here.
> def home(request):
> return render(request,home.html,{})
>
>

-- 
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/6ae14b24-3fff-4f12-a9d9-80f4baa95c81n%40googlegroups.com.


Spies in California and America

2023-03-28 Thread Michael Starr
So does  anyone have an update on the police state and spying of Democrat 
Ukrainians in America yet?

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/3711c50c-4f8d-4bef-97d5-9b37d33049a0n%40googlegroups.com.


Re: "Fat" vs "Lean" or better "Fit" Use of Electrical Information Devices

2023-03-24 Thread Michael Starr
One more:
Fat: Sending yourself emails as a means of storing information
Fit: Writing it down somewhere instead

Mike

On Friday, March 24, 2023 at 3:58:47 PM UTC-7 Michael Starr wrote:

> What are the properties of "fat" computer usage?
> What are the properties of "fit" computer usage?
>
> I find I fall into the former category.
>
> :(
>

-- 
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/05a1d4ac-69a5-4ed2-8960-d086607db70cn%40googlegroups.com.


Re: "Fat" vs "Lean" or better "Fit" Use of Electrical Information Devices

2023-03-24 Thread Michael Starr
I'll start:

Fat: Storing files you don't actually need because you "might need them 
*someday*"
Fit: Deleting or better yet, archiving those files

Mike

On Friday, March 24, 2023 at 3:58:47 PM UTC-7 Michael Starr wrote:

> What are the properties of "fat" computer usage?
> What are the properties of "fit" computer usage?
>
> I find I fall into the former category.
>
> :(
>

-- 
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/71d73a38-6183-43a3-a2b9-d0ef0e6188b5n%40googlegroups.com.


"Fat" vs "Lean" or better "Fit" Use of Electrical Information Devices

2023-03-24 Thread Michael Starr
What are the properties of "fat" computer usage?
What are the properties of "fit" computer usage?

I find I fall into the former category.

:(

-- 
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/f3f8381b-5fde-415a-85ef-b8e2c3cfa013n%40googlegroups.com.


Improving your Stack Overflow score

2023-03-22 Thread Michael Starr
I don't get that website. There are assholes in the thousands, and 
good-intentioned people like me at <10.
What is the deal? I don't even know what that site is for sometimes. The 
questions with good ratings are usually stupid and don't explain things 
correctly, with bad answers.
It's a conspiracy!
;)
Mike

-- 
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/71ee6d23-b7d3-4e3d-8dd5-335ad3bfc3den%40googlegroups.com.


How to get fresh air

2023-03-12 Thread Michael Starr
How do you get fresh air in your house?

-- 
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/5c62a611-ddb5-4bfa-9afe-65a6d0fd131cn%40googlegroups.com.


Re: How to fight Russia in America

2023-03-12 Thread Michael Starr
I'll roll over and die then. Thank you for contributing to the Russian 
cause. My parents would be proud.

On Sunday, March 12, 2023 at 3:37:58 PM UTC-7 Sebastian Jung wrote:

> Please stop this propaganda... This haven't nothing to do with django 
>
> Michael Starr  schrieb am So., 12. März 2023, 23:20:
>
>> Russia's influence in America is powerful. How do you fight it?
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/74de4d4b-230d-470a-a7c0-0c1e875154e4n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/74de4d4b-230d-470a-a7c0-0c1e875154e4n%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90a5fa71-7ffa-4ef8-8046-35f9988f3ac9n%40googlegroups.com.


How to fight Russia in America

2023-03-12 Thread Michael Starr
Russia's influence in America is powerful. How do you fight it?

-- 
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/74de4d4b-230d-470a-a7c0-0c1e875154e4n%40googlegroups.com.


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

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

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
>>>>  
>>>

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

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_phot

Function-based Views vs Class-based Views

2023-03-06 Thread Michael Starr
What are the pros and cons of either method of rendering HTTP request 
responses?

https://www.geeksforgeeks.org/class-based-vs-function-based-views-which-one-is-better-to-use-in-django/

In the article above it states that CBVs are DRYer, but I don't understand 
why. The article doesn't explain, it just states it.

The rest of the article is pretty good but it's a pretty slim introduction.

I thought many of you would like to chime in on this topic. Leave your 
opinion below! What do you use?

Mike

-- 
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/7bfa978b-3c11-4509-9160-799e5da43b44n%40googlegroups.com.


Re: Ordering of code

2023-03-03 Thread Michael Starr
Thank you, David.
Michael

On Friday, March 3, 2023 at 4:14:46 PM UTC-8 David Nugent wrote:

> Both are related to the python language, nothing Django specific about 
> them.
>
> This may help (not in explaining so much as demonstrating workarounds):
>
> https://stackoverflow.com/questions/4162456/forward-declaration-of-classes
> https://erdantic.drivendata.org/v0.4/forward-references/
>
> Regards,
> /d
>
> ------ Original Message --
> From "Michael Starr" 
> To "Django users" 
> Date 3/4/2023 7:43:18 AM
> Subject Ordering of code
>
> Does anyone know why in django models (and I don't know how it is in etc. 
> python), you can define a function below, and use it above in the code, but 
> a class can't reference a class defined later in the code, or it won't find 
> it?
>
> That seems like beyond stupid to me.
>
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/2409c040-107d-40e3-a828-0013851d0d98n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/2409c040-107d-40e3-a828-0013851d0d98n%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d4a19318-ef15-45a7-80a6-184918fa7931n%40googlegroups.com.


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.


Can't render images from database

2023-03-03 Thread Michael Starr
My next issue is that I'm having difficulty displaying images stored in the 
database.

It's a mouthful so I'll spare you, but I'll add details as I go along.

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/04cb18d8-4609-43a4-9296-96d6b597daban%40googlegroups.com.


Re: django.db.utils.OperationalError: foreign key mismatch - "pet_profile_petphoto_pet" referencing "pet_profile_petphoto"

2023-03-03 Thread Michael Starr
I fixed it. Let me see if I can find the stack article that helped...
Well anyway, the command that did it was
python manage.py migrate --run-syncdb
after deleting the pycache files, the db.sqlite file, and the migration 
files.

So delete all those, then run migrate --run-syncdb.
That did an ACTUAL migration.
Nifty command to know.

Michael

On Thursday, March 2, 2023 at 2:19:52 PM UTC-8 Michael Starr wrote:

> Now I am trying
>
> https://stackoverflow.com/questions/28385919/django-no-such-table-for-custom-user-profile-why
> But it doesn't get rid of
> OperationalError at /admin/pet_profile/pet/ no such table: pet_profile_pet 
>
> Django is acting as though it has hidden memory somewhere, outside of the 
> db.sqlite database and the migration files. I deleted all of them, redid 
> the makemigration command, redid migrate, and there was some text, namely
>
> Operations to perform:
>   Apply all migrations: admin, auth, contenttypes, sessions
> Running migrations:
>   Applying contenttypes.0001_initial... OK
>   Applying auth.0001_initial... OK
>   Applying admin.0001_initial... OK
>   Applying admin.0002_logentry_remove_auto_add... OK
>   Applying admin.0003_logentry_add_action_flag_choices... OK
>   Applying contenttypes.0002_remove_content_type_name... OK
>   Applying auth.0002_alter_permission_name_max_length... OK
>   Applying auth.0004_alter_user_username_opts... OK
>   Applying auth.0005_alter_user_last_login_null... OK
>   Applying auth.0006_require_contenttypes_0002... OK
>   Applying auth.0007_alter_validators_add_error_messages... OK
>   Applying auth.0008_alter_user_username_max_length... OK
>   Applying auth.0010_alter_group_name_max_length... OK
>   Applying auth.0011_update_proxy_permissions... OK
>   Applying auth.0012_alter_user_first_name_max_length... OK
>   Applying sessions.0001_initial... OK
>
> So it seems to have worked.
>
> But the error, operationalerror no such table, is still there.
>
> I have to recreate the superuser, as a side note, but I don't think this 
> is relevant.
>
> Leaning toward posting this in stackoverflow soon. Will take some time to 
> edit, polish, and edit again and again the question so that it is up to the 
> perfectionist standards of the stackoverflow tzars.
>
> Michael
>
> On Thursday, March 2, 2023 at 2:02:36 PM UTC-8 Michael Starr wrote:
>
>> Including not even finding the basic model field Pet, the most basic thing
>> OperationalError at /admin/pet_profile/pet/ no such table: 
>> pet_profile_pet 
>> It's totally effed.
>>
>> Michael
>> On Thursday, March 2, 2023 at 2:01:15 PM UTC-8 Michael Starr wrote:
>>
>>> This
>>>
>>> https://stackoverflow.com/questions/62726885/foreign-key-mismatch-comment-referencing-chellenge
>>> seems to work, but now I am getting a slew of database table model 
>>> errors.
>>>
>>>
>>>
>>> On Wednesday, March 1, 2023 at 12:35:59 PM UTC-8 Michael Starr wrote:
>>>
>>>> I even deleted the pet field from pet_photo and it still gives this 
>>>> error, even after deleting the db.sqlite3 database and remigrating. Makes 
>>>> no sense whatsoever. The error is now referencing something that is not 
>>>> even there!
>>>> Michael
>>>>
>>>> On Wednesday, March 1, 2023 at 12:33:00 PM UTC-8 Michael Starr wrote:
>>>>
>>>>> I have an error when I migrate my models. makemigrations passes just 
>>>>> fine, but upon migrate, it seems to think there is some error in the 
>>>>> pet_photo class' pet parameter and the pet_photo class:
>>>>> class Pet(models.Model):
>>>>> slug = models.SlugField(max_length = 5, primary_key = True, blank 
>>>>> = True, null=False)
>>>>> name = models.CharField(max_length = 255, unique = False)
>>>>> id = models.CharField(max_length = 261, unique = True, default = 
>>>>> uuid.uuid1)
>>>>> animaltype = models.CharField(choices = ANIMALTYPE_CHOICES, 
>>>>> max_length = 255, default="the one that barks")
>>>>> age = models.PositiveIntegerField()
>>>>> profile_photo = models.ImageField(blank = True)
>>>>>
>>>>> def save(self, *args, **kwargs):  # new
>>>>> slug_save(self)
>>>>> get_ID(self)
>>>>> return super().save(*args, **kwargs)
>>>>>
>>>>> def __str__(self):
>>>>> return self.name
>>>>>
>>>>> class PetPhoto(models.Model):
>>>>

Ordering of code

2023-03-03 Thread Michael Starr
Does anyone know why in django models (and I don't know how it is in etc. 
python), you can define a function below, and use it above in the code, but 
a class can't reference a class defined later in the code, or it won't find 
it?

That seems like beyond stupid to me.

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/2409c040-107d-40e3-a828-0013851d0d98n%40googlegroups.com.


Re: django.db.utils.OperationalError: foreign key mismatch - "pet_profile_petphoto_pet" referencing "pet_profile_petphoto"

2023-03-02 Thread Michael Starr
Now I am trying
https://stackoverflow.com/questions/28385919/django-no-such-table-for-custom-user-profile-why
But it doesn't get rid of
OperationalError at /admin/pet_profile/pet/ no such table: pet_profile_pet 

Django is acting as though it has hidden memory somewhere, outside of the 
db.sqlite database and the migration files. I deleted all of them, redid 
the makemigration command, redid migrate, and there was some text, namely

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK

So it seems to have worked.

But the error, operationalerror no such table, is still there.

I have to recreate the superuser, as a side note, but I don't think this is 
relevant.

Leaning toward posting this in stackoverflow soon. Will take some time to 
edit, polish, and edit again and again the question so that it is up to the 
perfectionist standards of the stackoverflow tzars.

Michael

On Thursday, March 2, 2023 at 2:02:36 PM UTC-8 Michael Starr wrote:

> Including not even finding the basic model field Pet, the most basic thing
> OperationalError at /admin/pet_profile/pet/ no such table: pet_profile_pet 
> It's totally effed.
>
> Michael
> On Thursday, March 2, 2023 at 2:01:15 PM UTC-8 Michael Starr wrote:
>
>> This
>>
>> https://stackoverflow.com/questions/62726885/foreign-key-mismatch-comment-referencing-chellenge
>> seems to work, but now I am getting a slew of database table model errors.
>>
>>
>>
>> On Wednesday, March 1, 2023 at 12:35:59 PM UTC-8 Michael Starr wrote:
>>
>>> I even deleted the pet field from pet_photo and it still gives this 
>>> error, even after deleting the db.sqlite3 database and remigrating. Makes 
>>> no sense whatsoever. The error is now referencing something that is not 
>>> even there!
>>> Michael
>>>
>>> On Wednesday, March 1, 2023 at 12:33:00 PM UTC-8 Michael Starr wrote:
>>>
>>>> I have an error when I migrate my models. makemigrations passes just 
>>>> fine, but upon migrate, it seems to think there is some error in the 
>>>> pet_photo class' pet parameter and the pet_photo class:
>>>> class Pet(models.Model):
>>>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>>>> True, null=False)
>>>> name = models.CharField(max_length = 255, unique = False)
>>>> id = models.CharField(max_length = 261, unique = True, default = 
>>>> uuid.uuid1)
>>>> animaltype = models.CharField(choices = ANIMALTYPE_CHOICES, 
>>>> max_length = 255, default="the one that barks")
>>>> age = models.PositiveIntegerField()
>>>> profile_photo = models.ImageField(blank = True)
>>>>
>>>> def save(self, *args, **kwargs):  # new
>>>> slug_save(self)
>>>> get_ID(self)
>>>> return super().save(*args, **kwargs)
>>>>
>>>> def __str__(self):
>>>> return self.name
>>>>
>>>> class PetPhoto(models.Model):
>>>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>>>> True, null=False)
>>>> title = models.CharField(max_length = 255)
>>>> id = models.CharField(max_length = 261, default=uuid.uuid1)
>>>> pet = models.ManyToManyField(Pet, related_name="Pet_Photos")
>>>> photo = models.ImageField(blank = False)
>>>>
>>>> def save(self, *args, **kwargs):  # new
>>>> slug_save(self)
>>>> get_ID(self)
>>>> return super().save(*args, **kwargs)
>>>>
>>>> def __str__(self):
>>>> return self.title
>>>>
>>>> I don't see what's wrong. I have a manytomany field where each photo is 
>>>

Re: django.db.utils.OperationalError: foreign key mismatch - "pet_profile_petphoto_pet" referencing "pet_profile_petphoto"

2023-03-02 Thread Michael Starr
Including not even finding the basic model field Pet, the most basic thing
OperationalError at /admin/pet_profile/pet/ no such table: pet_profile_pet 
It's totally effed.

Michael
On Thursday, March 2, 2023 at 2:01:15 PM UTC-8 Michael Starr wrote:

> This
>
> https://stackoverflow.com/questions/62726885/foreign-key-mismatch-comment-referencing-chellenge
> seems to work, but now I am getting a slew of database table model errors.
>
>
>
> On Wednesday, March 1, 2023 at 12:35:59 PM UTC-8 Michael Starr wrote:
>
>> I even deleted the pet field from pet_photo and it still gives this 
>> error, even after deleting the db.sqlite3 database and remigrating. Makes 
>> no sense whatsoever. The error is now referencing something that is not 
>> even there!
>> Michael
>>
>> On Wednesday, March 1, 2023 at 12:33:00 PM UTC-8 Michael Starr wrote:
>>
>>> I have an error when I migrate my models. makemigrations passes just 
>>> fine, but upon migrate, it seems to think there is some error in the 
>>> pet_photo class' pet parameter and the pet_photo class:
>>> class Pet(models.Model):
>>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>>> True, null=False)
>>> name = models.CharField(max_length = 255, unique = False)
>>> id = models.CharField(max_length = 261, unique = True, default = 
>>> uuid.uuid1)
>>> animaltype = models.CharField(choices = ANIMALTYPE_CHOICES, 
>>> max_length = 255, default="the one that barks")
>>> age = models.PositiveIntegerField()
>>> profile_photo = models.ImageField(blank = True)
>>>
>>> def save(self, *args, **kwargs):  # new
>>> slug_save(self)
>>> get_ID(self)
>>> return super().save(*args, **kwargs)
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>> class PetPhoto(models.Model):
>>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>>> True, null=False)
>>> title = models.CharField(max_length = 255)
>>> id = models.CharField(max_length = 261, default=uuid.uuid1)
>>> pet = models.ManyToManyField(Pet, related_name="Pet_Photos")
>>> photo = models.ImageField(blank = False)
>>>
>>> def save(self, *args, **kwargs):  # new
>>> slug_save(self)
>>> get_ID(self)
>>> return super().save(*args, **kwargs)
>>>
>>> def __str__(self):
>>> return self.title
>>>
>>> I don't see what's wrong. I have a manytomany field where each photo is 
>>> manytomany to any number of pets (I don't know the correct terminology for 
>>> this, if someone could correct my grammar please do so). But so what? I 
>>> have manytomanyfield in other area of models:
>>>
>>> class PetOwner(models.Model):
>>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>>> True, null=False)
>>> name = models.CharField(max_length = 255)
>>> id = models.CharField(max_length = 261, unique = True, default=uuid.
>>> uuid1)
>>> age = models.PositiveIntegerField()
>>> location = models.CharField(max_length = 255)
>>> profile_photo = models.ImageField(blank = True)
>>> pets = models.ManyToManyField(Pet, related_name = "Owners")
>>>
>>> def get_absolute_url(self):
>>> return reverse("owner_profile", kwargs={"slug": self.slug})  
>>>
>>> def save(self, *args, **kwargs):  # new
>>> slug_save(self)
>>> get_ID(self)
>>> return super().save(*args, **kwargs)
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>> and no error ever.
>>>
>>> Most of the google search results say to delete the migration .pyc files 
>>> under the migrations/ folder buut they don't seem relevant. It's just 
>>> like, added this parameter, changed this variable. There's nothing that 
>>> really points to the manytomany relationship between pet and pet_photo in 
>>> there, is what I am saying. So I don't see how deleting them (after rolling 
>>> back the migrations, of course--though I think it will automatically 
>>> reconstruct them either way so you don't have to roll them back per se 
>>> before deleting them) would do anything. I tried deleting the most recent 
>>> three and redid the database migrations and nothing worked.
>>>
>>> I'm stuck on this one. Google is not being too useful.
>>>
>>> Any help is appreciated.
>>>
>>> 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/97db723d-f393-4c15-b339-8814df6b6955n%40googlegroups.com.


Re: django.db.utils.OperationalError: foreign key mismatch - "pet_profile_petphoto_pet" referencing "pet_profile_petphoto"

2023-03-02 Thread Michael Starr
This
https://stackoverflow.com/questions/62726885/foreign-key-mismatch-comment-referencing-chellenge
seems to work, but now I am getting a slew of database table model errors.



On Wednesday, March 1, 2023 at 12:35:59 PM UTC-8 Michael Starr wrote:

> I even deleted the pet field from pet_photo and it still gives this error, 
> even after deleting the db.sqlite3 database and remigrating. Makes no sense 
> whatsoever. The error is now referencing something that is not even there!
> Michael
>
> On Wednesday, March 1, 2023 at 12:33:00 PM UTC-8 Michael Starr wrote:
>
>> I have an error when I migrate my models. makemigrations passes just 
>> fine, but upon migrate, it seems to think there is some error in the 
>> pet_photo class' pet parameter and the pet_photo class:
>> class Pet(models.Model):
>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>> True, null=False)
>> name = models.CharField(max_length = 255, unique = False)
>> id = models.CharField(max_length = 261, unique = True, default = uuid
>> .uuid1)
>> animaltype = models.CharField(choices = ANIMALTYPE_CHOICES, 
>> max_length = 255, default="the one that barks")
>> age = models.PositiveIntegerField()
>> profile_photo = models.ImageField(blank = True)
>>
>> def save(self, *args, **kwargs):  # new
>> slug_save(self)
>> get_ID(self)
>> return super().save(*args, **kwargs)
>>
>> def __str__(self):
>> return self.name
>>
>> class PetPhoto(models.Model):
>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>> True, null=False)
>> title = models.CharField(max_length = 255)
>> id = models.CharField(max_length = 261, default=uuid.uuid1)
>> pet = models.ManyToManyField(Pet, related_name="Pet_Photos")
>> photo = models.ImageField(blank = False)
>>
>> def save(self, *args, **kwargs):  # new
>> slug_save(self)
>> get_ID(self)
>> return super().save(*args, **kwargs)
>>
>> def __str__(self):
>> return self.title
>>
>> I don't see what's wrong. I have a manytomany field where each photo is 
>> manytomany to any number of pets (I don't know the correct terminology for 
>> this, if someone could correct my grammar please do so). But so what? I 
>> have manytomanyfield in other area of models:
>>
>> class PetOwner(models.Model):
>> slug = models.SlugField(max_length = 5, primary_key = True, blank = 
>> True, null=False)
>> name = models.CharField(max_length = 255)
>> id = models.CharField(max_length = 261, unique = True, default=uuid.
>> uuid1)
>> age = models.PositiveIntegerField()
>> location = models.CharField(max_length = 255)
>> profile_photo = models.ImageField(blank = True)
>> pets = models.ManyToManyField(Pet, related_name = "Owners")
>>
>> def get_absolute_url(self):
>> return reverse("owner_profile", kwargs={"slug": self.slug})  
>>
>> def save(self, *args, **kwargs):  # new
>> slug_save(self)
>> get_ID(self)
>> return super().save(*args, **kwargs)
>>
>> def __str__(self):
>> return self.name
>>
>> and no error ever.
>>
>> Most of the google search results say to delete the migration .pyc files 
>> under the migrations/ folder buut they don't seem relevant. It's just 
>> like, added this parameter, changed this variable. There's nothing that 
>> really points to the manytomany relationship between pet and pet_photo in 
>> there, is what I am saying. So I don't see how deleting them (after rolling 
>> back the migrations, of course--though I think it will automatically 
>> reconstruct them either way so you don't have to roll them back per se 
>> before deleting them) would do anything. I tried deleting the most recent 
>> three and redid the database migrations and nothing worked.
>>
>> I'm stuck on this one. Google is not being too useful.
>>
>> Any help is appreciated.
>>
>> 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/1461c3d0-f4ae-403e-8926-49f12cb47626n%40googlegroups.com.


NoReverseMatch--Seems that Django doesn't detect the app url

2023-02-25 Thread Michael Starr
I have a pet memorial project, and some urls in pet_memorial

pet memorial urls.py
from django.contrib import admin
from django.urls import path, include
from . import views

urlpatterns = [
path('admin/', admin.site.urls),
path('home/', views.HomeView.as_view(), name='home_view'),
path('', include('pet_profile.urls')),
]

and some urls in the pet_profile app

pet profile app urls.py
from django.contrib import admin
from django.urls import path
from pet_profile import views

urlpatterns = [
path("pet//", views.PetDetailView.as_view(), name = 
"pet_profile"),
path("owner//", views.PetOwnerProfileView.as_view(), name = 
"owner_profile"),
]

As you can see, pet memorial urls has an include call which includes the 
pet profile urls, so theoretically it should be checking for all urls 
whether they are in the project or in the app.

Now, I am trying to use the owner_profile url name to create a 
template-tagg'd anchor url link to the pet_owner_profile.html template.

home.html
{% extends "base.html" %}
{% block header %}

{% endblock %}
{% block content %}
test
{% endblock %}

In the views file I previously had template_name set to home.html, but now 
it is pet_owner_profile.html. I think that makes more sense? Otherwise the 
link would point back to itself.

views.py
from django.shortcuts import render
from django.views.generic import (TemplateView,ListView,
  DetailView,CreateView,
  UpdateView,DeleteView)
from pet_profile.models import PetOwner, Pet, PetPhoto, PetStory

class PetOwnerListView(ListView):
model = PetOwner
context_object_name = "owner_list"
template_name = "home.html"

*class PetOwnerProfileView(DetailView):*
*model = PetOwner*
*context_object_name = "owner"*
*template_name = "pet_owner_profile.html"*

class PetListView(ListView):
model = Pet
context_object_name = "pet_list"

class PetDetailView(DetailView):
model = Pet
context_object_name = "pet"

class PetPhotoListView(ListView):
model = PetPhoto
context_object_name = "pet_photo_list"

class PetPhotoDetailView(DetailView):
model = PetPhoto
context_object_name = "pet_photo"

class PetStoryListView(ListView):
model = PetStory
context_object_name = "pet_story_list"

class PetStoryDetailView(DetailView):
model = PetStory
context_object_name = "pet_story"


In either case, I get a noreversematch error when trying to render the home 
html page that includes the url template tag with owner_profile as the 
template tag name. It is a valid url name so I don't understand why it 
doesn't detect it. I don't know quite what's going on.

error:
NoReverseMatch at /home/ Reverse for 'owner_profile' with no arguments not 
found. 1 pattern(s) tried: ['owner/(?P[-a-zA-Z0-9_]+)/\\Z'] 
Request Method: 
GET 
Request URL: 
http://127.0.0.1:8000/home/ 
Django Version: 
4.1.7 
Exception Type: 
NoReverseMatch 
Exception Value: 
Reverse for 'owner_profile' with no arguments not found. 1 pattern(s) 
tried: ['owner/(?P[-a-zA-Z0-9_]+)/\\Z'] 
Exception Location: 
C:\Users\starr\Code\pet_memorial\.venv\Lib\site-packages\django\urls\resolvers.py,
 
line 828, in _reverse_with_prefix 
Raised during: 
pet_memorial.views.HomeView 
Python Executable: 
C:\Users\starr\Code\pet_memorial\.venv\Scripts\python.exe 
Python Version: 
3.11.2 
Python Path: 
['C:\\Users\\starr\\Code\\pet_memorial', 'C:\\Program 
Files\\Python311\\python311.zip', 'C:\\Program Files\\Python311\\DLLs', 
'C:\\Program Files\\Python311\\Lib', 'C:\\Program Files\\Python311', 
'C:\\Users\\starr\\Code\\pet_memorial\\.venv', 
'C:\\Users\\starr\\Code\\pet_memorial\\.venv\\Lib\\site-packages'] 
Server time: 
Sat, 25 Feb 2023 20:15:57 + 
Error during template rendering 

In template 
C:\Users\starr\Code\pet_memorial\pet_memorial\templates\pet_memorial\home.html, 
error at line *6*
Reverse for 'owner_profile' with no arguments not found. 1 pattern(s) 
tried: ['owner/(?P[-a-zA-Z0-9_]+)/\\Z'] 
1 
{% extends "base.html" %} 
2 
{% block header %} 
3 

4 
{% endblock %} 
5 
{% block content %} 
6 
test 
7 

8 
{% endblock %} 
Traceback Switch to copy-and-paste view  

   - 
   
C:\Users\starr\Code\pet_memorial\.venv\Lib\site-packages\django\core\handlers\exception.py,
 
   line 56, in inner 
   1. response = get_response(request) …
   Local vars 
   - 
   
C:\Users\starr\Code\pet_memorial\.venv\Lib\site-packages\django\core\handlers\base.py,
 
   line 220, in _get_response 
   1. response = response.render() …
   Local vars 
   - 
   
C:\Users\starr\Code\pet_memorial\.venv\Lib\site-packages\django\template\response.py,
 
   line 114, in render 
   1. self.content = self.rendered_content …
   Local vars 
   - 
   
C:\Users\starr\Code\pet_memorial\.venv\Lib\site-packages\django\template\response.py,
 
   line 92, in rendered_content 
   1. return template.render(context, self._request) …
   Local vars 
   - 
   

Re: Forum on WhatsApp

2022-12-23 Thread Michael Starr
You might want to explain a little bit more if you want people to join, 
which is what I'm guessing you want.
Mike

On Thursday, December 22, 2022 at 2:55:04 PM UTC-8 julika...@gmail.com 
wrote:

> https://chat.whatsapp.com/COaaB3ss9YoGJQNoGm8K6s
>

-- 
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/e70f42b2-9419-4887-8066-546193a8bb93n%40googlegroups.com.


Re: Need help Scraping a couple of websites

2022-12-23 Thread Michael Starr
Yeah it's not a DDOS or anything. They are providing the movie information 
on their site, from their databases, as-is and without warranty. That means 
you can do whatever you want with it to the fullest extent of criminal law.

But maybe I have no idea what I'm talking about.

Cheers,
Mike

On Friday, December 23, 2022 at 10:11:27 AM UTC-8 bscho...@schollnick.net 
wrote:

> > I can scrap for you. I just created an IMDB scrapper(which is illegal, 
> so not going to post the code anywhere but mailed IMDb about it) in the 
> flask.
> > Also, have experience in Django and web scrapping using bs4.
>
> illegal? Against Copyright, and maybe not permitted by End-User License. 
>
> But illegal? You’re not going to go to jail if you scrape IMDB, as an 
> individual user. If you do it as part of a company, that company will 
> probably be issued a cease and desist… And if they don’t comply they’ll get 
> IP blocked, and possibly sued. But once again, I suspect that would be 
> civil, and maybe not criminal? I’m not sure… 
>
> But IMDB can’t do anything to prevent someone from scraping the web site, 
> as a individual, as long as you don’t draw attention to yourself.
>
> - Benjamin
>
>

-- 
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/3c49e2d3-514b-4ce0-938d-29099129e85fn%40googlegroups.com.


Re: What are the default entries in a context dictionary, context[], from a View?

2022-12-22 Thread Michael Starr
Here is my code so far:

*models*
from django.db import models
from django.utils.text import slugify

class Pet(models.Model):
name = models.CharField(max_length=255)
age = models.IntegerField()
slug = models.SlugField(allow_unicode=True, max_length=100, 
unique=True, default="default_pet_slug")

def __str__(self):
return self.name

def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)

def get_absolute_url(self):
return reverse("pet:pet_details", kwargs={"slug": self.slug})

*views*
from django.views.generic.detail import DetailView
from pet.models import Pet

class PetDetailView(DetailView):
model = Pet
template_name = "pet_profile.html"

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
pets = Pet.objects
for pet in pets:
context[pet.name] = pet
return context

*home.html*


  

Pet Memorial
  
  
{% for pet in pets %}
  Pet Profile: {{ pet 
}}
{% endfor %}
  



I get no errors, but nothing shows up. I have verified that there is an 
entry in Pet ("Mocha").

Mike

On Thursday, December 22, 2022 at 5:17:34 PM UTC-8 Michael Starr wrote:

> I got an answer for ListView here 
> <https://stackoverflow.com/questions/60156251/get-context-data-method-django> 
> but I don't know if that's the same for all views. Probably not would be my 
> guess.
> Mike
>
> On Thursday, December 22, 2022 at 3:05:34 PM UTC-8 Michael Starr wrote:
>
>> I am starting to understand context dictionaries, and I figured out from 
>> some Googling that the get_context_dictionary method belongs in a View, the 
>> one that you want to provide entries for its corresponding template.
>>
>> My question is somewhat academic: Why can't I just use the context 
>> dictionary plan/vanilla " ", and if I can, what are the default entries 
>> labeled? If not, I understand how to add entries to them no problem.
>>
>> Code would be something like what is shown at this tutorial 
>> <https://riptutorial.com/django/example/3996/context-data>.
>>
>> Thank you very much.
>>
>> Mike
>>
>

-- 
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/a2638a04-407d-418d-a8a6-c3d7cffc72den%40googlegroups.com.


Re: What are the default entries in a context dictionary, context[], from a View?

2022-12-22 Thread Michael Starr
I got an answer for ListView here 
<https://stackoverflow.com/questions/60156251/get-context-data-method-django> 
but I don't know if that's the same for all views. Probably not would be my 
guess.
Mike

On Thursday, December 22, 2022 at 3:05:34 PM UTC-8 Michael Starr wrote:

> I am starting to understand context dictionaries, and I figured out from 
> some Googling that the get_context_dictionary method belongs in a View, the 
> one that you want to provide entries for its corresponding template.
>
> My question is somewhat academic: Why can't I just use the context 
> dictionary plan/vanilla " ", and if I can, what are the default entries 
> labeled? If not, I understand how to add entries to them no problem.
>
> Code would be something like what is shown at this tutorial 
> <https://riptutorial.com/django/example/3996/context-data>.
>
> Thank you very much.
>
> Mike
>

-- 
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/b13641d0-36ff-47fe-a866-5b8f855e5f8en%40googlegroups.com.


What are the default entries in a context dictionary, context[], from a View?

2022-12-22 Thread Michael Starr
I am starting to understand context dictionaries, and I figured out from 
some Googling that the get_context_dictionary method belongs in a View, the 
one that you want to provide entries for its corresponding template.

My question is somewhat academic: Why can't I just use the context 
dictionary plan/vanilla " ", and if I can, what are the default entries 
labeled? If not, I understand how to add entries to them no problem.

Code would be something like what is shown at this tutorial 
.

Thank you very much.

Mike

-- 
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/090b0296-a575-4b91-973b-aa6c34bfbf44n%40googlegroups.com.


Re: URL evaluates to 'slug' literally instead of the variable slug

2022-12-20 Thread Michael Starr
No reply yet, so bump.

On Friday, December 16, 2022 at 5:51:14 PM UTC-8 Michael Starr wrote:

> I hope someone is still subscribed to this post. I had another question...
>
> I looked up your link, about context dictionary, presumably to modify the 
> value returned by the function, like you said, to add the pets to it. I 
> don't know what to loop or iterate over to get all the pets, first off. I 
> know how to add them, I think, that would just be context[pet id or 
> something] = . Secondly, I'm assuming this function, 
> get_context_data, goes in the models file. I understand how to retrieve 
> context from the dictionary, you explained that as well as the professor in 
> the course I took on Django, so no problems there (so far).
>
> I think that's it, actually.
>
> Thanks in advance, hugely appreciate any help anyone can offer.
>
> Best,
> Mike
>
> On Thursday, December 15, 2022 at 2:54:59 PM UTC-8 Michael Starr wrote:
>
>> Sorry for that crass, asinine comment. I had a flare up of my condition.
>> Thank you all for the help.
>> Mike
>>
>> On Sunday, December 11, 2022 at 4:32:04 PM UTC-8 Michael Starr wrote:
>>
>>> It's poorly written and mine isn't. Am I better than them.
>>
>>
>>>
>>> On Monday, December 5, 2022 at 6:36:30 AM UTC-8 elvisa...@gmail.com 
>>> wrote:
>>>
>>>> Good !
>>>>
>>>> Le dim. 4 déc. 2022 à 22:04, Michael Starr  a 
>>>> écrit :
>>>>
>>>>> Thank you, Peter. I forgot to acknowledge your contribution.
>>>>>
>>>>> On Wednesday, November 30, 2022 at 4:43:47 PM UTC-8 Ryan Nowakowski 
>>>>> wrote:
>>>>>
>>>>>> On Wed, Nov 30, 2022 at 09:16:39AM -0800, Michael Starr wrote: 
>>>>>> > Thank you. Though, that hard codes everything, which is bad. How do 
>>>>>> I 
>>>>>> > generalize it? 
>>>>>>
>>>>>> You'll need to do 2 things: 
>>>>>>
>>>>>> 1. Add the pet(s) you want to the template context, probably by 
>>>>>> implementing get_context_data[1]. 
>>>>>>
>>>>>> 2. Change your template to use the pet from the template context 
>>>>>> instead of the hard code pet, Mocha. Assuming your pet in the template 
>>>>>> context is named 'pet': 
>>>>>>
>>>>>> Pet Profile: {{ 
>>>>>> pet.name }} 
>>>>>>
>>>>>> ...alternatively since you've implemented get_absolute_url: 
>>>>>>
>>>>>> Pet Profile: {{ pet.name }} 
>>>>>>
>>>>>>
>>>>>> [1] 
>>>>>> https://docs.djangoproject.com/en/4.1/ref/class-based-views/mixins-simple/#django.views.generic.base.ContextMixin.get_context_data
>>>>>>  
>>>>>>
>>>>> -- 
>>>>> 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...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0876cdf6-9e88-4336-9254-52aac5738c34n%40googlegroups.com.


Re: URL evaluates to 'slug' literally instead of the variable slug

2022-12-16 Thread Michael Starr
I hope someone is still subscribed to this post. I had another question...

I looked up your link, about context dictionary, presumably to modify the 
value returned by the function, like you said, to add the pets to it. I 
don't know what to loop or iterate over to get all the pets, first off. I 
know how to add them, I think, that would just be context[pet id or 
something] = . Secondly, I'm assuming this function, 
get_context_data, goes in the models file. I understand how to retrieve 
context from the dictionary, you explained that as well as the professor in 
the course I took on Django, so no problems there (so far).

I think that's it, actually.

Thanks in advance, hugely appreciate any help anyone can offer.

Best,
Mike

On Thursday, December 15, 2022 at 2:54:59 PM UTC-8 Michael Starr wrote:

> Sorry for that crass, asinine comment. I had a flare up of my condition.
> Thank you all for the help.
> Mike
>
> On Sunday, December 11, 2022 at 4:32:04 PM UTC-8 Michael Starr wrote:
>
>> It's poorly written and mine isn't. Am I better than them.
>
>
>>
>> On Monday, December 5, 2022 at 6:36:30 AM UTC-8 elvisa...@gmail.com 
>> wrote:
>>
>>> Good !
>>>
>>> Le dim. 4 déc. 2022 à 22:04, Michael Starr  a 
>>> écrit :
>>>
>>>> Thank you, Peter. I forgot to acknowledge your contribution.
>>>>
>>>> On Wednesday, November 30, 2022 at 4:43:47 PM UTC-8 Ryan Nowakowski 
>>>> wrote:
>>>>
>>>>> On Wed, Nov 30, 2022 at 09:16:39AM -0800, Michael Starr wrote: 
>>>>> > Thank you. Though, that hard codes everything, which is bad. How do 
>>>>> I 
>>>>> > generalize it? 
>>>>>
>>>>> You'll need to do 2 things: 
>>>>>
>>>>> 1. Add the pet(s) you want to the template context, probably by 
>>>>> implementing get_context_data[1]. 
>>>>>
>>>>> 2. Change your template to use the pet from the template context 
>>>>> instead of the hard code pet, Mocha. Assuming your pet in the template 
>>>>> context is named 'pet': 
>>>>>
>>>>> Pet Profile: {{ 
>>>>> pet.name }} 
>>>>>
>>>>> ...alternatively since you've implemented get_absolute_url: 
>>>>>
>>>>> Pet Profile: {{ pet.name }} 
>>>>>
>>>>>
>>>>> [1] 
>>>>> https://docs.djangoproject.com/en/4.1/ref/class-based-views/mixins-simple/#django.views.generic.base.ContextMixin.get_context_data
>>>>>  
>>>>>
>>>> -- 
>>>> 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...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8763db79-da9f-4487-8ad2-90a3595079bdn%40googlegroups.com.


Re: URL evaluates to 'slug' literally instead of the variable slug

2022-12-15 Thread Michael Starr
Sorry for that crass, asinine comment. I had a flare up of my condition.
Thank you all for the help.
Mike

On Sunday, December 11, 2022 at 4:32:04 PM UTC-8 Michael Starr wrote:

> It's poorly written and mine isn't. Am I better than them.
>
> On Monday, December 5, 2022 at 6:36:30 AM UTC-8 elvisa...@gmail.com wrote:
>
>> Good !
>>
>> Le dim. 4 déc. 2022 à 22:04, Michael Starr  a 
>> écrit :
>>
>>> Thank you, Peter. I forgot to acknowledge your contribution.
>>>
>>> On Wednesday, November 30, 2022 at 4:43:47 PM UTC-8 Ryan Nowakowski 
>>> wrote:
>>>
>>>> On Wed, Nov 30, 2022 at 09:16:39AM -0800, Michael Starr wrote: 
>>>> > Thank you. Though, that hard codes everything, which is bad. How do I 
>>>> > generalize it? 
>>>>
>>>> You'll need to do 2 things: 
>>>>
>>>> 1. Add the pet(s) you want to the template context, probably by 
>>>> implementing get_context_data[1]. 
>>>>
>>>> 2. Change your template to use the pet from the template context 
>>>> instead of the hard code pet, Mocha. Assuming your pet in the template 
>>>> context is named 'pet': 
>>>>
>>>> Pet Profile: {{ 
>>>> pet.name }} 
>>>>
>>>> ...alternatively since you've implemented get_absolute_url: 
>>>>
>>>> Pet Profile: {{ pet.name }} 
>>>>
>>>>
>>>> [1] 
>>>> https://docs.djangoproject.com/en/4.1/ref/class-based-views/mixins-simple/#django.views.generic.base.ContextMixin.get_context_data
>>>>  
>>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/43d43c8a-6393-4398-8040-7431a915844bn%40googlegroups.com.


Re: URL evaluates to 'slug' literally instead of the variable slug

2022-12-11 Thread Michael Starr
It's poorly written and mine isn't. Am I better than them.

On Monday, December 5, 2022 at 6:36:30 AM UTC-8 elvisa...@gmail.com wrote:

> Good !
>
> Le dim. 4 déc. 2022 à 22:04, Michael Starr  a 
> écrit :
>
>> Thank you, Peter. I forgot to acknowledge your contribution.
>>
>> On Wednesday, November 30, 2022 at 4:43:47 PM UTC-8 Ryan Nowakowski wrote:
>>
>>> On Wed, Nov 30, 2022 at 09:16:39AM -0800, Michael Starr wrote: 
>>> > Thank you. Though, that hard codes everything, which is bad. How do I 
>>> > generalize it? 
>>>
>>> You'll need to do 2 things: 
>>>
>>> 1. Add the pet(s) you want to the template context, probably by 
>>> implementing get_context_data[1]. 
>>>
>>> 2. Change your template to use the pet from the template context instead 
>>> of the hard code pet, Mocha. Assuming your pet in the template context is 
>>> named 'pet': 
>>>
>>> Pet Profile: {{ pet.name 
>>> }} 
>>>
>>> ...alternatively since you've implemented get_absolute_url: 
>>>
>>> Pet Profile: {{ pet.name }} 
>>>
>>>
>>> [1] 
>>> https://docs.djangoproject.com/en/4.1/ref/class-based-views/mixins-simple/#django.views.generic.base.ContextMixin.get_context_data
>>>  
>>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/e8afb697-d067-4cc6-bda8-93dd9b8748een%40googlegroups.com?utm_medium=email_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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c209ab85-1e49-47f0-a6a2-570b48f37021n%40googlegroups.com.


Re: URL evaluates to 'slug' literally instead of the variable slug

2022-11-30 Thread Michael Starr
Thank you. Though, that hard codes everything, which is bad. How do I 
generalize it?


Also, this worked. I had to specify template_name = pet_profile.html in 
the pet detail view.



On 11/30/22 7:15 AM, Ryan Nowakowski wrote:

On Tue, Nov 29, 2022 at 06:35:25PM -0800, Michael Starr wrote:

*home folder / home.html*


   
 
 
   
   
 test
 Pet Profile: Mocha
   


In your home.html you've hard coded a link to a specific pet named Mocha.
You'll need to hard code the slug as well so:

Pet Profile: Mocha



--
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/4f4f2184-48c9-5448-2fe2-a1ae5550a89c%40spinningcow.xyz.


URL evaluates to 'slug' literally instead of the variable slug

2022-11-30 Thread Michael Starr
Code is first, query is last (below). Thanks in advance.


*home directory urls.py*
from django.contrib import admin
from django.urls import path,include
from . import views

urlpatterns = [
path("admin/", admin.site.urls, name='admin'),
path("", views.Home.as_view(), name="home"),
path("pet/", include('pet.urls')),
]



*home directory views.py*
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.base import TemplateView
from django.views.generic import View

class Home(TemplateView):
template_name = 'home.html'



*app "pet" urls.py*
from django.contrib import admin
from django.urls import path
from . import views as pet_views
from .models import Pet

urlpatterns = [
path('', pet_views.PetDetailView.as_view(), 
name='pet_details'),]



*app "pet" views.py*
from django.shortcuts import render
from django.views.generic.detail import DetailView
from pet.models import Pet

class PetDetailView(DetailView):
model = Pet
slug_url_kwarg = 'slug'
slug_field = 'slug'




*app "pet" models.py*
from django.db import models
from django.utils.text import slugify

class Pet(models.Model):
name = models.CharField(max_length=255)
age = models.IntegerField()
slug = models.SlugField(allow_unicode=True, max_length=100, 
unique=True, default="default_pet_slug")

def __str__(self):
return self.name

def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)

def get_absolute_url(self):
return reverse("pet:pet_details", kwargs={"slug": self.slug})



*apps.py*
from django.apps import AppConfig

class PetConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "pet"



*admin.py*
from django.contrib import admin
from .models import Pet

admin.site.register(Pet)



*settings.py*
"""
Django settings for pet_memorial project.

Generated by 'django-admin startproject' using Django 4.1.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 
"django-insecure-zfb*2fvvz=_komv(#8(ho)ckc-+a3$^!@tua2#n^c&0*st=xm6"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"pet",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "pet_memorial.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
'pet_memorial/templates/',
'pet/templates/',
],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = "pet_memorial.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}


# Password validation
# 
https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": 
"django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{"NAME": 
"django.contrib.auth.password_validation.MinimumLengthValidator",},
{"NAME": 
"django.contrib.auth.password_validation.CommonPasswordValidator",},
{"NAME": 
"django.contrib.auth.password_validation.NumericPasswordValidator",},
]


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
#