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
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
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
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
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
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
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
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
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 = %
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
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
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
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
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
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
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
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@
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
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
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 =
20 matches
Mail list logo