celery tasks and circular imports

2011-03-07 Thread cerberos
I have tasks.py that imports models to access the managers. I also want to import a task in a custom save method of one of my models but can't as this creates a circular import. I'm happy to use signals instead hover I don't really know where to register them apart from models.py (which would also

Re: Inline formset when pk doesn't exist

2010-07-26 Thread cerberos
I've managed to solve my problem. view item_form = ItemForm() ImageFormSet = formset_factory(ImageForm) image_formset = ImageFormSet() template (I'm using uni_form in the template but it's no different) {{ image_formset.management_form }} {{ item_form|as

Inline formset when pk doesn't exist

2010-07-26 Thread cerberos
I have 2 models class Item(models.Model): fields here class ItemImage(models.Model): item = models.ForeignKey('Item', null=True, blank=True, related_name='images') I want a single 'form' where a user can add an Item and an ItemImage (actually many images but that's irrele

unit test for form with recaptcha field

2010-04-28 Thread cerberos
I want to write a form submission unit test for a form that has a recaptcha field, how do I fake a pass? Is there any way to tell in the form code that execution is being done by a test? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Decorator problem

2010-02-07 Thread cerberos
I'm trying to make a decorator that checks if a user is staff and redirects to the login page if not logged in or returns a 403 for logged in users that aren't staff. I found permission_required_with_403 (http://www.djangosnippets.org/ snippets/254/) which works well so I've added is_staff_with_40

Raise error based on both form and inline_formset

2009-12-10 Thread cerberos
I'm building a library system and have models Member, Loan and LoanItem (relationships as you'd expect), and an inline formset to enter a new loan (Loan and LoanItems). A member can borrow up to 6 books at a time, so my form contains 7 individual forms (1 loan and 6 loan items), I need to get the

filter foreign key field in inline formset

2009-12-07 Thread cerberos
One of the fields in an inline formset has a foreign key to another model, how can I filter it? I'm building a library system, the models are loans, loan items and book instances. I don't want books that are currently out on loan to be available on the loan items dropdown list. -- You received t

order_with_respect_to doesn't work for model related to self

2009-11-30 Thread cerberos
I have a model that's related to itself, the instance names are not unique. I want to order by full path so the result is like a list of directory paths a a/b a/b/c a/c b/d/g b/e It's obvious why order_with_respect_to it doesn't work (although a mention of this exception in the docs would be good

Re: is_valid error/bug when unique_together fields are both ForeignKey fields

2009-11-28 Thread cerberos
The problem ("Foo bar with this None and None already exists.") only happens when I use a ModelForm and choose to specify the field details myself. Here is an example Models class Foo(models.Model): f = models.IntegerField(unique=True) def __unicode__(self): return 'Foo with f = %

is_valid error/bug when unique_together fields are both ForeignKey fields

2009-11-26 Thread cerberos
I have a model that has two fields (Django 1.1.1) class FooBar(models.Model): foo = models.ForeignKey('Foo') bar = models.ForeignKey('Bar') class Meta: unique_together = (('foo','bar'),) When is_valid is called in my view and the combination of fields already exists (eg uniqu

Re: Form foreign key add new

2009-11-25 Thread cerberos
I've realised I can't inherit from RelatedFieldWidgetWrapper because I want to override __init__ so I've copies the entire class an made a few changes. Still need to know what to pass in for rel. -- You received this message because you are subscribed to the Google Groups "Django users" group. T

Form foreign key add new

2009-11-25 Thread cerberos
I want the same add new functionality as model foreign key select boxes in admin, there the select widget is passed through django.contrib.admin.widgets.RelatedFieldWidgetWrapper to add the additional html (image, links etc). The __init__.py takes the admin_site instance, I want this functionality

Open ID & request.user.message_set.create

2009-10-25 Thread cerberos
request.user.message_set.create(message="Your playlist was added successfully.") The docs (http://docs.djangoproject.com/en/dev/topics/auth/#messages) say "Finally, note that this messages framework only works with users in the user database. To send messages to anonymous users, use the session f

Re: One to Many relationship display

2009-10-16 Thread cerberos
Familiarise yourself with the python command line ('manage.py shell') and the querying docs, shouldn't take long. http://docs.djangoproject.com/en/dev/topics/db/queries/ I like the improvements that ipython brings to the command line, but that's not relevant. Hope this helps On Oct 16, 11:5

Re: Model field help_text

2009-09-19 Thread cerberos
On Sep 20, 1:14 am, cerberos wrote: > I have a ModelForm form, I want to use a different widget than the > default but when I do I lose the help_text. > > The first thing I tried was modelName.fieldName.help_text but it > didn't work, I've tried all sorts in a shell

Model field help_text

2009-09-19 Thread cerberos
I have a ModelForm form, I want to use a different widget than the default but when I do I lose the help_text. The first thing I tried was modelName.fieldName.help_text but it didn't work, I've tried all sorts in a shell but can't get the model's fields, I can't even get a list of the model's fie

are model field choices enumerated in the db?

2009-08-16 Thread cerberos
when the choices attribure is used for a model field are the choices enumerated in the database? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@

Re: solved: Need help with filter, limit and order_by query

2009-08-12 Thread cerberos
On Aug 13, 12:06 am, cerberos wrote: > On Aug 12, 11:52 pm, Alex Gaynor wrote: > > > > > On Wed, Aug 12, 2009 at 11:49 AM, cerberos wrote: > > > > Say there are 10 records, I want records 3 & 4 in descending order. > > > > q1 = ModelName.object

solved: Need help with filter, limit and order_by query

2009-08-12 Thread cerberos
On Aug 12, 11:52 pm, Alex Gaynor wrote: > On Wed, Aug 12, 2009 at 11:49 AM, cerberos wrote: > > > Say there are 10 records, I want records 3 & 4 in descending order. > > > q1 = ModelName.objects.order_by('id').filter(id__gte=3)[:2] # gives > > the rec

Need help with filter, limit and order_by query

2009-08-12 Thread cerberos
Say there are 10 records, I want records 3 & 4 in descending order. q1 = ModelName.objects.order_by('id').filter(id__gte=3)[:2] # gives the records I want but in ascending order q2 = ModelName.objects.order_by('-id').filter(id__gte=3)[:2] # gives the last 2 records (9 & 10) in correct order q3 =