Custom Query (27015 matches)


Show under each result:

Results (7 - 9 of 27015)

1 2 3 4 5 6 7 8 9 10 11 12 13
Ticket Resolution Summary Owner Reporter
#29136 invalid CreateView documentation incomplete nobody Linurandy

In that url and, when create the class AuthorCreate(CreateView):, don't have absolute_url, this brings as a problem confusion.

from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy
from myapp.models import Author

class AuthorCreate(CreateView):
    model = Author
    fields = ['name']

class AuthorUpdate(UpdateView):
    model = Author
    fields = ['name']

class AuthorDelete(DeleteView):
    model = Author
    success_url = reverse_lazy('author-list')
#29135 fixed get_object_or_404() and get_list_or_404() swallow AttributeError in queryset filtering Yuri Shikanov David Hagen

Here is the code for get_list_or_404:

def get_list_or_404(klass, *args, **kwargs):
    queryset = _get_queryset(klass)
        obj_list = list(queryset.filter(*args, **kwargs))
    except AttributeError:
        klass__name = klass.__name__ if isinstance(klass, type) else klass.__class__.__name__
        raise ValueError(
            "First argument to get_list_or_404() must be a Model, Manager, or "
            "QuerySet, not '%s'." % klass__name
    if not obj_list:
        raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
    return obj_list

The try-catch block is far too broad. Any AttributeError raised during the call to filter is swallowed and converted into an incorrect and confusing error message. This should be changed to either if not hasattr(queryset, 'filter'): raise ... or try: method = queryset.filter; except AttributeError: .... The same thing happens with queryset.get(*args, **kwargs) in get_object_or_404'.

#29134 needsinfo RelatedObjectDoesNotExist & Duplicate Key Exception Occurring Sporadically nobody Jason

We are using multi-table inheritance and occasionally we'll get a RelatedObjectDoesNotExist or a IntegrityError: duplicate key value violates unique constraint.

  • Our site is active, and we successfully generate at least 10,000 new related objects per day with no issues.
  • Our primary keys are auto-value ints that are up to approximately 200 million.
  • We previously saw these errors once every 100 days, but lately we're seeing it twice a week, and our code hasnt changed much in the last few months; no new apis, model changes, etc.
  • Our multi-table inheritance is only one-level (our model has a parent object, and about 8 inherited objects), where we perform many adds and deletes. Nowhere in our codebase do we create or delete parent objects - we always work on the inherited objects.
  • Other objects that do not use multi-table inheritance have never had an issue with duplicate keys.
  • We use django 1.8, PostgreSQL 9.5.10, Ubuntu 16.04; the db & webserver run on the same machine with 12 cores, 48gb of memory

Is there an existing bug we are unaware of? Why would we get duplicate keys and RelatedObjectDoesNotExist only occasionally?

1 2 3 4 5 6 7 8 9 10 11 12 13
Note: See TracQuery for help on using queries.
Back to Top