Wednesday, August 1, 2012

Re: Working with a Custom, Dynamic Form (using BaseForm)

Here are my models, if you are interested:

    class Photographer(models.Model):
        name = models.CharField(max_length=20)
        models = models.ManyToManyField('Model')

    class Model(models.Model):
        model = models.CharField(max_length=20, blank=False)
        series = models.ForeignKey('Series', null=True, blank=True)

    class A(models.Model):
        user = models.ForeignKey(User)
        photographer = models.ForeignKey('Photographer', blank=True, null=True)
        model = models.ForeignKey('Model', blank=True, null=True)



Thanks folks

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

Re: Working with a Custom, Dynamic Form (using BaseForm)

Hi Anton,

Thank you very much for your response. The 'fields_for_a' is generating the form fields for the instance of the model 'A'. The author admits that it might not be the prettiest implementation, but fully functional. 


def fields_for_a(instance):
    # generate a sorted dict of fields corresponding to the Field model
    # for the A instance
    fields_dict = SortedDict()
    fields = field_list(instance)
    # this really, really should be refactored
    for field in fields:
        if field.field_type == Field.BOOLEAN_FIELD:
            fields_dict[field.name] = forms.BooleanField(label=field.label, required=False, help_text=field.help_text)
        elif field.field_type == Field.CHAR_FIELD:
            widget = forms.TextInput
            fields_dict[field.name] = forms.CharField(label=field.label, required=field.required, max_length=field.max_length, help_text=field.help_text, widget=widget)

.........................(etc)................

             fields_dict[field.name] = field_type(label=field.label,
                                                 required=field.required,
                                                 help_text=field.help_text,
                                                 max_length=field.max_length,
                                                 widget=widget)

    return fields_dict


I am hoping to add an additional field, "Photographers" (from the 'Photographer' model) to AForm so that users can select a Photographer to become part of an instance of the 'A' model.

Does that make sense?


Thank you very much for any ideas!

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

Re: returning a zip file for download


OK, I got it working, I'm not sure what the problem was, but calling the loop variable 'file' was overriding the python default file object class

now I'm doing this:

        response = HttpResponse(File(file(tmp[1])), mimetype="application/zip")
        response['Content-disposition'] = ('attachment; '
                                           'filename="{}"').format(os.path.basename(tmp[1]))
        return response

and I'm wondering, what happens with that File object after the response is sent? when does it get closed? isn't there some cleanup code missing?

--
"The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

--
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@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

QuerySet API - istartswith - use UPPER instead of ILIKE with PostgreSQL backend

QuerySet API - istartswith - use UPPER instead of ILIKE with PostgreSQL backend 
which conflict with Documentation (https://docs.djangoproject.com/en/dev/ref/models/querysets/)
as documentation's example shows SQL equivalent as " ILIKE "

Is this due to my backend being PostgreSQL? or is there setting that I can change?
I would like to know this so that we can strategize indexing of DB.
Any advice would be appreciated.

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

Re: Issue Deploying Django

Thanks so much for the reply!

I had a feeling I would need it but I just like to be sure before I act.

Another thing. On Ubuntu there were additional packages I had to install. I believe one was called "psycopg2-python-dev" or something like that.

If I install psycopg2-python at:


Are there any additional packges that I might need?

I apologize for not being able to remember the additional ones I added before on Ubuntu but I'm at work and couldn't find in my installation history what they might have been or in my django google group discussions.

I feel like one was called "libpq-dev" actually.

Thanks for the help.

JJ

On Wednesday, August 1, 2012 2:07:54 AM UTC-4, lawgon wrote:
On Tue, 2012-07-31 at 20:52 -0700, JJ Zolper wrote:
> Do I need to go through and install the python like adapters is that
> what it's complaining about? I don't think this has to do with my
> Django code on the server it's just a file missing right?

you need to install pycopg - and it is nothing to do with your code
--
regards
Kenneth Gonsalves

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

Re: How to print a graph

a user to print one

I did this in python, but throws an error in django when I tried to run it... I have seen some examples of saving an image, but I would like to avoid that since I don't want to open and close a file...

let me know if you have any idea....

thanks

Python program:


def drawPlot(arrayGene1, arrayGene2):
    message = ''
    (m,b) = polyfit(arrayGene1,arrayGene2,1)
    yp    = polyval([m,b],arrayGene1)
    
    xlable('Gene 1')
    ylable('Gene 2')
    title('Correlation Graph')
    plot(arrayGene1, yp)
    scatter(arrayGene1,arrayGene2,marker='>')
    show()    
    return(message)



On Wed, Aug 1, 2012 at 12:21 PM, william ratcliff <william.ratcliff@gmail.com> wrote:
Do you need to display a graph, or allow the user to print one?  

On Wed, Aug 1, 2012 at 12:06 PM, Peregil <peregilx@gmail.com> wrote:
The information comes from a database, which I got it with a problem. However, I need to show a graph as well.

Please let me know any suggestions... 

thanks and have great day.

--
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@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to print a graph

Do you need to display a graph, or allow the user to print one?  

On Wed, Aug 1, 2012 at 12:06 PM, Peregil <peregilx@gmail.com> wrote:
The information comes from a database, which I got it with a problem. However, I need to show a graph as well.

Please let me know any suggestions... 

thanks and have great day.

--
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@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.