Comments (11)
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.
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.
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.
OK, I will have a look at is next week.
from django-admin-sortable2.
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.
have a look at these data-migration scripts: https://github.com/jrief/django-admin-sortable2#initial-data
from django-admin-sortable2.
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.
any proposals?
from django-admin-sortable2.
simply_sortable, easy_sortable, inorder, inorder_instances, model_inorder, model_sorter,
...
from django-admin-sortable2.
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.
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)
- Signal for Model is not Triggered when Item is Dragged HOT 3
- missing template(s) for Django 4.2 HOT 3
- No handle
- Newer order values voilates the field rule of PositiveIntegerField HOT 11
- Incorrect code example in documentation (Sec. "Many-to-Many Relations")
- Don't install testapp and its child modules HOT 8
- adminsortable2 - TemplateNotFound HOT 2
- Make *only* inlines sortable and not the base model admin?!? HOT 2
- 2.1.9 version inconsistent?
- RecursionError: maximum recursion depth exceeded while calling a Python object HOT 1
- Unable to see sort column (no pads) v2.1.9 HOT 3
- Admin UI does not get added HOT 1
- Question about default value of order field HOT 4
- small typo + latest docs are not deployed? HOT 2
- What about supporting Python 3.11 and 3.12? HOT 2
- Why not adapt for django 3.2? HOT 6
- Sorting does not work for StackedInline if widget of the field has <table> HOT 2
- I am trying to add a custom formset and extend it with django.forms.models.Baseinlineformset which is not working as it is raising the error "BaseFormSet.__init__() got an unexpected keyword argument 'default_order_direction'
- Is SortableStackedInline compatible with django-polymorphic?
- Support for Django 5 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-admin-sortable2.