Re: Django-cart. How to run method add_to_cart?

2013-10-02 Thread Leonardo Giordani
Hi Ricardo,

well this is a question that needs a good explanation. I try to give you
some hints about what you need to research about:

a. You need to send data to the Django server through a POST view. This is
a HTTP "verb", that is one of many different ways the browser has to
communicate with your server. In particular, POST views in Django work just
like standard views (i.e. GET views), but the request object has a POST
attribute which encompasses the data sent by the browser.

b. To create a POST HTTP request in your browser you need to create a form,
and Django can help you with a very very rich API.

So the general roadmap to achieve what you want is:

1. Set up a POST view that processes the incoming data
2. Link the POST view to an URL
3. Create an HTML template which shows a form to the user and sends data
back to the server.

The 3rd point is obviously needed only if you have to show the user a form
to collect the input he or she enters. You can also call POST views
directly, e.g. including some JS that performs the request, but this is an
advanced topic.

Start by looking at this video
tutorialand reading the
docs on Django
Forms 

I'd suggest you to also check the following resources to understand the
previous two matters:

http://www.w3schools.com/tags/ref_httpmethods.asp
https://docs.djangoproject.com/en/dev/ref/request-response/
http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
https://docs.djangoproject.com/en/dev/ref/forms/api/

Feel free to ask more if you need help.

Cheers,

Leo


Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2013/10/1 Ricardo Kamada 

> you already helped me a lot =)
> Leonardo looks just http://dpaste.com/1402408/
> On line 20 I pass a value of fixed amount in the template.
> How would get the amount in input dynamically?
>
> Abs
> [] s
>
> Ricardo
>
>
> 2013/10/1 Leonardo Giordani 
>
>> Ricardo,
>>
>> I think the example on the django-cart site are somehow incorrect: since
>> you are going to change the database you shall use a POST view and not a
>> GET.
>>
>> However, putting apart HTTP verbs for a moment, let's look at how you
>> call views from URLs. If you write something like the following in your
>> views.py (or whatever file you mapped in your urls.py)
>>
>>
>> from django.conf.urls import patterns, url
>>
>> from django.shortcuts import render_to_response
>>
>> def my_view(request, product_id, quantity):
>> [do something with product_id and quantity]
>> return render_to_response('template.html')
>>
>> urlpatterns = patterns('',
>>url(r'^(?P\d+)/(?P\d+)/$',
>>my_view
>>)
>>
>> you can browse to http://yoursite/path/1234/56 and have the Python
>> function my_view(product_id=1234, quantity=56) called.
>>
>> Try and implement something like the above code and see if it works.
>>
>> As for the django_cart: when you modify the DB always use POST views and
>> not GET, then you are right, you have to return a template rendering in
>> your add_to_cart() view.
>>
>> Let me know if it comes to life =)
>>
>> Cheers,
>> Leo
>>
>>
>>
>> Leonardo Giordani
>> Author of The Digital Cat 
>> My profile on About.me  - My GitHub
>> page  - My Coderwall 
>> profile
>>
>>
>> 2013/10/1 Ricardo Kamada 
>>
>>>  Leonardo Hi thanks for the reply but I still can not understand.
>>> I really need to pass the id and quantity parameters in the url? After
>>> all I'm recording the items in the correct session?
>>> I saw that the method has no return add_to_cart, as well as other
>>> methods remove_from_cart.
>>> In my template I am calling the method like this:
>>>  >> detalhe_produto.id1%}"> Buy  
>>>
>>> and URLs:
>>> url (r '^ products / buy / $', 'cart.views.add_to_cart', name =
>>> 'add_to_cart')
>>>
>>> You say that to pass arguments id and quantity that url?
>>>
>>> Ricardo
>>>
>>>
>>> 2013/10/1 Leonardo Giordani 
>>>
  You have to implement an URL dispatcher that links an URL to your
 view.
 Read here and 
 feel free to ask again if something is still not clear.

 Leonardo Giordani
 Author of The Digital Cat 
 My profile on About.me  - My GitHub
 page  - My Coderwall 
 profile


 2013/10/1 Ricardo 

>  Hi, I have this same problem.
> I'm looking for answer everywhere.
> enemybass could implement?
> If someone can help me with this
>

Re: Best practice for server-generated downloads?

2013-10-02 Thread Russell Keith-Magee
On Wed, Oct 2, 2013 at 2:33 PM, DJ-Tom  wrote:

> Hi,
>
> this is quite easy to answer - those reports need to be archived - users
> must be able to download them days or weeks later.
>
> So I will create a record in a database for each report that is created so
> users can access it later - maybe this can be seen as "uploading" a file to
> the server that acts as a document repository, with the only difference
> that the file is not uploaded, but produced by the server.
>

Well, if you need archival, there are two alternatives:

1. Write the file to disk at the same time it is being generated. There's
no reason you have to serve the file from where it was generated --
generate it, write it, and serve it.

2. Make sure the report will always be generated the same way. An analog
here -- if you request a page from a web server, it probably isn't saved on
disk like that (unless it's a genuinely static page) -- the server knows
how to reproduce the same page every time you request a specific URL. Make
the reports the same -- if you request /report/September-2013, you generate
the same report every time.

The second approach depends on whether you have well time-bucketed data,
but it's certainly possible to do.

>
> I don't see how I could use the xlsxwriter object in the way it is
> described here https://docs.djangoproject.**com/en/1.5/howto/outputting-**
> pdf/  - how
> could I pass the httpresponse object to xlsxWriter?
> (Maybe I have not yet found how this might work - but it is not what I
> need anyways...)
>

I haven't used xlsxwriter myself, but the key part of the PDF example is
that StringIO is an object that adheres to the python File API, but doesn't
actually involve a file. So, you open a StringIO object, "write" to it,
then dump the contents as the HTTP response.

So - whatever API endpoint on xlsxwriter lets you pass in a file object --
pass in a StringIO instance instead.

Yours,
Russ Magee %-)



Thomas
>
> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>
>>
>> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom  wrote:
>>
>>> Hi,
>>>
>>> I need to create database report downloads in Excel format (via
>>> xlsxwriter) and I'm wondering if there is any standard or best practice as
>>> to where those downloads should be located.
>>>
>>> Especially helpful would be if there was a portable way of managing the
>>> file system location and web request url in a way so that I don't have to
>>> change settings between the development and production server.
>>>
>>> Is this -> 
>>> https://docs.djangoproject.**com/en/1.5/topics/files/the
>>>  way to go?
>>>
>>> If they're sever generated, why do they need to hit the file system at
>> all?
>>
>> The following example in the docs:
>>
>> https://docs.djangoproject.**com/en/1.5/howto/outputting-**pdf/
>>
>> shows how you can stream a report directly to the end user. The example
>> uses reportlab to produce a PDF, but the same approach will work for a tool
>> writing to a different format.
>>
>> Yours,
>> Russ Magee %-)
>>
>>
>  --
> 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+unsubscr...@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/93413618-01d4-4fc0-a4d0-94fa67efe371%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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+unsubscr...@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-kJ%2BNhxt43b_ighenWZGErpHvPRE3q53BGrDczckFPyg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Custom Filter: Filter output based on a Python list

2013-10-02 Thread +Emmanuel
Am working on a Django project that retrieves a student's details from the 
database, filters them based on the 'period of examination' (this is 
implemented as a python list in a custom filter) and displays the output.

*Here is my custom filter:*

@register.filter
def periodofexamination(periodofexam):
periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
for period in periodofexam:
return period

*The template for displaying the output:*

{% extends 'base.html' %}
{% load results_extras %}
{% block title %}My Results{% endblock %}

{% block content %}
 My Tentative Examination Results
The results displayed below are tentative and 
for information purposes only.


Course CodeCourse NameCourse 
WorkExamGradeGPAYearExam 
Period
{% for query in queryset %}

{{ 
query.coursecode}}{{query.coursename}}{{query.coursework}}{{query.exam}}{{query.exam|grade}}{{query.exam|gpa}}{{query.academicyear}}{{query.examperiod}}
   
{% endfor %}

{% endblock %}

*The output:*
See the attached file (screenshot.png)

*The challenge:*
I would like to be able have the student results for a given exam period to 
appear each in their own table, for instance, all the results for exam 
period 'December 2011' should be in one table, all the results for exam 
period 'December 2010' should be in a different table. Currently, all the 
results appear in one table.
How do I implement this using a custom filter?
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+unsubscr...@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/bed2d4a9-2439-41bd-81a0-be2c4964ca6b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: Best practice for server-generated downloads?

2013-10-02 Thread Jirka Vejrazka
Hi Thomas,

 I'm doing exactly this - allowing users to download (graphically simple)
XLSx files from my web app, it also needs to be available for download
weeks later.

  As Russell pointed out, you don't need to store data on this if you have
a way of getting the same set of data later, you can always regenerate the
same Excel file. You don't even need to use StringIO for that.

 I'm using the save_virtual_notebook() in openpyxl package to generate the
Excel file straight from database upon each (infrequent) request.

  HTH

Jirka


On Wed, Oct 2, 2013 at 9:36 AM, Russell Keith-Magee  wrote:

>
> On Wed, Oct 2, 2013 at 2:33 PM, DJ-Tom  wrote:
>
>> Hi,
>>
>> this is quite easy to answer - those reports need to be archived - users
>> must be able to download them days or weeks later.
>>
>> So I will create a record in a database for each report that is created
>> so users can access it later - maybe this can be seen as "uploading" a file
>> to the server that acts as a document repository, with the only difference
>> that the file is not uploaded, but produced by the server.
>>
>
> Well, if you need archival, there are two alternatives:
>
> 1. Write the file to disk at the same time it is being generated. There's
> no reason you have to serve the file from where it was generated --
> generate it, write it, and serve it.
>
> 2. Make sure the report will always be generated the same way. An analog
> here -- if you request a page from a web server, it probably isn't saved on
> disk like that (unless it's a genuinely static page) -- the server knows
> how to reproduce the same page every time you request a specific URL. Make
> the reports the same -- if you request /report/September-2013, you generate
> the same report every time.
>
> The second approach depends on whether you have well time-bucketed data,
> but it's certainly possible to do.
>
>>
>> I don't see how I could use the xlsxwriter object in the way it is
>> described here https://docs.djangoproject.**com/en/1.5/howto/outputting-*
>> *pdf/  -
>> how could I pass the httpresponse object to xlsxWriter?
>> (Maybe I have not yet found how this might work - but it is not what I
>> need anyways...)
>>
>
> I haven't used xlsxwriter myself, but the key part of the PDF example is
> that StringIO is an object that adheres to the python File API, but doesn't
> actually involve a file. So, you open a StringIO object, "write" to it,
> then dump the contents as the HTTP response.
>
> So - whatever API endpoint on xlsxwriter lets you pass in a file object --
> pass in a StringIO instance instead.
>
> Yours,
> Russ Magee %-)
>
>
>
> Thomas
>>
>> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
>>
>>>
>>> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom  wrote:
>>>
 Hi,

 I need to create database report downloads in Excel format (via
 xlsxwriter) and I'm wondering if there is any standard or best practice as
 to where those downloads should be located.

 Especially helpful would be if there was a portable way of managing the
 file system location and web request url in a way so that I don't have to
 change settings between the development and production server.

 Is this -> 
 https://docs.djangoproject.**com/en/1.5/topics/files/the
  way to go?

 If they're sever generated, why do they need to hit the file system at
>>> all?
>>>
>>> The following example in the docs:
>>>
>>> https://docs.djangoproject.**com/en/1.5/howto/outputting-**pdf/
>>>
>>> shows how you can stream a report directly to the end user. The example
>>> uses reportlab to produce a PDF, but the same approach will work for a tool
>>> writing to a different format.
>>>
>>> Yours,
>>> Russ Magee %-)
>>>
>>>
>>  --
>> 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+unsubscr...@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/93413618-01d4-4fc0-a4d0-94fa67efe371%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> 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+unsubscr...@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/dj

Re: Custom Filter: Filter output based on a Python list

2013-10-02 Thread Leonardo Giordani
I'd cycle in the template through a list of exam periods, printing a table
for each cycle.
You have to pass the list of exam periods in the context of your view.

Try and let me know.

Regards,
Leo


Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2013/10/2 +Emmanuel 

> Am working on a Django project that retrieves a student's details from the
> database, filters them based on the 'period of examination' (this is
> implemented as a python list in a custom filter) and displays the output.
>
> *Here is my custom filter:*
>
> @register.filter
> def periodofexamination(periodofexam):
> periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
> for period in periodofexam:
> return period
>
> *The template for displaying the output:*
>
> {% extends 'base.html' %}
> {% load results_extras %}
> {% block title %}My Results{% endblock %}
>
> {% block content %}
>  My Tentative Examination Results
> The results displayed below are tentative
> and for information purposes only.
>
> 
> Course CodeCourse NameCourse
> WorkExamGradeGPAYearExam
> Period
> {% for query in queryset %}
>
> {{
> query.coursecode}}{{query.coursename}}{{query.coursework}}{{query.exam}}{{query.exam|grade}}{{query.exam|gpa}}{{query.academicyear}}{{query.examperiod}}
>
> {% endfor %}
> 
> {% endblock %}
>
> *The output:*
> See the attached file (screenshot.png)
>
> *The challenge:*
> I would like to be able have the student results for a given exam period
> to appear each in their own table, for instance, all the results for exam
> period 'December 2011' should be in one table, all the results for exam
> period 'December 2010' should be in a different table. Currently, all the
> results appear in one table.
> How do I implement this using a custom filter?
> 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+unsubscr...@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/bed2d4a9-2439-41bd-81a0-be2c4964ca6b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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+unsubscr...@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/CAEhE%2BO%3DsKK-mb4nMTBf493e%2BJ2483i3Qeuh%3D8qJ8Ckur1qJ%2B%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best practice for server-generated downloads?

2013-10-02 Thread François Schiettecatte
Hi

+1 on this except that I use xlrd and xlwt to read and write Excel files. To 
generate the excel file I just generate a list of lists (an array effectively) 
and pass that through a function which walks the list and generates the excel 
worksheet that I write to a StringIO so it can be returned to the client.

François

On Oct 2, 2013, at 6:34 AM, Jirka Vejrazka  wrote:

> Hi Thomas, 
> 
>  I'm doing exactly this - allowing users to download (graphically simple) 
> XLSx files from my web app, it also needs to be available for download weeks 
> later. 
> 
>   As Russell pointed out, you don't need to store data on this if you have a 
> way of getting the same set of data later, you can always regenerate the same 
> Excel file. You don't even need to use StringIO for that.
> 
>  I'm using the save_virtual_notebook() in openpyxl package to generate the 
> Excel file straight from database upon each (infrequent) request.
> 
>   HTH
> 
> Jirka
> 
> 
> On Wed, Oct 2, 2013 at 9:36 AM, Russell Keith-Magee  
> wrote:
> 
> On Wed, Oct 2, 2013 at 2:33 PM, DJ-Tom  wrote:
> Hi,
> 
> this is quite easy to answer - those reports need to be archived - users must 
> be able to download them days or weeks later.
> 
> So I will create a record in a database for each report that is created so 
> users can access it later - maybe this can be seen as "uploading" a file to 
> the server that acts as a document repository, with the only difference that 
> the file is not uploaded, but produced by the server.
> 
> Well, if you need archival, there are two alternatives:
> 
> 1. Write the file to disk at the same time it is being generated. There's no 
> reason you have to serve the file from where it was generated -- generate it, 
> write it, and serve it.
> 
> 2. Make sure the report will always be generated the same way. An analog here 
> -- if you request a page from a web server, it probably isn't saved on disk 
> like that (unless it's a genuinely static page) -- the server knows how to 
> reproduce the same page every time you request a specific URL. Make the 
> reports the same -- if you request /report/September-2013, you generate the 
> same report every time. 
> 
> The second approach depends on whether you have well time-bucketed data, but 
> it's certainly possible to do.
> 
> I don't see how I could use the xlsxwriter object in the way it is described 
> here https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/ - how could 
> I pass the httpresponse object to xlsxWriter?
> (Maybe I have not yet found how this might work - but it is not what I need 
> anyways...)
> 
> I haven't used xlsxwriter myself, but the key part of the PDF example is that 
> StringIO is an object that adheres to the python File API, but doesn't 
> actually involve a file. So, you open a StringIO object, "write" to it, then 
> dump the contents as the HTTP response. 
> 
> So - whatever API endpoint on xlsxwriter lets you pass in a file object -- 
> pass in a StringIO instance instead.
> 
> Yours,
> Russ Magee %-)
> 
> 
> 
> Thomas
> 
> Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
> 
> On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom  wrote:
> Hi,
> 
> I need to create database report downloads in Excel format (via xlsxwriter) 
> and I'm wondering if there is any standard or best practice as to where those 
> downloads should be located.
> 
> Especially helpful would be if there was a portable way of managing the file 
> system location and web request url in a way so that I don't have to change 
> settings between the development and production server.
> 
> Is this -> https://docs.djangoproject.com/en/1.5/topics/files/ the way to go?
> 
> If they're sever generated, why do they need to hit the file system at all? 
> 
> The following example in the docs:
> 
> https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/
> 
> shows how you can stream a report directly to the end user. The example uses 
> reportlab to produce a PDF, but the same approach will work for a tool 
> writing to a different format.
> 
> Yours,
> Russ Magee %-)
>  
> 
> -- 
> 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+unsubscr...@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/93413618-01d4-4fc0-a4d0-94fa67efe371%40googlegroups.com.
> 
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@go

Re: Custom Filter: Filter output based on a Python list

2013-10-02 Thread +Emmanuel
That's what I have been trying to do for quite sometime now! I can't seem 
to get the code right.

On Wednesday, October 2, 2013 2:13:25 PM UTC+3, Leo wrote:
>
> I'd cycle in the template through a list of exam periods, printing a table 
> for each cycle.
> You have to pass the list of exam periods in the context of your view.
>
> Try and let me know.
>
> Regards,
> Leo
>
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub 
> page  - My Coderwall 
> profile
>  
>
> 2013/10/2 +Emmanuel >
>
>> Am working on a Django project that retrieves a student's details from 
>> the database, filters them based on the 'period of examination' (this is 
>> implemented as a python list in a custom filter) and displays the output.
>>
>> *Here is my custom filter:*
>>
>> @register.filter
>> def periodofexamination(periodofexam):
>> periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
>> for period in periodofexam:
>> return period
>>
>> *The template for displaying the output:*
>>
>> {% extends 'base.html' %}
>> {% load results_extras %}
>> {% block title %}My Results{% endblock %}
>>
>> {% block content %}
>>  My Tentative Examination Results
>> The results displayed below are tentative 
>> and for information purposes only.
>>
>> 
>> Course CodeCourse NameCourse 
>> WorkExamGradeGPAYearExam 
>> Period
>> {% for query in queryset %}
>> 
>> {{ 
>> query.coursecode}}{{query.coursename}}{{query.coursework}}{{query.exam}}{{query.exam|grade}}{{query.exam|gpa}}{{query.academicyear}}{{query.examperiod}}
>>
>> {% endfor %}
>> 
>> {% endblock %}
>>
>> *The output:*
>> See the attached file (screenshot.png)
>>
>> *The challenge:*
>> I would like to be able have the student results for a given exam period 
>> to appear each in their own table, for instance, all the results for exam 
>> period 'December 2011' should be in one table, all the results for exam 
>> period 'December 2010' should be in a different table. Currently, all the 
>> results appear in one table.
>> How do I implement this using a custom filter?
>> 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...@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/bed2d4a9-2439-41bd-81a0-be2c4964ca6b%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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+unsubscr...@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/8bb1abd1-7cc4-44a4-aba4-2087b88d554d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Custom Filter: Filter output based on a Python list

2013-10-02 Thread Leonardo Giordani
Can you perhaps paste the view you are using to render the template? So I
can try and help your with some code

Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2013/10/2 +Emmanuel 

> That's what I have been trying to do for quite sometime now! I can't seem
> to get the code right.
>
>
> On Wednesday, October 2, 2013 2:13:25 PM UTC+3, Leo wrote:
>
>> I'd cycle in the template through a list of exam periods, printing a
>> table for each cycle.
>> You have to pass the list of exam periods in the context of your view.
>>
>> Try and let me know.
>>
>> Regards,
>> Leo
>>
>>
>> Leonardo Giordani
>> Author of The Digital Cat 
>> My profile on About.me  - My GitHub
>> page  - My Coderwall 
>> profile
>>
>>
>> 2013/10/2 +Emmanuel 
>>
>>> Am working on a Django project that retrieves a student's details from
>>> the database, filters them based on the 'period of examination' (this is
>>> implemented as a python list in a custom filter) and displays the output.
>>>
>>> *Here is my custom filter:*
>>>
>>> @register.filter
>>> def periodofexamination(**periodofexam):
>>> periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
>>> for period in periodofexam:
>>> return period
>>>
>>> *The template for displaying the output:*
>>>
>>> {% extends 'base.html' %}
>>> {% load results_extras %}
>>> {% block title %}My Results{% endblock %}
>>>
>>> {% block content %}
>>>  My Tentative Examination Results
>>> The results displayed below are tentative
>>> and for information purposes only.
>>>
>>> 
>>> Course CodeCourse NameCourse
>>> WorkExam**GradeGPA**YearExam
>>> Period
>>> {% for query in queryset %}
>>>
>>> {{ query.coursecode}}{{**
>>> query.coursename}}{{**query.coursework}}{{**
>>> query.exam}}{{query.**exam|grade}}{{query.**
>>> exam|gpa}}{{query.**academicyear}}{{**
>>> query.examperiod}}
>>>
>>> {% endfor %}
>>> 
>>> {% endblock %}
>>>
>>> *The output:*
>>> See the attached file (screenshot.png)
>>>
>>> *The challenge:*
>>> I would like to be able have the student results for a given exam period
>>> to appear each in their own table, for instance, all the results for exam
>>> period 'December 2011' should be in one table, all the results for exam
>>> period 'December 2010' should be in a different table. Currently, all the
>>> results appear in one table.
>>> How do I implement this using a custom filter?
>>> 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...@**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/bed2d4a9-**2439-41bd-81a0-be2c4964ca6b%**
>>> 40googlegroups.com
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>
>>  --
> 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+unsubscr...@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/8bb1abd1-7cc4-44a4-aba4-2087b88d554d%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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+unsubscr...@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/CAEhE%2BOnt7phVNgR5F13Jo4CgRW_of%2BU%3D86N%2BOjnY5YzfSg3jJA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


model inheritance

2013-10-02 Thread Roberto López López
Hi,

I am extending a 3rd party model in my application, using multi-table
inheritance. I can create an instance and modify it, but when I try to
list the created objects at http://localhost:8000/en/admin/news/news/ ,
I am getting a nice exception:

Traceback:
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response
  140. response = response.render()
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
in render
  105. self.content = self.rendered_content
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
in rendered_content
  82. content = template.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  140. return self._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  124. return compiled_parent._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  124. return compiled_parent._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  63. result = block.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  63. result = block.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  1185. _dict = func(*resolved_args,
**resolved_kwargs)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in result_list
  286. 'results': list(results(cl))}
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in results
  264. yield ResultList(None, items_for_result(cl, res,
None))
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in __init__
  256. super(ResultList, self).__init__(*items)

Re: Custom Filter: Filter output based on a Python list

2013-10-02 Thread +Emmanuel
Here's the view:
def results_page(request):
queryset = Results.objects.all().filter(reg_number = 'DBA/20020/82/DU')
return render_to_response('results.html', locals(), context_instance = 
RequestContext(request))

Please note that, so far, there's nothing wrong with the view. Using the 
custom filter at the output level is where the issue is.
What I want to do is something close to this (note the bold items):

*{% for query in queryset|periodofexamination %}*

Course CodeCourse NameCourse 
WorkExamGradeGPAYearExam 
Period
   
{{ 
query.coursecode}}{{query.coursename}}{{query.coursework}}{{query.exam}}{{query.exam|grade}}{{query.exam|gpa}}{{query.academicyear}}{{query.examperiod}}
   

{% endfor %}
{% endblock %}

On Wednesday, October 2, 2013 3:00:40 PM UTC+3, Leo wrote:
>
> Can you perhaps paste the view you are using to render the template? So I 
> can try and help your with some code
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub 
> page  - My Coderwall 
> profile
>  
>
> 2013/10/2 +Emmanuel >
>
>> That's what I have been trying to do for quite sometime now! I can't seem 
>> to get the code right.
>>
>>
>> On Wednesday, October 2, 2013 2:13:25 PM UTC+3, Leo wrote:
>>
>>> I'd cycle in the template through a list of exam periods, printing a 
>>> table for each cycle.
>>> You have to pass the list of exam periods in the context of your view.
>>>
>>> Try and let me know.
>>>
>>> Regards,
>>> Leo
>>>
>>>
>>> Leonardo Giordani
>>> Author of The Digital Cat 
>>> My profile on About.me  - My GitHub 
>>> page  - My Coderwall 
>>> profile
>>>  
>>>
>>> 2013/10/2 +Emmanuel 
>>>
  Am working on a Django project that retrieves a student's details 
 from the database, filters them based on the 'period of examination' (this 
 is implemented as a python list in a custom filter) and displays the 
 output.

 *Here is my custom filter:*

 @register.filter
 def periodofexamination(**periodofexam):
 periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
 for period in periodofexam:
 return period

 *The template for displaying the output:*

 {% extends 'base.html' %}
 {% load results_extras %}
 {% block title %}My Results{% endblock %}

 {% block content %}
  My Tentative Examination Results
 The results displayed below are tentative 
 and for information purposes only.

 
 Course CodeCourse NameCourse 
 WorkExam**GradeGPA**YearExam 
 Period
 {% for query in queryset %}
 
 {{ query.coursecode}}{{**
 query.coursename}}{{**query.coursework}}{{**
 query.exam}}{{query.**exam|grade}}{{query.**
 exam|gpa}}{{query.**academicyear}}{{**
 query.examperiod}}

 {% endfor %}
 
 {% endblock %}

 *The output:*
 See the attached file (screenshot.png)

 *The challenge:*
 I would like to be able have the student results for a given exam 
 period to appear each in their own table, for instance, all the results 
 for 
 exam period 'December 2011' should be in one table, all the results for 
 exam period 'December 2010' should be in a different table. Currently, all 
 the results appear in one table.
 How do I implement this using a custom filter?
 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...@**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/bed2d4a9-**2439-41bd-81a0-be2c4964ca6b%**
 40googlegroups.com
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .

>>>
>>>  -- 
>> 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/8bb1abd1-7cc4

automated unit test generation

2013-10-02 Thread skunkwerk
Hi, 
   I've been working on an open source project to auto-generate unit tests 
for web apps based on traces collected from the web server and static code 
analysis.  I've got an alpha version online at www.splintera.com, and the 
source is at https://github.com/splintera/python-django-client.  I'd love 
to get some feedback from the community and extend it to work with other 
languages as well.

  I wrote it originally because I was sick of coming into companies where I 
had to inherit tens of thousands of lines of code without any tests, and 
never had time to write them manually - being careful to mock out 
dependencies, specify the correct inputs and outputs, and figure out which 
path it was taking through the code. 

   I'd like to get some sense of: 
- how difficult/tedious is writing unit tests, and why? 
- do you wish you had better code coverage? 
- how important is testing to you? 

thanks, 
imran 

-- 
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+unsubscr...@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/5a67363c-9e05-4e95-bd6c-78dda14c7483%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Custom Filter: Filter output based on a Python list

2013-10-02 Thread Leonardo Giordani
Ok, now I get the point. I STRONGLY suggest to avoid performing big
computations while rendering templates, so I think it is better for you to
try something like

def results_page(request):
context = {}
context.update(locals())
context['periods'] = {}
for period in ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']:
context['periods'][period] = Results.objects.all().filter(\
   reg_number =
'DBA/20020/82/DU').filter()
return render_to_response('results.html', context, context_instance =
RequestContext(request))

and in template

{% for period,results in periods.items %}

[...]
Here you can use {{period}}, which is in turn 'DECEMBER 2011', 'MAY
2011', and so on, and
{{result}} that encompasses the values extracted from the DB.
[...]

{% endfor %}

I included a filter() since I do not know the
models, so I do not know how you can filter out by examination period.

Please note that I would not pass the whole locals() dict to the view, but
carefully select what I need in the template.

Speaking about your filter

@register.filter
def periodofexamination(periodofexam):
periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
for period in periodofexam:
return period

I think you misunderstood the filter role, which is, indeed, to filter,
things. Here, the input periodofexam variable is not filtered, but
overwritten. Furthermore, you use return in a for loop, so the result of
your filter is 'DECEMBER 2011' irrespective of the input value.

Please check the above code, I wrote it directly in the mail composer, so
bugs are certainly lurking.

Let me know if you succeed in solving the problem

Leo




Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2013/10/2 +Emmanuel 

> Here's the view:
> def results_page(request):
> queryset = Results.objects.all().filter(reg_number = 'DBA/20020/82/DU')
> return render_to_response('results.html', locals(), context_instance =
> RequestContext(request))
>
> Please note that, so far, there's nothing wrong with the view. Using the
> custom filter at the output level is where the issue is.
> What I want to do is something close to this (note the bold items):
>
> *{% for query in queryset|periodofexamination %}*
> 
> Course CodeCourse NameCourse
> WorkExamGradeGPAYearExam
> Period
>
> {{
> query.coursecode}}{{query.coursename}}{{query.coursework}}{{query.exam}}{{query.exam|grade}}{{query.exam|gpa}}{{query.academicyear}}{{query.examperiod}}
>
> 
> {% endfor %}
> {% endblock %}
>
> On Wednesday, October 2, 2013 3:00:40 PM UTC+3, Leo wrote:
>
>> Can you perhaps paste the view you are using to render the template? So I
>> can try and help your with some code
>>
>> Leonardo Giordani
>> Author of The Digital Cat 
>> My profile on About.me  - My GitHub
>> page  - My Coderwall 
>> profile
>>
>>
>> 2013/10/2 +Emmanuel 
>>
>>> That's what I have been trying to do for quite sometime now! I can't
>>> seem to get the code right.
>>>
>>>
>>> On Wednesday, October 2, 2013 2:13:25 PM UTC+3, Leo wrote:
>>>
 I'd cycle in the template through a list of exam periods, printing a
 table for each cycle.
 You have to pass the list of exam periods in the context of your view.

 Try and let me know.

 Regards,
 Leo


 Leonardo Giordani
 Author of The Digital Cat 
 My profile on About.me  - My GitHub
 page  - My Coderwall 
 profile


 2013/10/2 +Emmanuel 

>  Am working on a Django project that retrieves a student's details
> from the database, filters them based on the 'period of examination' (this
> is implemented as a python list in a custom filter) and displays the 
> output.
>
> *Here is my custom filter:*
>
> @register.filter
> def periodofexamination(**periodofex**am):
> periodofexam = ['DECEMBER 2011', 'MAY 2011', 'DECEMBER 2010']
> for period in periodofexam:
> return period
>
> *The template for displaying the output:*
>
> {% extends 'base.html' %}
> {% load results_extras %}
> {% block title %}My Results{% endblock %}
>
> {% block content %}
>  My Tentative Examination Results
> The results displayed below are
> tentative and for information purposes only.
>
> 
> Course CodeCourse NameCourse
> WorkExam**Grad**eGPA**YearExam
> Period
> {% for query in queryset %}
>
> {{ query.coursecode}}{{**q**
> uery.coursename}}{{**qu**ery.coursework}}{

Re: model inheritance

2013-10-02 Thread Leonardo Giordani
Are you sure your DB has been synced after putting the ForeignKey(News) in
your Department model?
Can you post somewhere the following models: News, OldNews, Department?

Regards,

Leo

Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2013/10/2 Roberto López López 

>  Hi,
>
> I am extending a 3rd party model in my application, using multi-table
> inheritance. I can create an instance and modify it, but when I try to list
> the created objects at http://localhost:8000/en/admin/news/news/ , I am
> getting a nice exception:
>
> Traceback:
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   140. response = response.render()
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in render
>   105. self.content = self.rendered_content
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   82. content = template.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   140. return self._render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   63. result = block.nodelist.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   63. result = block.nodelist.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   1185. _dict = func(*resolved_args, **resolved_kwargs)
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
> in result_list
>   286. 'results': list(results(cl))}
> File
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
> in results
>   264. yield ResultList(None

Re: Two sets of registration with django-registration

2013-10-02 Thread Vibhu Rishi
hi

I have updated and using All Auth now. I also liked it that i can do the
social logins and the linkedin login seems to be working so far :)

Can you point me to documentation on how to ovveride the methods ? I dont
know so much about this part of django and am a bit at a loss in my
implementation.

vibhu


On Tue, Sep 24, 2013 at 7:32 AM, Vibhu Rishi  wrote:

> Thanks for the pointer. Will check out all auth.
>
> V.
>
>
> On Tue, Sep 24, 2013 at 4:03 AM, Kamil Gałuszka wrote:
>
>>
>> Of course.
>>
>> First of all I would recommend you using of django-allauth. They are
>> having great docs and they support custom user model. django-registration
>> is little less maintained and maybe less suitable for your needs.
>>
>> First you define your custom form in settings.py:
>> SIGNUP_FORM_CLASS
>>
>> Then you are inherit this class
>> https://github.com/pennersr/django-allauth/blob/master/allauth/account/adapter.pyand
>>  override method save_user to actually do what you want.
>>
>> And that is it. Is just that simple
>>
>> Cheers
>> Kamil
>>
>>
>>
>>
>> On Monday, September 23, 2013 7:32:38 PM UTC+2, Vibhu Rishi wrote:
>>>
>>> Hi,
>>>
>>> I have 2 types of users with different views of the same page . Using
>>> django-registration, I have been able to setup all the signup/password
>>> change etc for one level of users - say students.
>>>
>>> Now I want to have another set of registrations for Teachers. Is there a
>>> way to achieve that ?
>>>
>>> Vibhu
>>>
>>> --
>>> Simplicity is the ultimate sophistication. - Leonardo da Vinci
>>> Life is really simple, but we insist on making it complicated. -
>>> Confucius
>>>
>>  --
>> 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+unsubscr...@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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Simplicity is the ultimate sophistication. - Leonardo da Vinci
> Life is really simple, but we insist on making it complicated. - Confucius
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
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+unsubscr...@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/CAPiONw%3DSGHvprmV3QYF967i7Ce5z1hQZsPH-%3DDJdoSHpwrMSeg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: automated unit test generation

2013-10-02 Thread Derek
Imran

Sounds very useful (I am now in that position of having to generate tests 
for an existing code base).  Can this be run as a stand-alone tool?  I ask 
because your website says "we continue to collect data on real-world usage 
through low overhead sampling on your production servers"; but that will 
not be possible as we are running behind a firewall.

Thanks
Derek

PS Maybe on your site you need to quote Jacob: 'Code without tests is 
broken as designed'.

On Wednesday, 2 October 2013 14:59:55 UTC+2, skunkwerk wrote:
>
> Hi, 
>I've been working on an open source project to auto-generate unit tests 
> for web apps based on traces collected from the web server and static code 
> analysis.  I've got an alpha version online at www.splintera.com, and the 
> source is at https://github.com/splintera/python-django-client.  I'd love 
> to get some feedback from the community and extend it to work with other 
> languages as well.
>
>   I wrote it originally because I was sick of coming into companies where 
> I had to inherit tens of thousands of lines of code without any tests, and 
> never had time to write them manually - being careful to mock out 
> dependencies, specify the correct inputs and outputs, and figure out which 
> path it was taking through the code. 
>
>I'd like to get some sense of: 
> - how difficult/tedious is writing unit tests, and why? 
> - do you wish you had better code coverage? 
> - how important is testing to you? 
>
> thanks, 
> imran 
>

-- 
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+unsubscr...@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/f2042e2e-4d74-40a2-af09-a2b7d38a0b99%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best practice for server-generated downloads?

2013-10-02 Thread Timothy W. Cook
I tried to return a generated file but it seems that the Admin interface
(or middleware?) is capturing my response.

I get a brief blank page and then the Admin interface again without eve
getting the download prompt.

My last attempt looked like this:
fname = 'ccd-'+self.ct_id+'.xsd'
response = HttpResponse(ccd_str, content_type='application/xml')
response['Content-Disposition'] = 'attachment; ' + fname
return response

Where ccd_str contains the text (an XML Schema) which is also written to
the database.  I did try a few other approaches according to the
documentation and entries on StackOverflow.

Can this be dome using the Admin interface?  Any ideas?

Thanks,
Tim





On Wed, Oct 2, 2013 at 8:26 AM, François Schiettecatte <
fschietteca...@gmail.com> wrote:

> Hi
>
> +1 on this except that I use xlrd and xlwt to read and write Excel files.
> To generate the excel file I just generate a list of lists (an array
> effectively) and pass that through a function which walks the list and
> generates the excel worksheet that I write to a StringIO so it can be
> returned to the client.
>
> François
>
> On Oct 2, 2013, at 6:34 AM, Jirka Vejrazka 
> wrote:
>
> > Hi Thomas,
> >
> >  I'm doing exactly this - allowing users to download (graphically
> simple) XLSx files from my web app, it also needs to be available for
> download weeks later.
> >
> >   As Russell pointed out, you don't need to store data on this if you
> have a way of getting the same set of data later, you can always regenerate
> the same Excel file. You don't even need to use StringIO for that.
> >
> >  I'm using the save_virtual_notebook() in openpyxl package to generate
> the Excel file straight from database upon each (infrequent) request.
> >
> >   HTH
> >
> > Jirka
> >
> >
> > On Wed, Oct 2, 2013 at 9:36 AM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
> >
> > On Wed, Oct 2, 2013 at 2:33 PM, DJ-Tom  wrote:
> > Hi,
> >
> > this is quite easy to answer - those reports need to be archived - users
> must be able to download them days or weeks later.
> >
> > So I will create a record in a database for each report that is created
> so users can access it later - maybe this can be seen as "uploading" a file
> to the server that acts as a document repository, with the only difference
> that the file is not uploaded, but produced by the server.
> >
> > Well, if you need archival, there are two alternatives:
> >
> > 1. Write the file to disk at the same time it is being generated.
> There's no reason you have to serve the file from where it was generated --
> generate it, write it, and serve it.
> >
> > 2. Make sure the report will always be generated the same way. An analog
> here -- if you request a page from a web server, it probably isn't saved on
> disk like that (unless it's a genuinely static page) -- the server knows
> how to reproduce the same page every time you request a specific URL. Make
> the reports the same -- if you request /report/September-2013, you generate
> the same report every time.
> >
> > The second approach depends on whether you have well time-bucketed data,
> but it's certainly possible to do.
> >
> > I don't see how I could use the xlsxwriter object in the way it is
> described here https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/- 
> how could I pass the httpresponse object to xlsxWriter?
> > (Maybe I have not yet found how this might work - but it is not what I
> need anyways...)
> >
> > I haven't used xlsxwriter myself, but the key part of the PDF example is
> that StringIO is an object that adheres to the python File API, but doesn't
> actually involve a file. So, you open a StringIO object, "write" to it,
> then dump the contents as the HTTP response.
> >
> > So - whatever API endpoint on xlsxwriter lets you pass in a file object
> -- pass in a StringIO instance instead.
> >
> > Yours,
> > Russ Magee %-)
> >
> >
> >
> > Thomas
> >
> > Am Mittwoch, 2. Oktober 2013 02:11:21 UTC+2 schrieb Russell Keith-Magee:
> >
> > On Tue, Oct 1, 2013 at 9:49 PM, DJ-Tom  wrote:
> > Hi,
> >
> > I need to create database report downloads in Excel format (via
> xlsxwriter) and I'm wondering if there is any standard or best practice as
> to where those downloads should be located.
> >
> > Especially helpful would be if there was a portable way of managing the
> file system location and web request url in a way so that I don't have to
> change settings between the development and production server.
> >
> > Is this -> https://docs.djangoproject.com/en/1.5/topics/files/ the way
> to go?
> >
> > If they're sever generated, why do they need to hit the file system at
> all?
> >
> > The following example in the docs:
> >
> > https://docs.djangoproject.com/en/1.5/howto/outputting-pdf/
> >
> > shows how you can stream a report directly to the end user. The example
> uses reportlab to produce a PDF, but the same approach will work for a tool
> writing to a different format.
> >
> > Yours,
> > Russ Magee %-)

Re: model inheritance

2013-10-02 Thread Roberto López López

Hi Leonardo, thanks for your answer.

Yes, it has been synced.

The model itself is a little bit bigger, as you can notice from the code
https://dpaste.de/c3Rg I am using as well the News model from
https://github.com/wildfish/cmsplugin_news/blob/master/cmsplugin_news/models.py

Regards,

Roberto





On 10/02/2013 03:45 PM, Leonardo Giordani wrote:
> Are you sure your DB has been synced after putting the
> ForeignKey(News) in your Department model?
> Can you post somewhere the following models: News, OldNews, Department?
>
> Regards,
>
> Leo
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub
> page  - My Coderwall profile
> 
>
>
> 2013/10/2 Roberto López López  >
>
> Hi,
>
> I am extending a 3rd party model in my application, using
> multi-table inheritance. I can create an instance and modify it,
> but when I try to list the created objects at
> http://localhost:8000/en/admin/news/news/ , I am getting a nice
> exception:
>
> Traceback:
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   140. response = response.render()
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in render
>   105. self.content = self.rendered_content
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   82. content = template.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   140. return self._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   63. result = block.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> 

Django 1.4 Form Wizard and browser back button document expired

2013-10-02 Thread Laura Morgan
Hi,

Working on a 3 step process, using a SessionWizardView class in Django 1.4 
Form wizard.  In IE (mostly, although have seen in other browsers), If user 
hits browser back button instead of the form PREV button, in some cases it 
gives "Document expired".  This probably isn't a wizard thing, but just 
wondering if anyone has dealt with this.

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+unsubscr...@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/857db7d2-c617-4e01-bf4c-a9261543358b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: model inheritance

2013-10-02 Thread Roberto López López

Is there maybe a way to set the cmsplugin_news.News.Meta.abstract option
to True? In order to prevent accessing the parent model to fetch the
inherited data.



On 10/02/2013 03:45 PM, Leonardo Giordani wrote:
> Are you sure your DB has been synced after putting the
> ForeignKey(News) in your Department model?
> Can you post somewhere the following models: News, OldNews, Department?
>
> Regards,
>
> Leo
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub
> page  - My Coderwall profile
> 
>
>
> 2013/10/2 Roberto López López  >
>
> Hi,
>
> I am extending a 3rd party model in my application, using
> multi-table inheritance. I can create an instance and modify it,
> but when I try to list the created objects at
> http://localhost:8000/en/admin/news/news/ , I am getting a nice
> exception:
>
> Traceback:
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   140. response = response.render()
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in render
>   105. self.content = self.rendered_content
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   82. content = template.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   140. return self._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   63. result = block.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   63. 

Re: how to start learning Django in Windows Platform

2013-10-02 Thread Vernon D. Cole
You can run all of the tutorial stuff in Windows, and it's not a bad idea 
to learn things one-at-a-time.  I would suggest, however, that if you are 
serious about using django, you need to learn Linux, too.  The easiest way 
to do that would be to download the current Ubuntu desktop version, make 
appropriate bootable media, and install it on a laptop or workstation you 
already use.  The installation will re-partition the disk and set up the 
dual-boot configuration for you.  Then use Linux to do your more advanced 
django learning projects. 

On Tuesday, October 1, 2013 9:42:59 AM UTC-6, Ahsan Ahmad wrote:
>
> Hi,
> This is Ahsan. and i am brand fresh programmer in Django. Please guide the 
> easiest way to start learning Django.
>
> Thank You
>

-- 
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+unsubscr...@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/0b8617e7-a6bf-4dac-8867-4e2e3170c26f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


new project: django-mini-lean. no more excuses for not split testing!

2013-10-02 Thread Dan Ancona
Hiya django-users -

Long time lurker, and long time user of many open source projects that I've 
never felt like I contributed enough back to. Finally changing that a bit 
today with the release of this an open source split testing framework, 
Django Mini Lean:

https://github.com/DanAncona/django-mini-lean

The details are all on there but to summarize, it's an example of an easy 
way to do split testing, using django. Came out of my previous startup, 
Democracy Dashboard. We kept finding excuses to move the split testing 
story farther down in our tracker. This likely wasn't why we failed to 
prove out a functional growth hypothesis, but I'm sure it didn't help. I 
hope with the release of this we will remove the excuses for someone out 
there!

Two quick notes -

1 - this is my first open source contribution, and most of this code was 
written just by me. So I could not be more open to feedback on everything 
from coding style to how to package this up better to feature requests.

2 - I had a rather abrupt layoff from a job a few weeks ago, and just found 
I am not in fact eligible for unemployment. (didn't know this was even 
possible) So I'm looking for both FT and short term contract work. My ideal 
role isn't just writing code: I like a little evangelism, customer or 
product development, UX or even tech sales along with it. Hope this isn't 
against list protocols.

Thanks, enjoy and please let me know if you have any questions or feedback 
about mini lean!

Dan

-- 
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+unsubscr...@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/e2b3fe8b-105f-4c77-8ab9-1779db990c38%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Is there an equivalent to JPA @embedded in django modeling

2013-10-02 Thread Khanh Tran
Lets say both Customer and Business have an Address. In JPA, we can store 
address attributes(street,city,state,zip) directly inside Customer and 
Business using @Embedded annotation.Is there an equivalent to @embedded in 
python without using ForeignKey field. 

-- 
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+unsubscr...@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/a3cc0fb3-93f1-4759-a30b-b91b22ae47d1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Is there an equivalent to JPA @embedded in django modeling

2013-10-02 Thread Jonathan D. Baker
Could you use an abstract base class to define the address fields and then 
inherit from that?

Sent from my iPhone

> On Oct 2, 2013, at 4:55 PM, Khanh Tran  wrote:
> 
> Lets say both Customer and Business have an Address. In JPA, we can store 
> address attributes(street,city,state,zip) directly inside Customer and 
> Business using @Embedded annotation.Is there an equivalent to @embedded in 
> python without using ForeignKey field. 
> -- 
> 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+unsubscr...@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/a3cc0fb3-93f1-4759-a30b-b91b22ae47d1%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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+unsubscr...@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/510ABBAA-0539-4D5F-A470-AA61704E47C8%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Tests not loading initial_data fixtures

2013-10-02 Thread Sam Lai
I'm trying to test a Django management command in app X that parses
data files and inserts data into models that are located in apps Y and
Z. Apps Y and Z have initial_data.json files in them. On running my
test however, it seems that my initial_data fixtures are not being
loaded.

I could specify the initial_data fixtures manually (presumably I can
do ../) using the 'fixtures' variable in my TestCase, but that isn't
very DRY and becomes tedious when more apps are introduced with their
own initial_data.

I tracked this down to a change that Russell made 3 years ago
(https://github.com/django/django/commit/b31a1b99261d05bf8a34495ee9faf4d6592b8b36).
The commit message and content explains why *custom SQL* fixtures
aren't loaded automatically during testing, but says nothing about why
xml/yaml/json fixtures are no longer loaded either.

All django-users threads that I can find on this refer to the
situation prior to this change, and state that initial_data fixtures
*were* loaded.

What's the reason for the change? I thought initial_data is designed
for data that should always be in the database, so this is a bit odd.
Can't really find anything in the docs that mentions this either.

Thanks,

Sam

-- 
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+unsubscr...@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/CABxbXqV1BUxGj8OgV-y3Z%2Bh%2BQ17i-gKujKPBXtANZToGOE%2BwVg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


is it possible to make the |safe template filter conditional on content

2013-10-02 Thread Mike Dewhirst
I made a custom template filter (ref_href) which converts numbered 
references (like [1], [2] etc) into footnote hyperlinks. It works but 
requires the |safe filter which is dangerous.


To be actually safe I want to *only* use the |safe filter when the data 
contains a numbered reference. Which I cannot do if it is permanently in 
the template. In other words, I want to remove the |safe filter from the 
template and incorporate it into my custom filter which checks that we 
have an integer between the square brackets before doing its work.


Just thinking about it now, I suppose I could put a conditional in the 
template ...


{% if "[" in value %}
  {{ value | ref_href | safe }}
{% else %}
  {{ value }}
{% endif %}

... but that's a lot of typing over dozens of templates. And it isn't 
good enough.


Thanks for any secrets

Mike

--
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+unsubscr...@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/524D14D9.5090605%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.