Giter Club home page Giter Club logo

Comments (11)

jrief avatar jrief commented on May 30, 2024

This is weird, you declare the field in the parent class and the ordering for the field in the derived class.
What if you also put the ordering = ['order']into the Meta class of the parent?

from django-admin-sortable2.

burakk avatar burakk commented on May 30, 2024

I have tried that too... And i looked at the inspector... ajax call result is empty list.... But when using without abstract class ajax result is a list containing order and primary keys...

from django-admin-sortable2.

burakk avatar burakk commented on May 30, 2024

My complete parent class is as:

class Media(models.Model):
title = models.CharField(unique = True, max_length=200)
descr = models.TextField(blank=True, null=True)
excerpt = models.CharField(max_length=250, blank=True, null=True)
slug = models.SlugField(editable=False)
pub_date = models.DateTimeField(_('date published'), auto_now_add=True)
tags = TaggableManager(blank=True)
order = models.PositiveSmallIntegerField("Order", blank=False, null=False )

def filename(self):
    return os.path.basename(self.file.name) 

def save(self, *args, **kwargs):
    self.slug = slugify(self.title)
    super(Media, self).save(*args, **kwargs)

class Meta:
    abstract = True


def __unicode__(self):  
    return self.title  

def extension(self):
    name, extension = os.path.splitext(self.file.name)
    return extension 

And in admin

class ModelImageAdmin (SortableAdminMixin, AdminImageMixin, admin.ModelAdmin):

list_display = ('title',   )  
def formfield_for_foreignkey(self, db_field, request, **kwargs):
       if db_field.name == 'content_type':
           kwargs['queryset'] = ContentType.objects.filter(name__regex=r'(^work$|^entry$)')
       return super(ModelImageAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
# define the autocomplete_lookup_fields
autocomplete_lookup_fields = {
    'generic': [['content_type', 'object_id'],],
} 

from django-admin-sortable2.

jrief avatar jrief commented on May 30, 2024

OK, I will have a look at is next week.

from django-admin-sortable2.

burakk avatar burakk commented on May 30, 2024

Ok. I think i have found the problem. I have used south to migrate the models. And used 0(zero) for order field for existing fields. So all the instances had zero for order fields and list_sortable.js send zero to django... so nothing updates...
I will try to change the order field values manually now

from django-admin-sortable2.

jrief avatar jrief commented on May 30, 2024

have a look at these data-migration scripts: https://github.com/jrief/django-admin-sortable2#initial-data

from django-admin-sortable2.

burakk avatar burakk commented on May 30, 2024

Thanks. It is solved.

I have used adminsortable before but adminsortable2 is more useful for me. Do you think about changing your librarie's name with a more unique one in order to prevent confusions with adminsortable?

Thank you again for a good library like this

from django-admin-sortable2.

jrief avatar jrief commented on May 30, 2024

any proposals?

from django-admin-sortable2.

burakk avatar burakk commented on May 30, 2024

simply_sortable, easy_sortable, inorder, inorder_instances, model_inorder, model_sorter,
...

from django-admin-sortable2.

jrief avatar jrief commented on May 30, 2024

I'm not that unhappy with django-admin-sortable2. In the first place I started with django-admin-sortable, but then had the need to make an existing model sortable. There I was unable to use django-admin-sortable and so I tried to fix it. But django-admin-sortable is broken by design and unfixable for my needs, so I started a new project from scratch.

from django-admin-sortable2.

victor-yunenko avatar victor-yunenko commented on May 30, 2024

Odd, I just stumbled into a very similar problem.

I got what initial data is about, but what confused me is that I didn't need to run python manage.py reorder when I added it to a Model that had no abstract parent?

After the investigation I concluded that the only significant difference between the Model that I extended with sorting and which worked without the manage.py command, and the one that didn't work was the abstract = True parent.

I found that ticket because I started searching for abstract keyword.

Maybe it would be possible to add a django messages.error("Please run python manage.py reorder") on the reorder POST processing when the order is 0?

from django-admin-sortable2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.