Monday, March 31, 2014

Re: Django python checkbox

Thank you very much!
I'm Sorry, i'm missing write comments,
I want to do download have been checboxd file  from html, then i write to views.py this code, so i don't know how do write !
Please help me!
this is my right code:
def export_selected_data(request):
#    if request.method == 'POST':
#        _selected_action = request.POST.getlist("_
selected_action")

    response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    if request.method == 'POST':
        _selected_action = request.POST.getlist("_selected_action")

        _selected_action = User.objects.all()
        for obj in _selected_action:
            row=[]
            for field in User._meta.fields:
                row.append(unicode(getattr(obj,field.name)).encode("cp932"))
            writer.writerow(row)
    return response
This is my html:

<form name="myForm"  method="POST">
<select name="myMenu" onchange="myGo()">
<option value="/articles/export_selected_data" >selected_export
</select>
</form>
<table >
        <thead>
            <tr>
                <th>Check</th>             
                <th>名前</th>
                <th>会社名</th>
                <th>法人電話</th>
            </tr>
        </thead>
        <tbody>
{% if articles.count > 0 %}
{% for user in articles %}
        <tr>
        <td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
        <td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name  }}</a></td>
        <td >{{ user.company }}</td>
        <td >{{ user.number }}</td>
        </tr>
{% endfor %}
</tbody>
</table>
{% else %}
    <p>None</p>
{% endif %}

2014年4月1日火曜日 12時47分08秒 UTC+9 Camilo Torres:
Hello,

You should start with the basics:

You are using request.FILES and that is for file upload, no file download. To upload a file to the server, you must have a <input type="file" ...> in your template, which you don't have.

To download files from the server to the browser (to the user computer), you should do:
or, if the user uploaded the content:

Hope this put you in the right direction.

Camilo

On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
Hello,

i wan to do download file of a checkbox ;
Please help me

this is my viewspy:

def export_selected_dataqq(request):
    if request.method == 'POST':
        _selected_action = request.FILES("_selected_action")
      
    response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    _selected_action = []
    writer.writerow(_selected_action)
  
    for obj in _selected_action:
       
        row=[]
        for field in User._meta.fields:
            row.append(unicode(getattr(obj,field.name)).encode("cp932"))
        writer.writerow(row)
    return response

this is mmy html:

<table >
        <thead>
            <tr>
                <th>Check</th>             
                <th>名前</th>
                <th>会社名</th>
                <th>法人電話</th>
            </tr>
        </thead>
        <tbody>
{% if articles.count > 0 %}
{% for user in articles %}
        <tr>
        <td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
        <td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name  }}</a></td>
        <td >{{ user.company }}</td>
        <td >{{ user.number }}</td>
        </tr>
{% endfor %}

</tbody>
</table>
</form>
{% else %}
    <p>None</p>
{% endif %}


2014年4月1日火曜日 12時47分08秒 UTC+9 Camilo Torres:
Hello,

You should start with the basics:

You are using request.FILES and that is for file upload, no file download. To upload a file to the server, you must have a <input type="file" ...> in your template, which you don't have.

To download files from the server to the browser (to the user computer), you should do:
or, if the user uploaded the content:

Hope this put you in the right direction.

Camilo

On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
Hello,

i wan to do download file of a checkbox ;
Please help me

this is my viewspy:

def export_selected_dataqq(request):
    if request.method == 'POST':
        _selected_action = request.FILES("_selected_action")
      
    response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    _selected_action = []
    writer.writerow(_selected_action)
  
    for obj in _selected_action:
       
        row=[]
        for field in User._meta.fields:
            row.append(unicode(getattr(obj,field.name)).encode("cp932"))
        writer.writerow(row)
    return response

this is mmy html:

<table >
        <thead>
            <tr>
                <th>Check</th>             
                <th>名前</th>
                <th>会社名</th>
                <th>法人電話</th>
            </tr>
        </thead>
        <tbody>
{% if articles.count > 0 %}
{% for user in articles %}
        <tr>
        <td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
        <td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name  }}</a></td>
        <td >{{ user.company }}</td>
        <td >{{ user.number }}</td>
        </tr>
{% endfor %}

</tbody>
</table>
</form>
{% else %}
    <p>None</p>
{% endif %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4f1b7cbf-3265-429c-99dc-f1ccbaad15fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django python checkbox

Thank you very much!
Sory, i'm missing write comments,
I want to do download have been checboxd file  from html, then i write to views.py this code, so i don't know how do write !
Please help me!
this is my right code:
def export_selected_data(request):
#    if request.method == 'POST':
#        _selected_action = request.POST.getlist("_selected_action")

    response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    if request.method == 'POST':
        _selected_action = request.POST.getlist("_selected_action")

        _selected_action = User.objects.all()
        for obj in _selected_action:
            row=[]
            for field in User._meta.fields:
                row.append(unicode(getattr(obj,field.name)).encode("cp932"))
            writer.writerow(row)
    return response
This is my html:

<form name="myForm"  method="POST">
<select name="myMenu" onchange="myGo()">
<option value="/articles/export_selected_data" >selected_export
</select>
</form>
<table >
        <thead>
            <tr>
                <th>Check</th>             
                <th>名前</th>
                <th>会社名</th>
                <th>法人電話</th>
            </tr>
        </thead>
        <tbody>
{% if articles.count > 0 %}
{% for user in articles %}
        <tr>
        <td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
        <td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name  }}</a></td>
        <td >{{ user.company }}</td>
        <td >{{ user.number }}</td>
        </tr>
{% endfor %}
</tbody>
</table>
{% else %}
    <p>None</p>
{% endif %}

2014年4月1日火曜日 12時47分08秒 UTC+9 Camilo Torres:
Hello,

You should start with the basics:

You are using request.FILES and that is for file upload, no file download. To upload a file to the server, you must have a <input type="file" ...> in your template, which you don't have.

To download files from the server to the browser (to the user computer), you should do:
or, if the user uploaded the content:

Hope this put you in the right direction.

Camilo

On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
Hello,

i wan to do download file of a checkbox ;
Please help me

this is my viewspy:

def export_selected_dataqq(request):
    if request.method == 'POST':
        _selected_action = request.FILES("_selected_action")
      
    response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    _selected_action = []
    writer.writerow(_selected_action)
  
    for obj in _selected_action:
       
        row=[]
        for field in User._meta.fields:
            row.append(unicode(getattr(obj,field.name)).encode("cp932"))
        writer.writerow(row)
    return response

this is mmy html:

<table >
        <thead>
            <tr>
                <th>Check</th>             
                <th>名前</th>
                <th>会社名</th>
                <th>法人電話</th>
            </tr>
        </thead>
        <tbody>
{% if articles.count > 0 %}
{% for user in articles %}
        <tr>
        <td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
        <td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name  }}</a></td>
        <td >{{ user.company }}</td>
        <td >{{ user.number }}</td>
        </tr>
{% endfor %}

</tbody>
</table>
</form>
{% else %}
    <p>None</p>
{% endif %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0478d10a-f432-444c-a41e-3090f3f09e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django python checkbox

Hello,

You should start with the basics:
https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/

You are using request.FILES and that is for file upload, no file download. To upload a file to the server, you must have a <input type="file" ...> in your template, which you don't have.

To download files from the server to the browser (to the user computer), you should do:
https://docs.djangoproject.com/en/1.6/ref/contrib/staticfiles/
or, if the user uploaded the content:
https://docs.djangoproject.com/en/1.6/topics/files/

Hope this put you in the right direction.

Camilo

On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
Hello,

i wan to do download file of a checkbox ;
Please help me

this is my viewspy:

def export_selected_dataqq(request):
    if request.method == 'POST':
        _selected_action = request.FILES("_selected_action")
      
    response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    _selected_action = []
    writer.writerow(_selected_action)
  
    for obj in _selected_action:
       
        row=[]
        for field in User._meta.fields:
            row.append(unicode(getattr(obj,field.name)).encode("cp932"))
        writer.writerow(row)
    return response

this is mmy html:

<table >
        <thead>
            <tr>
                <th>Check</th>             
                <th>名前</th>
                <th>会社名</th>
                <th>法人電話</th>
            </tr>
        </thead>
        <tbody>
{% if articles.count > 0 %}
{% for user in articles %}
        <tr>
        <td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
        <td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name  }}</a></td>
        <td >{{ user.company }}</td>
        <td >{{ user.number }}</td>
        </tr>
{% endfor %}

</tbody>
</table>
</form>
{% else %}
    <p>None</p>
{% endif %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/129bfa86-8215-4bfe-9c7e-84a3fbef6017%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: ManyToMany quick question

On Monday, March 31, 2014 5:37:05 PM UTC-4:30, willyhakim wrote:
when creating your models, how do you know which field to assign the ManyToManyField ?

 from django.db import models
    

class Student(models.Model):
    name = models.TextField()


class Course(models.Model):
    name = models.TextField()
    students = models.ManyToManyField(Student, related_name='courses')

>>> from testapp import models
>>> a = models.Student(name='aaaaa')
>>> a.save()
>>> b = models.Student(name='bbbbb')
>>> b.save()
>>> c = models.Course(name='cccccccc')
>>> c.save()
>>> c.students.add(a)
>>> c.students.add(b)
>>> c.students.all()
[<Student: Student object>, <Student: Student object>]

>>> a = models.Student.objects.get(name='aaaaa')
>>> a.name
'aaaaa'
>>> a.courses.all()
[<Course: Course object>]


Is this what you are asking?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9e05634b-4784-4cfe-beb9-9e0a52218edb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Use custom HTML to render forms

You must think on what is the output HTML you need to generate. Depending on that, you may be able to figure where to put the {% block content %} tags. What is the output HTML you expect?

On Thursday, March 27, 2014 9:18:47 AM UTC-4:30, Fred DJar wrote:
Hello, 
I am a beginner in python and django programming, i have a question that already have been asked in stackoverflow and many forums, but i couldnt solve my own.

this exactly my situation:

this the code in my app html page:

{% extends 'base.html' %}

{% block content %}

<form method="POST" action=""> {% csrf_token %}            
        {{ form.as_p }} 
    <footer>
        <button type="submit" class="button">Confirmer</button>
    </footer>    
</form>

{% endblock %}



but in my base.html i have already this form and this classes:

<form action="" class="sky-form">
    <section>
        <label class="input">
                <input type="password" placeholder="Confirmation">
                <b class="tooltip tooltip-bottom-right">Retaper votre mot de passe</b>
        </label>
    </section>
.
.
.
.
</form>


where should i put {% block content %} and {% endblock %} in my base.html!!!!!!

i've also followed the tutorial from the official docs, but it did,'t work out for me

i'm sorry if my question seem silly!
Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e94b706c-29e7-4b52-8312-cf0f030d9987%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Use custom HTML to render forms

It depends on what you want to do. If you want to override/replace the form in base.html, then place the block tag around the form, like so (in base.html):

{% block content %}
    <form action="" class="sky-form">
        ...
    </form>
{% endblock %}

Any template extending from base.html which defines a "content" block will override the form in base.html.

_Nik

On 3/27/2014 6:48 AM, Fred DJar wrote:
Hello, 
I am a beginner in python and django programming, i have a question that already have been asked in stackoverflow and many forums, but i couldnt solve my own.

this exactly my situation:

this the code in my app html page:

{% extends 'base.html' %}

{% block content %}

<form method="POST" action=""> {% csrf_token %}            
        {{ form.as_p }} 
    <footer>
        <button type="submit" class="button">Confirmer</button>
    </footer>    
</form>

{% endblock %}



but in my base.html i have already this form and this classes:

<form action="" class="sky-form">
    <section>
        <label class="input">
                <input type="password" placeholder="Confirmation">
                <b class="tooltip tooltip-bottom-right">Retaper votre mot de passe</b>
        </label>
    </section>
.
.
.
.
</form>


where should i put {% block content %} and {% endblock %} in my base.html!!!!!!

i've also followed the tutorial from the official docs, but it did,'t work out for me

i'm sorry if my question seem silly!
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0d9ee9e7-7cc5-4e6b-8fdb-c02d9d1d7049%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: ManyToMany quick question



So sorry, I should have been clear. I meant when you are assigning a field ManyToManyField (through) properties

 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1be20b23-1cfd-4539-bb3b-34cbcda99071%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: ManyToMany quick question

On 1/04/2014 9:07 AM, willyhakim wrote:
> when creating your models, how do you know which field to assign the
> ManyToManyField ?

https://docs.djangoproject.com/en/1.6/topics/db/models/#many-to-many-relationships

>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/08b9538b-a98f-4768-ad0d-f8f6b8419440%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/08b9538b-a98f-4768-ad0d-f8f6b8419440%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5339FE04.1000902%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Re: Use custom HTML to render forms

HELP PLEASE

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/632a638d-af9b-4ba0-a2f2-bbb5189a25f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ManyToMany quick question

when creating your models, how do you know which field to assign the ManyToManyField ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/08b9538b-a98f-4768-ad0d-f8f6b8419440%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Avoid Django s3-urls stripping



Hi Aaron,
this is the url:

http://this-is-the-irish-aeneas-bucket.s3.amazonaws.com/XXXASCIINAMEXXX/5/2014-03-10_08%3A37%3A39.274998-d3421964017734f96198c74d853eb2e7?Signature=2hR%2Fy0iXqimJ5e1umXX2xY1FqjU%3D&Expires=1396003040&AWSAccessKeyId=XXXXXXXXXXXXXXXXXXXXXX

I replaced some byte with X for security reason.
Today, in order to debug, i ve trie:

c = {}

url = aws.get_s3_content(key).replace('/','')
c['s3url'] = url.encode('utf-8')

context = RequestContext(request, c)

return HttpResponse(template.render(context))


and the url is stripped....... incredible!


Il giorno venerdì 28 marzo 2014 15:20:13 UTC+1, Aaron Cannon ha scritto:
I'd like to try to reproduce this locally.  If you can send me the URL
(feel free to mangle the signature parameter for security), that will
help.  Alternatively, you might cut the URL into pieces, to see if
it's some specific characters that it's choking on, and then just send
me that bit.

Otherwise, if you'd like to create a small example project that
demonstrates this issue, and upload it to github, that would work as
well.

Aaron

On 3/28/14, Paolo Bertasi <paolo...@gmail.com> wrote:
>
> Hi and thanks for your help.
>
> I tried
> * to print url in the console : OK
> * to print HttpResponse(url) in the console: OK
> * to return the url witout a template in the browser : wrong
>
> So i am really confused....
> I am almost sure that:
> 1) it is not a s3 problem
> 2) it is not a HttpResponse problem
> 3) it is not a templating problem
>
> It seems that django strip the url when i get the url via browser...
>
>
>
> Il giorno giovedì 27 marzo 2014 19:34:10 UTC+1, Aaron Cannon ha scritto:
>>
>> Is the url a bytestring?  A quick check of the code for HttpResponse
>> shows that that class is expecting a byte string.  Perhaps the URL
>> contains unicode characters that aren't being escaped properly?
>>
>> Aaron
>>
>> On 3/27/14, Aaron Cannon <can...@fireantproductions.com <javascript:>>
>> wrote:
>> > Other things I'd probably try to debug this issue would be:
>> >
>> > * Hard coding the string into the call to HttpResponse,
>> > * printing the variable that contains the URL to the console.
>> >
>> > If the URL was still bad after trying the first item, and the second
>> > item printed the expected result, then you could completely take S3
>> > out of the picture.  From there, I would start narrowing it down, to
>> > see if it was a specific character that was causing the problem.
>> >
>> > Narrowing things down a bit more might make it easier for folks to
>> > help you figure out your issue.
>> >
>> > Luck.
>> >
>> > Aaron
>> >
>> > On 3/27/14, Paolo Bertasi <paolo...@gmail.com <javascript:>> wrote:
>> >> Hi Aaron,
>> >> the html is "wrong" as well.
>> >>
>> >> Moreover i tried {% autoescape off %} but with no luck :(
>> >>
>> >>
>> >>
>> >>
>> >> Il giorno giovedì 27 marzo 2014 17:24:45 UTC+1, Aaron Cannon ha
>> scritto:
>> >>>
>> >>> Try clicking view source in your browser when you view it.  Perhaps
>> >>> the URL needs to be HTML escaped?
>> >>>
>> >>> Just a guess.
>> >>>
>> >>> Aaron
>> >>>
>> >>> On 3/21/14, Paolo Bertasi <paolo...@gmail.com <javascript:>> wrote:
>> >>> > Hello,
>> >>> > I'm trying to setup a mini django app to allow users to download
>> files
>> >>> from
>> >>> >
>> >>> > s3. I wrote a simple python function (using boto of course) to fetch
>> >>> >
>> >>> > the
>> >>> >
>> >>> > correct url but when i handle the url with django the url is
>> stripped.
>> >>> > I wrote down the exact behaviour
>> >>> > here<
>> >>>
>> http://stackoverflow.com/questions/22531195/avoid-django-s3-urls-stripping>
>>
>>
>> >>>
>> >>>
>> >>> > .
>> >>> >
>> >>> > Please help :)
>> >>> >
>> >>> > --
>> >>> > You received this message because you are subscribed to the Google
>> >>> Groups
>> >>> > "Django users" group.
>> >>> > To unsubscribe from this group and stop receiving emails from it,
>> send
>> >>> an
>> >>> > email to django-users...@googlegroups.com <javascript:>.
>> >>> > To post to this group, send email to
>> >>> > django...@googlegroups.com<javascript:>.
>> >>>
>> >>> > Visit this group at http://groups.google.com/group/django-users.
>> >>> > To view this discussion on the web visit
>> >>> >
>> >>>
>> https://groups.google.com/d/msgid/django-users/e3dba710-5189-4800-b455-09868dcf578b%40googlegroups.com.
>>
>>
>> >>>
>> >>>
>> >>> > For more options, visit https://groups.google.com/d/optout.
>> >>> >
>> >>>
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "Django users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >>
>> an
>> >> email to django-users...@googlegroups.com <javascript:>.
>> >> To post to this group, send email to
>> >> django...@googlegroups.com<javascript:>.
>>
>> >> Visit this group at http://groups.google.com/group/django-users.
>> >> To view this discussion on the web visit
>> >>
>> https://groups.google.com/d/msgid/django-users/1172243d-6d55-41b4-9cf4-a6bbc6379225%40googlegroups.com.
>>
>>
>> >> For more options, visit https://groups.google.com/d/optout.
>> >>
>> >
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d8f379e1-4485-43ea-9a0a-7982ff1d0e35%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e16027a5-2fdc-4a7e-9b75-8a74ac61aa6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sunday, March 30, 2014

How to switch json context between two pages in djanog

I have two html pages with different json context ,I have templates for both pages which contains a script which on loading the pages individually loads the context into the list.Now i want to develop a toggle button which onclicking changes the context ,is there any way i can do this with ajax i am using django framework.can anybody please help me with this.

My views are like this

Class Myview(Baseclass):
   def template():
      return template
   def jsonContext():
     return .content()
   def context():
      return {}

My templates are like this:
{extend 'base.html'}
{{list.render}}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e476a402-0759-4222-8279-b5712b46333d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Django python checkbox

Hello,

i wan to do download file of a checkbox ;
Please help me

this is my viewspy:

def export_selected_dataqq(request):
    if request.method == 'POST':
        _selected_action = request.FILES("_selected_action")
      
    response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    _selected_action = []
    writer.writerow(_selected_action)
  
    for obj in _selected_action:
       
        row=[]
        for field in User._meta.fields:
            row.append(unicode(getattr(obj,field.name)).encode("cp932"))
        writer.writerow(row)
    return response

this is mmy html:

<table >
        <thead>
            <tr>
                <th>Check</th>             
                <th>名前</th>
                <th>会社名</th>
                <th>法人電話</th>
            </tr>
        </thead>
        <tbody>
{% if articles.count > 0 %}
{% for user in articles %}
        <tr>
        <td ><input class="action-select" name="_selected_action" id ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" class="button"></td>
        <td ><a href="/articles/get/{{ user.id }}/">{{ user.user_name  }}</a></td>
        <td >{{ user.company }}</td>
        <td >{{ user.number }}</td>
        </tr>
{% endfor %}

</tbody>
</table>
</form>
{% else %}
    <p>None</p>
{% endif %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c8b66947-b791-47bf-8000-4f2865351a03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: register for mIRC

Yes

Gerald Klein DBA
geraldklein.com
ContactMe@geraldklein.com
geraldklein.wordpress.com
jk@zognet.com
708-599-0352

Arch\Gentoo Awesome, Ranger & Vim the coding triple threat.
Linux registered user #548580
Brought to you by the Amish Mafia

On Mar 29, 2014 6:26 PM, "CS" <sw.cornel@gmail.com> wrote:
Hi everyone,

I am new at python and I want to start to learn django.
I have small question, how can I register my ID to join #django in mIRC?

CS

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/677c008b-7bfb-46cb-8185-4142f0883728%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP8NtCwYU7UzFhbajE6vKhd7PYU6HLOCyU-XB0s5eaGhpShkaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: register for mIRC

Hi,

Registration of your username isn't something #django specific - it's something you need to do in order to use IRC in general. Not all channels enforce the requirement for a registered ID, but is a common approach in popular channels to prevent people from impersonating others.

To register, you need to have a "conversation" with the NickServ bot. See:


for more details. More general help on using IRC can be found here:


I hope that helps!

Yours, 
Russ Magee %-)


On Sun, Mar 30, 2014 at 3:38 AM, CS <sw.cornel@gmail.com> wrote:
Hi everyone,

I am new at python and I want to start to learn django.
I have small question, how can I register my ID to join #django in mIRC?

CS

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/677c008b-7bfb-46cb-8185-4142f0883728%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq84_NxE6o0ZUN-%2BeU1hMF4jRxm3UZ7G_5U5iH9w33P9Z3SA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Allow the Prefetch queryset to be used with GenericForeignKey

That would be awesome, somebody has a solution for this?

On Sunday, February 16, 2014 2:53:55 PM UTC-3, Robert Kajic wrote:
I would love it if the Prefetch object allowed me to pass in custom querysets when prefetching related generic foreign fields. Specifically I want this in order to call select_related on each subgroup.
For now I've subclassed the GenericForiengKey class, overriding get_prefetch_queryset, to allow me to use modelless querysets like this:

.prefetch_related(
        Prefetch('obj', queryset=QuerySet().select_related(
            "user", "poem__user", "consumer", "producer"
))

In get_prefetch_queryset, for each subgroup, I copy the select_related options from the modelless queryset to the subgroup queryset:

qs = ct.get_all_objects_for_this_type(pk__in=fkeys)
# Copy any select related options from queryset to qs
qs = self.combine_select_related(qs, queryset)
ret_val.extend(qs)

Initially I thought I would simply be able to combine the two querysets using QuerySet.__or__, but I noticed that Query.combine refuses to run unless both queries are on the same model. Would there be any harm in allowing it to combine Queries even if the qeries are not on the same model, as long as one of the queries doesn't have a model at all? Then the above could be changed into:

# Copy any select related options from queryset to qs
qs |= queryset

This would have the added benefit of copying other options other than select_related.

I know this is problematic because you may not want to combine the same queryset with each individual group. Ideally, the developer would be able to specify a different queryset for each group kind.

.prefetch_related(
        Prefetch('obj', queryset=QuerySet().select_related(
            "user", "poem__user", "consumer", "producer"
))

Does anyone have any thoughts on this? 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7a7a4157-51b2-4e89-8cb0-ce25b5445b36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: STATIC and MEDIA

Hi Julio!

Thank u so much!

Jonathan
Diretor de Tecnologia
+55(12)98864-1594

Sent from my iPhone

> On Mar 30, 2014, at 13:49, Julio Molina Soler <julio.molina@telenet.be> wrote:
>
> Hi Jonathan,
>
> the cleanest way I found:
>
> at the beginning of your settings.py add
>
> import os
> BASE_PROJECT = os.path.dirname(__file__)
>
> then when the section comes
>
> MEDIA_ROOT = os.path.join(BASE_PROJECT,'media')
> MEDIA_URL = '/media/'
>
> STATIC_ROOT = os.path.join(BASE_PROJECT,'static')
> STATIC_URL = '/static/'
>
> and in some cases I also add the static inside the apps like this
>
> STATICFILES_DIRS = (
> # Put strings here, like "/home/html/static" or "C:/www/django/static".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> os.path.join(BASE_PROJECT, 'newApp','static')
> )
>
> Julio,
>
>> On dom 30 mar 2014 00:39:41 CET, Jonathan Querubina wrote:
>> Guys
>>
>> What is the best way to configure and make accessible via URL the STATIC and the MEDIA uri?
>>
>> I can`t seem to find a good way, and get so many errors for the both being equal.
>>
>> Can someone send me an example of this configs?
>>
>> Thanks!
>>
>
>
>
> --
> Julio Molina Soler
> julio.molina@telenet.be
> Github: https://github.com/jmolinaso
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53384B12.3050202%40telenet.be.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/E689782E-CE07-4770-855B-61ED7BA53CC5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: STATIC and MEDIA

Hi Jonathan,

the cleanest way I found:

at the beginning of your settings.py add

import os
BASE_PROJECT = os.path.dirname(__file__)

then when the section comes

MEDIA_ROOT = os.path.join(BASE_PROJECT,'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(BASE_PROJECT,'static')
STATIC_URL = '/static/'

and in some cases I also add the static inside the apps like this

STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or
"C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_PROJECT, 'newApp','static')
)

Julio,

On dom 30 mar 2014 00:39:41 CET, Jonathan Querubina wrote:
> Guys
>
> What is the best way to configure and make accessible via URL the STATIC and the MEDIA uri?
>
> I can`t seem to find a good way, and get so many errors for the both being equal.
>
> Can someone send me an example of this configs?
>
> Thanks!
>



--
Julio Molina Soler
julio.molina@telenet.be
Github: https://github.com/jmolinaso

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53384B12.3050202%40telenet.be.
For more options, visit https://groups.google.com/d/optout.

Django apps

I wish to develope application that can give directions and location.

Pleas i need some guidance for a way forward. I have done some research but
still not getting it right. 

I need some guidance

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a240e0bf-b14b-4fb1-86cb-d134e8a50f70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saturday, March 29, 2014

STATIC and MEDIA

Guys

What is the best way to configure and make accessible via URL the STATIC and the MEDIA uri?

I can`t seem to find a good way, and get so many errors for the both being equal.

Can someone send me an example of this configs?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7C03A25B-2634-4FDD-A4B2-B6F13CEA699D%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Django (1.5) login exception (Save with update_fields did not affect any rows)

In my Django web app (running on Google App Engine), when a new user signs up a User object is created and then that user is authenticated and logged in. Every once in a while, the login function throws an exception (DatabaseError: Save with update_fields did not affect any rows) and I'm not really sure why this is happening (this is my first Django app).

newuser = User.objects.create_user(username, "", password)        newuser.first_name = username      newuser.save()           # Create and save an associated accounts table to the system      models.Accounts(user=newuser).save()          # Authenticate the new user      newuser = authenticate(username=username, password=password)        # This is the login that occasionally throws an exception      login(request, newuser)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd0fe745-91bc-41b0-bd5b-e8561b43e8e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.