Custom Query (27278 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (25 - 27 of 27278)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Ticket Resolution Summary Owner Reporter
#29388 invalid JSONField defaults to empty list gets modified Ponytech
Description

Consider this simple model :

from django.db import models
from django.contrib.postgres.fields import JSONField


class Thing(models.Model):
	name = models.CharField(max_length=100)
	features = JSONField(default=[], blank=True)

And this code snippet :

>>> t1 = Thing.objects.create(name="thing 1")
>>> t1.features.append({"f1": 42, "f2": 56})
>>> t1.features
[{'f1': 42, 'f2': 56}]
>>> t1.save()
>>> t2 = Thing.objects.create(name="thing 2")
>>> t2.features
[{'f1': 42, 'f2': 56}]

I'd expect t2 features to be an empty list.

My guess is the model default fields gets modified somehow.

#29387 worksforme GenericRelation's on proxy models do not cascade deletion nobody Mehmet Dogan
Description

For this code (from this StackOverflow question ):

class Person(models.Model):
    identity = models.CharField(max_length=13, verbose_name="ID")
    name = models.CharField(max_length=255, verbose_name="Name")
    board = GenericRelation('second_app.BoardMember') #Second Try

    def __unicode__(self):
        return self.identity

    class Meta:
        verbose_name = "Person"
        verbose_name_plural = "People"

class Student(Person):
    class Meta:
        proxy = True

class Parent(Person):
    class Meta:
        proxy = True

class Teacher(Person):
    board = GenericRelation('second_app.BoardMember') # first try
    class Meta:
        proxy = True

class BoardMember(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey('content_type', 'object_id', for_concrete_model=False)
    responsabilities = models.CharField(max_length=255)

In the 'first try', deleting the Teacher record (proxy) does not delete the BoardMember record. However, in the 'second try', deleting the Person record (concrete), does delete the BoardMember record.

#29386 invalid Meta Inheritance for default_permissions nobody Clayton Daley
Description

I add Read/Browse permissions to my models that I enforce in my views. For some reason, default_permissions isn't inheriting in the way I would expect. Nor does the Meta Inheritance section of the documentation say anything to suggest this should not be valid.

Given something like:

class BreadMetaMixin(object):
    # ACTION_EDIT aliases "change" for BREAD semantics, see http://paul-m-jones.com/archives/291
    default_permissions = (ACTION_BROWSE, ACTION_READ, ACTION_EDIT, ACTION_ADD, ACTION_DELETE)

class Encounter(AbstractParentModel):
    class Meta(BreadMetaMixin, AbstractParentModel.Meta):
        pass

class Admission(Encounter):
    class Meta(Encounter.Meta):
        # also reproduced with non-proxy model
        proxy = True

When I makemigrations, Encounter detects the new permissions...

...
    operations = [
        migrations.CreateModel(
            name='Encounter',
...
            options={
                'default_permissions': ('browse', 'read', 'change', 'add', 'delete'),
                'abstract': False,
            },
...

but Admissions does not:

...
    operations = [
        migrations.CreateModel(
            name='Admission',
...
            options={
                'abstract': False,
                'proxy': True,  # also verified with non-proxy model
                'indexes': [],
            },
...

It's possible that this hasn't come up because it's masked by #11154, but it affects non-proxy models as well. I noticed it because I'm working around #11154 using a migration like:

def add_proxy_permissions(apps, schema_editor):
    """Workaround https://code.djangoproject.com/ticket/11154 by manually creating the required permissions."""
    ContentType = apps.get_model('contenttypes', 'ContentType')
    Permission = apps.get_model('auth', 'Permission')
    for model in ['Admission']:
        class_ = apps.get_model('task_manager', model)
        content_type = ContentType.objects.get_for_model(class_, for_concrete_model=False)
        for perm in class_._meta.default_permissions:
            Permission.objects.get_or_create(
                content_type=content_type,
                codename='{}_{}'.format(perm, model.lower()),
            )

This works great on two meta models where BreadMetaMixin is included directly (e.g. UserProxy wraps auth.models.User and includes BreadMetaMixin). When I moved the code over to Admission, however, it wasn't working correctly. If I mixin BreadMetaMixin directly, it works fine so I've narrowed it down to a Meta Inheritance issue.

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