diff --git a/backend/app/api/listings.py b/backend/app/api/listings.py index ff44269..9b3ec10 100644 --- a/backend/app/api/listings.py +++ b/backend/app/api/listings.py @@ -27,6 +27,7 @@ from fastapi import APIRouter, Depends, Query, HTTPException, Request from pydantic import BaseModel, Field, EmailStr from sqlalchemy import select, func, and_ from sqlalchemy.ext.asyncio import AsyncSession +from sqlalchemy.orm import selectinload from app.database import get_db from app.api.deps import get_current_user, get_current_user_optional @@ -284,7 +285,7 @@ async def browse_listings( db: AsyncSession = Depends(get_db), ): """Browse active domain listings (public).""" - query = select(DomainListing).where( + query = select(DomainListing).options(selectinload(DomainListing.user)).where( DomainListing.status == ListingStatus.ACTIVE.value ) @@ -413,7 +414,9 @@ async def get_listing_by_slug( ): """Get listing details by slug (public).""" result = await db.execute( - select(DomainListing).where( + select(DomainListing) + .options(selectinload(DomainListing.user)) + .where( and_( DomainListing.slug == slug, DomainListing.status == ListingStatus.ACTIVE.value,