tickets_full: 3413

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
3413 2007-02-01 15:28:45 2007-02-14 09:45:32 2019-06-24 00:51:35.672610 Unreviewed closed Database layer (models, ORM)     master invalid You can't use AnonymousUser in the database API My situation is this: I have a model with a !OneToOne field to the User model to support the extended features that I need my users to have. In one of my views I used code like the following to branch based on whether the user is logged in: {{{ try: app_user = AppUser.objects.get(user=request.user) # show personal view for this user: ... except AppUser.DoesNotExist: # user isn't logged in; show some other view: ... }}} I think that this code worked for me with the MySQL backend, but when I changed over to sqlite3 it gave me !InterfaceError. But, I vaguely remember updating my checked-out copy of django SVN at that time, so perhaps there was a change to the codebase that caused my results. Either way, I've done some preliminary tracing and found that the sqlite3 backend code is sending SQL that looks like this: {{{ SELECT columns FROM the_table WHERE ("app_user"."user_id" = ?) with <class 'django.contrib.auth.models.AnonymousUser'> as a parameter. }}} When an actual User is given instead of !AnonymousUser, the parameter is that user's numerical id. I haven't dug deep enough into django's code to determine how !AnonymousUser should be handled in this case to produce a !DoesNotExist error (assuming that's the desired behavior), but ticket #2144 looks related. As an aside: I've changed my code to branch on request.user.is_authenticated(), and that works fine. adrian Mason Simon <>   0 0 0 0 0 0
Powered by Datasette · Query took 14.819ms