specialunderwear / django-easymode Goto Github PK
View Code? Open in Web Editor NEWQuickly build backends for flash/flex websites with Django.
License: GNU General Public License v3.0
Quickly build backends for flash/flex websites with Django.
License: GNU General Public License v3.0
Hello,
want to say great job on easymode, I made changes to it by your tutorial for 1.4 and it works great except 1 thing.
In 1.3.1 - Django admin was using links which basically made you to stay in admin on certain language, example:
Django 1.4:
So I have 2 versions of website in 1.3.1 and 1.4 - I want to achieve that person with Italian language will stay on Italian, without
changing the 'localeurl' in the url every record he is changing...
I would like to do it without editing the core of django to be like in 1.3.1, I think there must be a proper way to do it with cookies
maybe not sure, I am not PRO in Django so if you already know if you can share how to achieve this, thanks a lot.
Great work by the way.
In Django 1.3 and 1.4 it's possible to have readonly fields in the admin.
admin.ModelAdmin.readonly_fields = ('fields', )
Easymode, however, does not understand it. When submitting a form, it makes the form invalid. It should not validate the field at all. I created a test to demonstrate it.
https://gist.github.com/4336937
Also the readonly field is displayed twice.
I used this easymode version:
pip install git+https://github.com/specialunderwear/django-easymode.git@a978994c9410b7706c4a2935d596e172a9c8055a#egg=django_easymode-dev
The test which fails is: test_form_submit_submit_readonly. We suspect the L10N decorator to screw things up.
I18n is not working at all with the latest django beta. Fix this when 1.4-rc-1 is released.
As of Django 1.3, the unique_error_message method has moved from the form to the model. For models with a unique slug field, this causes the following error upon saving:
AttributeError: 'RecipeForm' object has no attribute 'unique_error_message'
It happens here:
if qs.extra(select={'a': 1}).values('a').order_by():
self._errors[field_name] = ErrorList([self.unique_error_message([field_name])]) <---
bad_fields.add(field_name)
It is useful to hide parent_link field totally while editing a sub-model using InvisibleModelAdmin. The following snippet does it.
from easymode.tree.admin.relation import InvisibleModelAdmin
from django.forms.widgets import HiddenInput
class HideParentModelAdmin(InvisibleModelAdmin):
def get_fieldsets(self, request, obj=None):
fss = super(HideParentModelAdmin,self).get_fieldsets(request,obj)
found = False
newfss = [(f[0],f[1].copy()) for f in fss]
for fs in newfss:
cols = []
for fcol in fs[1]['fields']:
if isinstance(fcol,basestring):
if fcol == self.parent_link:
found = True
continue
cols.append(fcol)
continue
rows = []
for frow in fcol:
if frow == self.parent_link:
found = True
continue
rows.append(frow)
if rows:
cols.append(tuple(rows))
fs[1]['fields'] = tuple(cols)
if found:
newfss.append( ('',{'fields':((self.parent_link,),),'classes':['collapse',]}) )
return newfss
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
if db_field.name == self.parent_link:
kwargs['widget'] = HiddenInput
return super(HideParentModelAdmin,self).formfield_for_foreignkey(db_field, request, **kwargs)
save_as = True
Just because the "Save and add another" button does not have sense in this case, it has been changed to "Save As" button.
I have a very simple model, with just one translatable field (using the I18n decorator in models.py).
If I want to display only the field for the current language in the admin interface, I use the L10n decorator in admin.py.
But then, it appears that I got two columns with checkboxes in the admin interface for this particular model.
Moreover, if I check one of the second column checkboxes, when I want to do some action (deleting in this case), the browser pops up a message saying that I have unsaved modifications on some editable fields, and I need to confirm by hitting "OK", or cancel by hitting "Cancel".
Then, even if I uncheck all the second column checkboxes, the message still pops up when I submit the action.
This is not a major issue but it can be confusing / annoying for people using the admin interface.
I am using Django 1.6.5 and django-easymode 1.4b4
as seen in the following 2 line of code from L10n:
# hide added fields from form and admin
cls.exclude = added_fields
L10n uses the exclude field to hide the added fields from the admin. This seems to completely overwrite any pre existing value. When the decorator is applied to a ModelAdmin with a customized exclude field, this creates problems for obvious reasons.
when syncdb was called it gave this error with django 1.6
python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 2, in
from django.core.management import execute_manager
ImportError: cannot import name execute_manager
when i searched for the error it said execute_manager has been completely removed in 1.6.
Let we have two classes, f.e.:
class Top(models.Model):
pass
class Bottom(models.Model):
top = models.ForeignKey(Top)
and tree admin view where the Top is a root object class, while Bottom is a leaf object class.
User having no permissions to add a new Bottom object should not see the "Add ..." button in a tree view
User having no permissions to add a new Bottom object should not see the empty Bottom object in a tree view
User having no permissions to edit the Bottom object should not see the "Edit ..." button/link in a tree view
User having no permissions to edit the Bottom object should not see editable fields in a tree view
User having no permissions to delete the Bottom object should not see the "Delete ..." checkbox in a tree view
Hi Folks,
What a little gem of a module is this, according to the documentation! It does work exactly how I had my translations in mind, and actually how I started building it. But I found too many traps during programming it myself, so that is why I started looking around if somebody else had done it 'my' way, and I found Django EasyMode!
One question:
Does it work with Django 1.7.8?
Should I use version 0.14.5 (default from pypi) or another?
The django 1.3 has the static files subsystem which scans 'static' directories to see what files should be copied or linked to the 'static' directory of the project using your application. Just make a link or copy the 'media' directory to the 'static' to make this option available for application users.
ImportError: cannot import name tzinfo
django version 1.10
Hi. Can you some deprecation warnings and wrong imports for support Django 1.8?
Hi I'm on Django 1.11.29
and using python 2.7
I have a dockerised application and I tried to install almost all version of your package unsuccessfully receiving always the same error in the description.
From a look at the files in your repo I can see the error have no reason to exists because it has been solved already. Nevertheless, it seems like pip install is not updated so before anyone else run into the same time wasting issue, here is how to solve it:
in your requirements.txt use this:
git+https://github.com/specialunderwear/django-easymode.git@master
instead of Django-easymode==1.4b5
The wrong import causes easymode.tree.admin.abstract module unusable in django 1.5
The force_unicode function is wrongly imported from django.utils.translation instead of django.utils.encoding as in other parts of code.
The git-generated diff for necessary changes is present below:
diff --git a/easymode/tree/admin/forms.py b/easymode/tree/admin/forms.py
index 63b52c3..533d5d5 100644
--- a/easymode/tree/admin/forms.py
+++ b/easymode/tree/admin/forms.py
@@ -1,7 +1,7 @@
from django.core.urlresolvers import reverse
from django.forms import IntegerField
from django.forms.models import BaseInlineFormSet
-from django.utils.translation import force_unicode
+from django.utils.encoding import force_unicode
from easymode.tree.admin.widgets.foreignkey import LinkWidget
For some reason, the LinkInline doesn't show inline objects except the first one.
I've created a very simple example with two models:
from django.db import models
# Create your models here.
class Top(models.Model):
text = models.TextField()
class Bottom(models.Model):
top = models.ForeignKey(Top)
text = models.TextField()
and created a simple admin for them:
from django.contrib import admin
from django.conf.urls.defaults import *
from easymode.tree.admin.abstract import LinkInline, LinkedItemAdmin
from easymode.tree.admin.relation import InvisibleModelAdmin
from testone import models
class BottomInline(LinkInline):
model = models.Bottom
parent_link = 'top'
class BottomAdmin(InvisibleModelAdmin):
model = models.Bottom
parent_link = 'top'
admin.site.register(models.Bottom,BottomAdmin)
class TopAdmin(LinkedItemAdmin):
inlines = [
BottomInline,
]
admin.site.register(models.Top,TopAdmin)
'''
class BottomInline(admin.TabularInline):
model = models.Bottom
class TopAdmin(admin.ModelAdmin):
inlines = [
BottomInline,
]
admin.site.register(models.Top,TopAdmin)
'''
The first (uncommented) portion of the admin is working with easymode, while the second one (commented out) is a standard django admin code.
I am filling in one Top object and several Bottom objects linked to the Top one. When I am looking to the standard admin, I see several filled objects:
https://docs.google.com/open?id=0B6V0N4fDeXFPNjJjZGExMDMtNjk5Yi00NzZiLWE2MjctZDVjNjE5OWRlNDM4
When I am looking to the easymode-powered admin, I see the only one Bottom object filled, but several object lines with links (links are working):
https://docs.google.com/open?id=0B6V0N4fDeXFPYzM5MGZlMGItNjExYi00MGRhLTkwMjUtYjEwZDViZGEwNTU5
The package I installed with pip (version 1.0b1
) seems to be missing this line in the localize_fields
function. The result is that when using the I18n
decorator, the locale attributes all retain the name of the original field and thus get_localized_field_name
always returns None when trying to add the extra localized attributes to a new instance of the model object.
After installing the package from GitHub the issue was fixed, so it looks like there's a discrepancy between the package published in pip and the source code on GitHub's master
branch. Let me know if there's anything I can do to help!
/usr/local/lib/python3.5/dist-packages/django_easymode-1.4b5-py3.5.egg/easymode/utils/init.py", line 14, in
import urlparse
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.