Either its age - the scotch - or some combination of both, but I am
having problems with a SIMPLE formset. (its my first).

On my formset I get an AttributeError - 'Client' object has no
attribute 'ordered'... .but I dont have an attribute of that
anywhere....???? I tried changing from a "get" to a "raw" but still
get a (similar) message.

My code is :
(models.py)

class Client(models.Model):
    title = models.CharField(max_length=3, choices=TITLE_CHOICES)
    firstname = models.CharField(max_length=50)
    lastname = models.CharField(max_length=50)
    mobilenumber = models.CharField(max_length=50)
    phonenumber = models.CharField(max_length=50)
    email = models.CharField(max_length=50)
    street = models.CharField(max_length=50)
    city = models.CharField(max_length=50)
    state = models.CharField(max_length=10, choices=STATE_CHOICES)
    class Meta:
        ordering = ('lastname','firstname')
        unique_together = ('firstname', 'lastname','mobilenumber')

    def __unicode__(self):
        return self.id


I have a forms.py containing

ClientFormSet = modelformset_factory(Client, extra=0, max_num=1)


In my view.py" I have the following... which is getting called and is
what generates the error....

def c4(request, client_id=None):
    if  client_id == None:
        if request.method == 'POST':
            formset = ClientFormSet(request.POST, request.FILES)
            if formset.is_valid():
                formset.save()
                clients = Client.objects.all()
                return SortableGrid(request,
clients).render_to_response("mylibrary/real.html")
        else:
            formset = ClientFormSet(request.POST, request.FILES)

    else:
        if request.method == 'POST':
            formset = ClientFormSet(request.POST, request.FILES,
queryset=Client.objects.get(pk=client_id))
            if formset.is_valid():
                formset.save()
                clients = Client.objects.all()
                return SortableGrid(request,
clients).render_to_response("mylibrary/real.html")

        else:
            formset = ClientFormSet(request.POST, request.FILES,
queryset=Client.objects.get(pk=client_id))

    return render_to_response("4.html", {
        "formset": formset,
    })


My "4.html" contains
<form method="post" action="">
    {{ formset.management_form }}
    {% for form in formset.forms %}
        {{ form.id }}
        <ul>
            <li>{{ form.id }}</li>
            <li>{{ form.firstname }}</li>
            <li>{{ form.lastname }}</li>
        </ul>
    {% endfor %}
        <input type="submit" value="Save" />
</form>
<FORM METHOD="LINK" ACTION="../3"><input type="submit" value="Cancel" /
></FORM>

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

Reply via email to