Re: Can't render images from database

2023-03-03 Thread Chelsea Fan
did you setup static and media files?

On Sat, Mar 4, 2023 at 3:00 AM Michael Starr  wrote:

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

-- 
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/CAJwZndfr8%3Da5jCJGRLNeKAWeersxt8sBFsWzCc%3DUKUmBxK5%3DdA%40mail.gmail.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
>  
> 
> .
>
>

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


Re: Ordering of code

2023-03-03 Thread David Nugent
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+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 
.


--
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/em52dd8be4-5db0-4ab4-96a5-097ef6e44e26%4090728edb.com.


pgpbAnhgd2Lz0.pgp
Description: PGP signature


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

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: Upload image submit by users to another serveur

2023-03-03 Thread Ahmed Mulla
Hey off the top of my head there are a bunch of ways you can do it.

1. Create a separate function that uploads the image to the new server,
call that function in the upload view(you should make it async)

2. Write the input to something like Kafka and then write read functions
that cater to different needs

3. Set a cron job that copies the images from the original server and then
uploads them to a new server (not advisable)

Let me know if these help.

On Sat, Mar 4, 2023, 1:07 AM Théodore KOSSI  wrote:

> Hello guys, I hope you are well
>
> I want to upload image submitting by user to another server
>
> Please , do you have any solutions to help me.
>
>
> --
> theodoros17@python-developer
>
> --
> 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/CAKiMjQHddZCwq%2BjnNS-VvKt90zcmGehWaM3qAB4-dg426gJ5Gg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJLn2xKatOxJBFMuXh%2BUc6Jxqe_wRdkYLq93WEx7OXcWMn5v7A%40mail.gmail.com.


Upload image submit by users to another serveur

2023-03-03 Thread Théodore KOSSI
Hello guys, I hope you are well

I want to upload image submitting by user to another server

Please , do you have any solutions to help me.


-- 
theodoros17@python-developer

-- 
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/CAKiMjQHddZCwq%2BjnNS-VvKt90zcmGehWaM3qAB4-dg426gJ5Gg%40mail.gmail.com.


Re: "Django road map and resources"

2023-03-03 Thread Prosper Lekia
Hi Yaqiinso. Just start small. All you need is a good understanding of your 
project logic, and what you want to achieve. You can also try collaborating 
on a existing project. You can always reach out to me. I started Django 
with the docs, and by studying the code base of cloned projects. I have 
currently built a an ecommerce site, an online banking app, a delivery 
tracking app, and currently working on my startup, a social media site. 
With you knowledge you can build the project of your dreams.

On Wednesday, March 1, 2023 at 5:00:43 PM UTC+1 yaqiinso wrote:

> Hello dear django developers i was learning django since december i 
> understood all the basics like how create apps,models,views,url,some 
> authentication like adding user,login and logout but still i can not make 
> the projects of my dreams like building school management system software , 
> E_commerce web, and so ,  where to go can  any one please give road map 
> that takes me to my dream ..

-- 
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/f982abf5-a498-426c-b1fb-46aed5701596n%40googlegroups.com.