Re: Contract Django Developer Required - London

2012-02-09 Thread Aymeric Augustin
2012/2/9 BAC 

> I hope the group does not mind my posting this but thought it would be
> of value to the community.
>

This mailing list is dedicated to the development of Django and job offers
are off-topic. Thanks for your understanding.

You may be interested in
https://docs.djangoproject.com/en/dev/faq/general/#where-can-i-find-django-developers-for-hire

-- 
Aymeric.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Adding fields to admin forms

2012-02-09 Thread Chris Wilson

Hi all,

I want to be able to add extra fields, that I control, to the admin forms. 
For example, a read-only list of documents authored by the user, which is 
ManyToMany, so an InlineAdmin doesn't work.


The admin module docs don't really say whether this is possible or not. 
They have much more to say about excluding, reordering and making fields 
read-only. However there are hints that it's possible (for ModelForm):


* "Also, if you manually add the excluded fields back to the form, they 
will not be initialized from the model instance."


* "you can extend and reuse ModelForms by inheriting them. This is useful 
if you need to declare extra fields"


And the admin interface uses ModelForm and allows you to specify your own 
form. So I create a custom subclass of ModelForm with the new field:


from django_tables2 import tables
class DocumentsAuthoredTable(tables.Table):
...

class DocumentsAuthoredWidget(widgets.Widget):
def render(self, name, value, attrs=None):
table = DocumentsAuthoredTable(value)
return table.as_html()

class DocumentsAuthoredField(forms.Field):
widget = DocumentsAuthoredWidget


class IntranetUserReadOnlyForm(ModelForm):
class Meta:
model = models.IntranetUser

documents_authored = DocumentsAuthoredField()

Now I have to do some ugly things. The widget has no access to the 
instance (model), so I have to provide some data for it, by adding a 
method to either the IntranetUserReadOnlyForm or the model. I don't want 
to introduce a circular dependency in the model, so I have to do this in 
the form:


def __init__(self, data=None, files=None, auto_id='id_%s', 
prefix=None,

initial=None, error_class=ErrorList, label_suffix=':',
empty_permitted=False, instance=None):

"""
Add a "method" to the initial data which is used to lookup the
value of documents_authored by BoundField.
"""

if initial is None:
initial = {}
from django.utils.functional import curry
initial['documents_authored'] = curry(self.get_documents_authored, 
instance)


super(IntranetUserReadOnlyForm, self).__init__(data, files,
auto_id, prefix, initial, error_class, label_suffix,
empty_permitted, instance)

def get_documents_authored(self, instance):
# print "get_documents_authored(%s)" % instance
return instance.document_set.all()

And now I have to do a really horrible hack in the Admin class, to add 
this field into the form:


class IntranetUserAdmin(AdminWithReadOnly):
documents_authored = None

This is because AdminReadOnlyField tries to call label_for_field() on the 
field, which insists that it be a member of the Model or the Admin, not 
the Form. It doesn't really care what type of attribute it is, but it 
throws an exception if it's not there at all:


  File "/usr/lib/pymodules/python2.6/django/template/defaulttags.py", line 
227, in render

nodelist.append(node.render(context))
  File "/usr/lib/pymodules/python2.6/django/template/defaulttags.py", line 
190, in render

values = list(values)
  File "/usr/lib/pymodules/python2.6/django/contrib/admin/helpers.py", 
line 103, in __iter__

model_admin=self.model_admin)
  File "/usr/lib/pymodules/python2.6/django/contrib/admin/helpers.py", 
line 135, in __init__

label = label_for_field(field, form._meta.model, model_admin)
  File "/usr/lib/pymodules/python2.6/django/contrib/admin/util.py", line 
252, in label_for_field

raise AttributeError(message)
TemplateSyntaxError: Caught AttributeError while rendering: Unable to 
lookup 'documents_authored' on IntranetUser or IntranetUserAdmin


So please can we have an easier way to add fields to an admin form? 
Ideally I wouldn't have to change the Model or the Admin at all, just add 
a new attribute to the custom Form.


Also please can the widget have access to the request? Rendering out a 
DjangoTable (with proper links) needs this.


Cheers, Chris.
--
Aptivate | http://www.aptivate.org | Phone: +44 1223 760887
The Humanitarian Centre, Fenner's, Gresham Road, Cambridge CB1 2ES

Aptivate is a not-for-profit company registered in England and Wales
with company number 04980791.

--
You received this message because you are subscribed to the Google Groups "Django 
developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Contract Django Developer Required - London

2012-02-09 Thread BAC
I hope the group does not mind my posting this but thought it would be
of value to the community. Pls let me know if I should refrain going
forward.

We're looking for a Django developer to work in London for 4-8 weeks.
The project is working with a top 10 UK website by traffic, adding new
functionality to a new social / collaborative tool.

Strong Python / Django experience with knowledge of HTML/CSS
preferred.

If you are interested, please get in touch with Ben Corke.

Benc (*AT*) adrem.uk.com

www.adrem.uk.com/jobs/digital

+44 (020) 7562 8282

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: start using less (and bootstrap!)

2012-02-09 Thread zalew


> We're going
> to solve that with our move to Git/GitHub, which will make it much
> easier for people to fork and much easier for core developers to
> integrate contributions.


a bit offtopic: why not http://bitbucket.org? similar features, it's on 
python/django and already popular in django community.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/uWdwl_1-_qIJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.