Hi Tim,

On 06/05/2015 03:44 PM, Tim Sawyer wrote:
> I've just upgraded from a very old version of Django (1.4) up to 1.7.8,
> and some behaviour isn't how I expect.  I may have missed something -
> I've not been keeping an eye on the framework changes.

I would strongly recommend that you upgrade version by version (that is,
first 1.4.x to 1.5.12, then 1.5.12 to 1.6.11, then 1.6.11 to 1.7.8),
each as a separate step, making sure that everything works as you expect
between each step, and that you carefully read the release notes (if you
haven't) for each version as you update to it.

Django tries to maintain backwards compatibility where we can, but we do
have to change and remove features sometimes. Those changes are
documented in the release notes for each version.

If you've upgraded all the way from 1.4 to 1.7 without reading the
release notes, which is what it sounds like, then I will be very
surprised if the below is the only problem you have.

> Two models, Venue and VenueAlias.  VenueAlias has a ForeignKey to Venue,
> one venue has many VenueAliases. (Full models pasted below.)
> 
> My problem is with accessing venuealias_set on my Venue, it doesn't seem
> to be limiting to Venue how it used to in the earlier version.
> 
> Here's an interactive session that shows the problem.  Venue 5854 has
> three aliases.
> 
>>>> from bbr.contests.models import Venue
>>>> lVenue = Venue.objects.filter(id=5854)[0]
>>>> lVenue
> <Venue: Royal Northern College of Music (Haden Freeman Concert Hall),
> Manchester, Greater Manchester, England, UK>
>>>> lVenue.exact
> False
>>>> lAliases = lVenue.venuealias_set.all()
>>>> len(lAliases)
> 402
>>>> print lAliases.query
> SELECT "venues_venuealias"."id", "venues_venuealias"."last_modified",
> "venues_venuealias"."created", "venues_venuealias"."name",
> "venues_venuealias"."alias_start_date",
> "venues_venuealias"."alias_end_date", "venues_venuealias"."venue_id",
> "venues_venuealias"."lastChangedBy_id", "venues_venuealias"."owner_id"
> FROM "venues_venuealias" INNER JOIN "contests_venue" ON (
> "venues_venuealias"."venue_id" = "contests_venue"."id" ) WHERE
> "contests_venue"."exact" = True ORDER BY "venues_venuealias"."name" ASC
> 
> Where's the SQL to limit by the foreign key to venue.id=5854?  Why is
> there a reference in here to contests_venue.exact?

That is very strange. I've never seen that, and I'm not aware of any
changes to Django that would cause that. Nor do I see anything in the
models code you pasted below that looks suspicious to me as a possible
cause.

I have to guess that there's some other code in your project causing
this problem, but I'm afraid I don't know what that might be.

I'm afraid the best I can advise is to go back to Django 1.4 and do the
upgrade again methodically, and see if you can track down at precisely
which version this problem first manifests.

Good luck!

Carl


> Approaching the same problem from the other direction works fine, and I
> get the correct number of aliases returned.
> 
>>>> from bbr.venues.models import VenueAlias
>>>> lVenueAliases = VenueAlias.objects.filter(venue_id=5854)
>>>> len(lVenueAliases)
> 3
>>>> print lVenueAliases.query
> SELECT "venues_venuealias"."id", "venues_venuealias"."last_modified",
> "venues_venuealias"."created", "venues_venuealias"."name",
> "venues_venuealias"."alias_start_date",
> "venues_venuealias"."alias_end_date", "venues_venuealias"."venue_id",
> "venues_venuealias"."lastChangedBy_id", "venues_venuealias"."owner_id"
> FROM "venues_venuealias" WHERE "venues_venuealias"."venue_id" = 5854
> ORDER BY "venues_venuealias"."name" ASC
> 
> On my old server, running the old django 1.4 code, both these approaches
> work as expected.  Venue and VenueAlias are actually in different
> models.py files, for historical reasons.
> 
> What have I missed?  Thanks for any input/education!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/55721CB8.9070202%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to