Friday, February 28, 2014

Re: Bus Error on Development Server

On 2/28/14 6:16 PM, Gkpetrak wrote:
Hello,

I was trying to process Images with some python scripts, when I receive bus error. After that I had many bus errors on different programs.
Finally I tried to start django' development server, and I received the same error.
The "after that I had many bus errors on different programs" is the clue that perhaps your physical memory has a bad spot.

Your image processing might have used more physical memory than your typical computer load uses, and ended up in a bad part of memory.

I would recommend running an intensive memory test (e.g. memtest86+) to isolate which memory chip is at fault, and either yank it or replace it.

hth

                                - Tom

I know that this error happens when a process is trying to access memory  that the CPU cannot physically address.    I checked my log files and the output of the error is the following:

T02:13:26.879355+02:00 suse-pc kernel: [ 9976.488797] ata1.00: exception Emask 0x0 SAct 0x1 SErr 0x0 action 0x0    2014-03-01T02:13:26.879402+02:00 suse-pc kernel: [ 9976.488806] ata1.00: irq_stat 0x40000008    2014-03-01T02:13:26.879413+02:00 suse-pc kernel: [ 9976.488813] ata1.00: failed command: READ FPDMA QUEUED    2014-03-01T02:13:26.879419+02:00 suse-pc kernel: [   9976.488826] ata1.00: cmd 60/08:00:50:8d:75/00:00:39:00:00/40 tag 0 ncq   4096 in    2014-03-01T02:13:26.879428+02:00 suse-pc kernel: [   9976.488826]          res 41/40:08:51:8d:75/00:00:39:00:00/00 Emask   0x409 (media error) <F>  2014-03-01T02:13:26.879434+02:00 suse-pc kernel: [ 9976.488832] ata1.00: status: { DRDY ERR }    2014-03-01T02:13:26.879437+02:00 suse-pc kernel: [ 9976.488836] ata1.00: error: { UNC }    2014-03-01T02:13:26.948294+02:00 suse-pc kernel: [ 9976.557999] ata1.00: configured for UDMA/133    2014-03-01T02:13:26.948313+02:00 suse-pc kernel: [ 9976.558034] sd 0:0:0:0: [sda] Unhandled sense code    2014-03-01T02:13:26.948315+02:00 suse-pc kernel: [ 9976.558040] sd 0:0:0:0: [sda]      2014-03-01T02:13:26.948316+02:00 suse-pc kernel: [ 9976.558044] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE    2014-03-01T02:13:26.948317+02:00 suse-pc kernel: [ 9976.558048] sd 0:0:0:0: [sda]      2014-03-01T02:13:26.948318+02:00 suse-pc kernel: [ 9976.558052] Sense Key : Medium Error [current] [descriptor]    2014-03-01T02:13:26.948320+02:00 suse-pc kernel: [ 9976.558059] Descriptor sense data with sense descriptors (in hex):    2014-03-01T02:13:26.948321+02:00 suse-pc kernel: [ 9976.558062]         72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00    2014-03-01T02:13:26.948321+02:00 suse-pc kernel: [ 9976.558081]         39 75 8d 51    2014-03-01T02:13:26.948335+02:00 suse-pc kernel: [ 9976.558090] sd 0:0:0:0: [sda]      2014-03-01T02:13:26.948338+02:00 suse-pc kernel: [ 9976.558095] Add. Sense: Unrecovered read error - auto reallocate failed    2014-03-01T02:13:26.948339+02:00 suse-pc kernel: [ 9976.558099] sd 0:0:0:0: [sda] CDB:    2014-03-01T02:13:26.948340+02:00 suse-pc kernel: [ 9976.558102] Read(10): 28 00 39 75 8d 50 00 00 08 00    2014-03-01T02:13:26.948341+02:00 suse-pc kernel: [ 9976.558119] end_request: I/O error, dev sda, sector 964005201    2014-03-01T02:13:26.948342+02:00 suse-pc kernel: [ 9976.558207] ata1: EH complete        Any ideas ?     How can I fix it ?    Regards,  George 

--
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/33d3ed3a-fd7a-49a4-a897-b0a80ee7c77e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Bus Error on Development Server

Hello,

I was trying to process Images with some python scripts, when I receive bus error. After that I had many bus errors on different programs.
Finally I tried to start django' development server, and I received the same error.
I know that this error happens when a process is trying to access memory  that the CPU cannot physically address.    I checked my log files and the output of the error is the following:

T02:13:26.879355+02:00 suse-pc kernel: [ 9976.488797] ata1.00: exception Emask 0x0 SAct 0x1 SErr 0x0 action 0x0  
2014-03-01T02:13:26.879402+02:00 suse-pc kernel: [ 9976.488806] ata1.00: irq_stat 0x40000008
2014-03-01T02:13:26.879413+02:00 suse-pc kernel: [ 9976.488813] ata1.00: failed command: READ FPDMA QUEUED
2014-03-01T02:13:26.879419+02:00 suse-pc kernel: [ 9976.488826] ata1.00: cmd 60/08:00:50:8d:75/00:00:39:00:00/40 tag 0 ncq 4096 in
2014-03-01T02:13:26.879428+02:00 suse-pc kernel: [ 9976.488826]          res 41/40:08:51:8d:75/00:00:39:00:00/00 Emask 0x409 (media error) <F>
2014-03-01T02:13:26.879434+02:00 suse-pc kernel: [ 9976.488832] ata1.00: status: { DRDY ERR }
2014-03-01T02:13:26.879437+02:00 suse-pc kernel: [ 9976.488836] ata1.00: error: { UNC }
2014-03-01T02:13:26.948294+02:00 suse-pc kernel: [ 9976.557999] ata1.00: configured for UDMA/133
2014-03-01T02:13:26.948313+02:00 suse-pc kernel: [ 9976.558034] sd 0:0:0:0: [sda] Unhandled sense code
2014-03-01T02:13:26.948315+02:00 suse-pc kernel: [ 9976.558040] sd 0:0:0:0: [sda]  
2014-03-01T02:13:26.948316+02:00 suse-pc kernel: [ 9976.558044] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
2014-03-01T02:13:26.948317+02:00 suse-pc kernel: [ 9976.558048] sd 0:0:0:0: [sda]  
2014-03-01T02:13:26.948318+02:00 suse-pc kernel: [ 9976.558052] Sense Key : Medium Error [current] [descriptor]
2014-03-01T02:13:26.948320+02:00 suse-pc kernel: [ 9976.558059] Descriptor sense data with sense descriptors (in hex):
2014-03-01T02:13:26.948321+02:00 suse-pc kernel: [ 9976.558062]         72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00
2014-03-01T02:13:26.948321+02:00 suse-pc kernel: [ 9976.558081]         39 75 8d 51
2014-03-01T02:13:26.948335+02:00 suse-pc kernel: [ 9976.558090] sd 0:0:0:0: [sda]  
2014-03-01T02:13:26.948338+02:00 suse-pc kernel: [ 9976.558095] Add. Sense: Unrecovered read error - auto reallocate failed
2014-03-01T02:13:26.948339+02:00 suse-pc kernel: [ 9976.558099] sd 0:0:0:0: [sda] CDB:
2014-03-01T02:13:26.948340+02:00 suse-pc kernel: [ 9976.558102] Read(10): 28 00 39 75 8d 50 00 00 08 00
2014-03-01T02:13:26.948341+02:00 suse-pc kernel: [ 9976.558119] end_request: I/O error, dev sda, sector 964005201
2014-03-01T02:13:26.948342+02:00 suse-pc kernel: [ 9976.558207] ata1: EH complete
Any ideas ? How can I fix it ? Regards, George

--
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/33d3ed3a-fd7a-49a4-a897-b0a80ee7c77e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: django-php - yeah, it happened.

The post was actually meant to be humorous, albeit dry :)

But if it makes you any happier, I'd have been just as sad if it was django-java, django-rails, django-ruby or django-insert-whatever-language-you-want-here. On a serious thought, my opposition isn't against PHP, despite my disliking for it, it's the principle in general. 

Cal


On Fri, Feb 28, 2014 at 6:49 PM, Rafał Pitoń <rafio.xudb@gmail.com> wrote:
Really? You bring up three years old toy project that didn't went anywhere and mock somebody's work because PHP's involved? Thats bad form OP.

--
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/51c7ea33-216f-438a-9ec1-1a0acb7e831a%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+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/CAHKQagHCU%2BnTu72PA0neTmXucHOhpE_tqU4cj1k%2B7Sx-mvFQ_A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: django-php - yeah, it happened.

On Feb 28, 2014, at 1:51 PM, Rafał Pitoń <rafio.xudb@gmail.com> wrote:

You should give Jinja and projects like django-jinja a look then. They are exactly what you want: Twig like template system for Django.

Thanks, but that's not the piece I need. I'm happy with Django's templates and I want to use them in JavaScript like Twig allows. Unfortunately Twig is just different enough to Not Work out of the box.

Swig might get us there (http://paularmstrong.github.io/swig/), but I haven't looked into it enough.

-scott

Re: django-php - yeah, it happened.

On Friday, February 28, 2014 4:16:58 PM UTC+1, Scott Anderson wrote:
Well, things like Twig are based on Django templates. We're currently migrating from PHP to Django, and if something like Django-PHP made that easier I would most definitely use it.

To be honest I wish there were a Twig-like solution for Django. We're going to try adding the missing tags to the Django template system to match what we're using in Twig.

-scott

You should give Jinja and projects like django-jinja a look then. They are exactly what you want: Twig like template system for Django.

--
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/ca1fec71-ebaf-43f1-9908-5023f86769d6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: django-php - yeah, it happened.

Really? You bring up three years old toy project that didn't went anywhere and mock somebody's work because PHP's involved? Thats bad form OP.

--
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/51c7ea33-216f-438a-9ec1-1a0acb7e831a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Accessing a python function from a blog post stored in the db?

Broadly speaking, yes. The details may get hairy, but those are probably better dealt with in issue specific threads.

Good luck, and don't hesitate to bring up any other questions.

~CK

On Thursday, February 27, 2014 5:29:34 PM UTC-6, Dennis Marwood wrote:
OK I think you are talking about something like https://docs.djangoproject.com/en/dev/intro/tutorial02/#adding-related-objects where I could just insert a slider type of entry and then a text entry and so on. Is that it?

On Wednesday, 26 February 2014 14:49:55 UTC-8, C. Kirby wrote:
It doesn't have to, I guess it depends on how involved the creation tools are that you create. Quick and dirty idea off the top of my head:
If the authoring tools define post widgets (body, text, scroller, video, etc) you could let authors drag and drop the elements as they wish. On the model side, make all resources extend a base class of BlogResource type, then for each blog post have a many to many through table that stores ordering:
PostID(foriegn=blog)
ResourceID(genericforeignkey to blog resource)
OrderID(int)

or somthing like that.

Regards,
~CK

On Wednesday, February 26, 2014 4:18:14 PM UTC-6, Dennis Marwood wrote:
Won't this force my blog posts to all be the same. i.e. Text then a image scroller?
How would I handle the case where a blog post was Text, image scroller, text, image scroller?

On Wednesday, 26 February 2014 13:35:01 UTC-8, C. Kirby wrote:
It sounds like your implementation is a little skewed.
If a blog post is made of multiple resources (summary, body, multiple image collections, etc.) You should probably have a model or models with the appropriate fields/relationships.  That way your template can house all of the template language, and you build a single, user facing blog post from the elements in the blog post model(s).
This also gives you the benefit of making the various resources available in other ways (eg. Show all my image collections, share collections, etc) as well as change your layout in the future without having hard-coded template calls in your content.

Regards
~CK

On Wednesday, February 26, 2014 3:18:54 PM UTC-6, Dennis Marwood wrote:
Thanks. I look forward to trying this soon.

I feel like I may be trying to swim against the current with this. Is this a problem with the way that I have decided to implement my blog or are these workarounds typical for django applications?

On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:
On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood <dennis...@gmail.com> wrote:
> Thanks. I believe this is what I am looking for. However I am still running
> into an issue w/ the fact that I am pulling my blog entries from the db.
> This is causing the template to interpret the {% image_slider %} as a
> string.
>
> From view.py:
> def blog(request):
>     entries =
> Project.objects.filter(destination="blog").order_by('-creation_date')
>     return render(request, 'content.html', {"entries": entries,
>                                                "page_title": "Blog",
>                                                "description": "Blog"})
>
> And in content.html:
> {% for each in entries %}
> <p>{{ each.entry }}</p>
> {% endfor %}
>
> And a blog entry:
> Hello! Check out this collection of images. {% image_slider %} And this
> collection! {% image_slider %}
>
>
> I don't want to hard code the inclusion tag in the content.html. Instead I
> want to call it from the blog post. Is this possible?

Yes. You will need to write a custom template tag to parse the
contents of the object as a template, render it within the current
context and return the generated data.

Writing a custom template tag:

https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags

Rendering templates to string:

https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context

Your content.html would then look something like this, assuming you
called the custom tag 'render':

{% for each in entries %}
<p>{% render each.entry %}</p>
{% endfor %}

Beware the massive security holes if you allow users to generate
content that your site then renders as a template.

Cheers

Tom

--
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/ac308365-e0b8-4a88-be8b-9e691229c31a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Template/Form Errors and DynaTree.js

Hi Timothy,

What you could do is create a function that gets the id of the form. It can then query the action of the form and the parameters of the form. It would look something like this:

function submitForm(form_id) {
var $form = $("#" + form_id);

$.ajax({
type: 'POST',
url: $form.attr('action'),
dataType: 'html', data: $form.serialize(), success: function(data){ $("#old_div_content").html(data); }, error: function(xhr, textStatus, errorThrown) {         console.log('AJAX communication failed:', textStatus, errorThrown); } });
}

This way it is pretty generic as long as the "old_div_content" div id stays the same.

Regards,

Andréas



Med vänliga hälsningar,

Andréas Kühne
Software Development Manager
Suitopia Scandinavia AB


2014-02-28 15:48 GMT+01:00 Timothy W. Cook <tim@mlhim.org>:

On Thu, Feb 27, 2014 at 10:18 AM, Andreas Kuhne <andreas.kuhne@suitopia.com> wrote:
Hi again Timothy,

Actually it's much easier than you think.


Great news!  :-)
 

The error you showed is a validation error, is it not?


Yes.


In the example that you gave (below) it seems that I will need an AJAX function for each different form.  Correct? 
IOW:
There are 25 different forms/views/models that can be selected, one at a time, for create or update in this div.  So, do I understand correctly that I need a function with the correct URL and data map for each one of those?  If so, what is the approach to calling the one the user has selected?  My urks are named, for example: dvtemporal_create and dvtemporal_update.  Of course the _update has the record id as well.  

There is a lot of information in the Django request so I want to be able to reuse this with an 'abstract as possible' ajax function. 

Thoughts? 

--Tim 

 
What you do is that you submit the form via jquery ajax, something like this should work:

  $.ajax({ type: 'POST', url: the_form_url, dataType: 'html', data: { email : $('#id_email').val(), name : $('#id_name').val(), phone : $('#id_phone').val() }, success: function(data){ $("#old_div_content").html(data); }, error: function(xhr, textStatus, errorThrown) {         console.log('AJAX communication failed:', textStatus, errorThrown); } });

Now you will have to change the function so that the parameters sent to your view are correct (in the data map), the url is correct and the success method changes the correct div. You won't have to do any error handling in jquery at all, because the validation is on the server. When you replace the html in the div that you want to replace, the user will just get the validation errors that django creates for you.

You really don't have to change anything in the view that you are using at the moment, because it already returns the information that you want in the div, all you have to do is get in into the div :-)

Regards,

Andréas


2014-02-27 14:06 GMT+01:00 Timothy W. Cook <tim@mlhim.org>:
Hi Andreas,

Thanks for the reply.


On Thu, Feb 27, 2014 at 9:42 AM, Andreas Kuhne <andreas.kuhne@suitopia.com> wrote:
Hi Timothy,

What you probably have to do is submit the form in a ajax call via jquery for example. https://api.jquery.com/jQuery.ajax/

You create a request via the ajax method in jquery and then add a success and error handler. They only have to update the div you want to replace: $("#div_id").html(response).



This certainly seems like a reasonable approach.  The points I am unsure of is:

1)  how do I catch the template error in jQuery?

2) I suppose that I have to (somehow) catch the error in the ModelForm? 

3) then send that request to jQuery, somehow?  

My forms and views are pretty simple at this point.  Here are examples:

class DvCodedStringCreateView(CreateView):
    template_name = 'dvcodedstring_create.html'
    success_url = '/dashboard'
    model = DvCodedString
    form_class = DvCodedStringCreateForm
    fields = ['published','prj_name','data_name','lang','description','sem_attr','resource_uri','asserts',
                'terminology','term_subset','codes','t_code','t_string','t_name','t_abbrev','t_version',
                'min_length','max_length','exact_length','enums','enums_annotations','default_value',]




class DvCodedStringCreateForm(forms.ModelForm):
    class Meta:
        model = DvCodedString
        widgets = {
                    'data_name': TextInput(attrs={'size':90}),
                    'description': Textarea(attrs={'cols':80, 'rows':5,'wrap':'off'}),
                    'sem_attr': Textarea(attrs={'cols':15, 'rows':3,'wrap':'off'}),
                    'resource_uri': Textarea(attrs={'cols':60, 'rows':3,'wrap':'off'}),
                    'asserts': Textarea(attrs={'cols':80, 'rows':2,'wrap':'off'}),
                    'enums': Textarea(attrs={'cols':30, 'rows':5,'wrap':'off'}),
                    'enums_annotations': Textarea(attrs={'cols':50, 'rows':5,'wrap':'off'}),
                    't_code': Textarea(attrs={'cols':15, 'rows':5,'wrap':'off'}),
                    't_string': Textarea(attrs={'cols':30, 'rows':5,'wrap':'off'}),
                    't_abbrev': Textarea(attrs={'cols':10, 'rows':5,'wrap':'off'}),
                    't_version': Textarea(attrs={'cols':10, 'rows':5,'wrap':'off'}),
                    't_name': Textarea(attrs={'cols':40, 'rows':5,'wrap':'off'}),

                   }



Thanks in advance for any further guidance.  

--Tim


 
2014-02-27 12:38 GMT+01:00 Timothy W. Cook <tim@mlhim.org>:
I have no idea where to start on this problem. 
My application is work great using the admin UI but to enhance usability it is time for a new user interface.  

I am using dynatree.js to create a 'Project' tree with subelements (called PcTs) grouped into types;  IOW:  There are three levels before you get to an editable component.  Hence the reason to use a tree instead of paging through the admin UI.  

So my  UI (Selection_001.png)  uses <div> tags to layout the spaces.  Basically tree on the left and a larger editing space next to it.  My forms a re properly placed inside the scrollable <div>.  My problem is when I get an error in the form, how do I control it so that it is only displayed in the same <div> where the form was displayed?  What I get now is a full page reload. See Selection_002.png

The template does not use any extend or include directives.  It is a completely self contained HTML file.
There are forms and views for each of the PcTs. 


Any ideas on where to start working on this?  





--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 994711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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/CA%2B%3DOU3UZppis4c8rr_Ok9rQ_SO6uXK6iii8HG7cPHE9qq1CWLw%40mail.gmail.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+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/CALXYUbno2-CvWgs%2BZjTWO7zU0C3YkvnzLCs3S0stiPGvDvBPBA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 994711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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/CA%2B%3DOU3Uky1-JSEsW8towv4gQz9hFH_c5dx1w6HaCdRA%2B9ZKshA%40mail.gmail.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+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/CALXYUbmK74Nk57X6gkMOWRxscsWbv6REo0g%3Dqu1k1mdZMuqMRg%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 994711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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/CA%2B%3DOU3UD64_vHr8Cm7qHipLULX2qZv2Ego%3D-HuZHCWFyo9Redg%40mail.gmail.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+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/CALXYUbk5VBeRdxygicuqQmMatKAQ2eC4KVjbEbwS-OUe2M9RSA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: django-php - yeah, it happened.

Well, things like Twig are based on Django templates. We're currently migrating from PHP to Django, and if something like Django-PHP made that easier I would most definitely use it.

To be honest I wish there were a Twig-like solution for Django. We're going to try adding the missing tags to the Django template system to match what we're using in Twig.

-scott


On Thursday, February 27, 2014 6:30:49 PM UTC-5, Cal Leeming [Simplicity Media Ltd] wrote:
Clearly this should be considered for merge into the core;

The really sad part: someone somewhere *will* use this in production, and be totally srs about it.

Excuse me whilst I cry myself to sleep.

Cal

--
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/766ce944-4af5-41e0-9b68-c9175c9d1aff%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Using Django without templates?

On Thursday, February 27, 2014 8:37:45 PM UTC-6, somecallitblues wrote:

You do have to be careful with templates if you're using too many inclusions or if you have too much logic in them. There's a good django debug toolbar add-on that informs you about the time a template takes to compile.


I'm currently having performance problems with templates that have many small django forms in them.  Plan to try something like Angular.js instead of django templates and see if it's better.

The reference to "full stack" ~might~ have meant something like Meteor, a framework that uses javascript on both server and client.

--
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/3dbe90fd-e04c-49f9-ac86-2fb2e80caf1e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Template/Form Errors and DynaTree.js


On Thu, Feb 27, 2014 at 10:18 AM, Andreas Kuhne <andreas.kuhne@suitopia.com> wrote:
Hi again Timothy,

Actually it's much easier than you think.


Great news!  :-)
 

The error you showed is a validation error, is it not?


Yes.


In the example that you gave (below) it seems that I will need an AJAX function for each different form.  Correct? 
IOW:
There are 25 different forms/views/models that can be selected, one at a time, for create or update in this div.  So, do I understand correctly that I need a function with the correct URL and data map for each one of those?  If so, what is the approach to calling the one the user has selected?  My urks are named, for example: dvtemporal_create and dvtemporal_update.  Of course the _update has the record id as well.  

There is a lot of information in the Django request so I want to be able to reuse this with an 'abstract as possible' ajax function. 

Thoughts? 

--Tim 

 
What you do is that you submit the form via jquery ajax, something like this should work:

  $.ajax({ type: 'POST', url: the_form_url, dataType: 'html', data: { email : $('#id_email').val(), name : $('#id_name').val(), phone : $('#id_phone').val() }, success: function(data){ $("#old_div_content").html(data); }, error: function(xhr, textStatus, errorThrown) {         console.log('AJAX communication failed:', textStatus, errorThrown); } });

Now you will have to change the function so that the parameters sent to your view are correct (in the data map), the url is correct and the success method changes the correct div. You won't have to do any error handling in jquery at all, because the validation is on the server. When you replace the html in the div that you want to replace, the user will just get the validation errors that django creates for you.

You really don't have to change anything in the view that you are using at the moment, because it already returns the information that you want in the div, all you have to do is get in into the div :-)

Regards,

Andréas


2014-02-27 14:06 GMT+01:00 Timothy W. Cook <tim@mlhim.org>:
Hi Andreas,

Thanks for the reply.


On Thu, Feb 27, 2014 at 9:42 AM, Andreas Kuhne <andreas.kuhne@suitopia.com> wrote:
Hi Timothy,

What you probably have to do is submit the form in a ajax call via jquery for example. https://api.jquery.com/jQuery.ajax/

You create a request via the ajax method in jquery and then add a success and error handler. They only have to update the div you want to replace: $("#div_id").html(response).



This certainly seems like a reasonable approach.  The points I am unsure of is:

1)  how do I catch the template error in jQuery?

2) I suppose that I have to (somehow) catch the error in the ModelForm? 

3) then send that request to jQuery, somehow?  

My forms and views are pretty simple at this point.  Here are examples:

class DvCodedStringCreateView(CreateView):
    template_name = 'dvcodedstring_create.html'
    success_url = '/dashboard'
    model = DvCodedString
    form_class = DvCodedStringCreateForm
    fields = ['published','prj_name','data_name','lang','description','sem_attr','resource_uri','asserts',
                'terminology','term_subset','codes','t_code','t_string','t_name','t_abbrev','t_version',
                'min_length','max_length','exact_length','enums','enums_annotations','default_value',]




class DvCodedStringCreateForm(forms.ModelForm):
    class Meta:
        model = DvCodedString
        widgets = {
                    'data_name': TextInput(attrs={'size':90}),
                    'description': Textarea(attrs={'cols':80, 'rows':5,'wrap':'off'}),
                    'sem_attr': Textarea(attrs={'cols':15, 'rows':3,'wrap':'off'}),
                    'resource_uri': Textarea(attrs={'cols':60, 'rows':3,'wrap':'off'}),
                    'asserts': Textarea(attrs={'cols':80, 'rows':2,'wrap':'off'}),
                    'enums': Textarea(attrs={'cols':30, 'rows':5,'wrap':'off'}),
                    'enums_annotations': Textarea(attrs={'cols':50, 'rows':5,'wrap':'off'}),
                    't_code': Textarea(attrs={'cols':15, 'rows':5,'wrap':'off'}),
                    't_string': Textarea(attrs={'cols':30, 'rows':5,'wrap':'off'}),
                    't_abbrev': Textarea(attrs={'cols':10, 'rows':5,'wrap':'off'}),
                    't_version': Textarea(attrs={'cols':10, 'rows':5,'wrap':'off'}),
                    't_name': Textarea(attrs={'cols':40, 'rows':5,'wrap':'off'}),

                   }



Thanks in advance for any further guidance.  

--Tim


 
2014-02-27 12:38 GMT+01:00 Timothy W. Cook <tim@mlhim.org>:
I have no idea where to start on this problem. 
My application is work great using the admin UI but to enhance usability it is time for a new user interface.  

I am using dynatree.js to create a 'Project' tree with subelements (called PcTs) grouped into types;  IOW:  There are three levels before you get to an editable component.  Hence the reason to use a tree instead of paging through the admin UI.  

So my  UI (Selection_001.png)  uses <div> tags to layout the spaces.  Basically tree on the left and a larger editing space next to it.  My forms a re properly placed inside the scrollable <div>.  My problem is when I get an error in the form, how do I control it so that it is only displayed in the same <div> where the form was displayed?  What I get now is a full page reload. See Selection_002.png

The template does not use any extend or include directives.  It is a completely self contained HTML file.
There are forms and views for each of the PcTs. 


Any ideas on where to start working on this?  





--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 994711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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/CA%2B%3DOU3UZppis4c8rr_Ok9rQ_SO6uXK6iii8HG7cPHE9qq1CWLw%40mail.gmail.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+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/CALXYUbno2-CvWgs%2BZjTWO7zU0C3YkvnzLCs3S0stiPGvDvBPBA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 994711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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/CA%2B%3DOU3Uky1-JSEsW8towv4gQz9hFH_c5dx1w6HaCdRA%2B9ZKshA%40mail.gmail.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+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/CALXYUbmK74Nk57X6gkMOWRxscsWbv6REo0g%3Dqu1k1mdZMuqMRg%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 994711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

--
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/CA%2B%3DOU3UD64_vHr8Cm7qHipLULX2qZv2Ego%3D-HuZHCWFyo9Redg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: django-php - yeah, it happened.

WTF lol @Cal, you made my morning! 

--
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/CAD1DFf0ZYogXwde0HzFkz6e1QvhhvniY4ywUHw_L__gtkz2Qtw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: django-php - yeah, it happened.

:D


2014-02-28 0:30 GMT+01:00 Cal Leeming [Simplicity Media Ltd] <cal.leeming@simplicitymedialtd.co.uk>:
Clearly this should be considered for merge into the core;

The really sad part: someone somewhere *will* use this in production, and be totally srs about it.

Excuse me whilst I cry myself to sleep.

Cal

--
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/CAHKQagH-dFwiwSePpKoSGzUKR71CF92s8g%3DfVRpiiBS-2w1vdA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--
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/CAF4ENO0OLEZbbA30%3DRXQweq0AErsJMq8kTFrovG5TKQxWY41QQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thursday, February 27, 2014

Re: Using Django without templates?

You do have to be careful with templates if you're using too many inclusions or if you have too much logic in them. There's a good django debug toolbar add-on that informs you about the time a template takes to compile.

On 27/02/2014 9:47 am, "ApathyBear" <nirchernia@gmail.com> wrote:
I was briefly talking with a developer from Google whom I had met. 

He mentioned something that I hadn't really gotten a chance to ask him more about

He told me to be careful with django templates because in terms of scale, they can cause problems and almost always need to be re-written. Rather he mentioned something like using a 'full stack'.

I think back, and I don't exactly follow what he means by that. Is their a way to use Django without templates? Is it better ? Why or why not?

--
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/2aa3d77a-da31-460e-b472-204e2548b69a%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+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/CAHqTbjn1AXCykZT9ggtvj4Z7%2BcEsR_CqpA2TC9wXKDURaR3wUw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Javascript and sessions

On Wednesday, February 26, 2014 10:41:38 PM UTC-4:30, Luke Baker wrote:
My web application is heavily based around form input. I'd like to update the user's session with each form input that they update or change while working with a form. I'm thinking of implementing some simple javascript that listens for 'change' events on each form input. When the 'change' event fires, I'd like to make an ajax request to update the users session with that form input name and value. To do this, I would have to write a view that would allow the user to POST any thing they wanted (essentially) to their session - is this safe? It makes me think twice.

Yes you must write that view. Sanitize the inputs.

--
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/187995d9-0a47-4e00-9b93-f17490d7ba96%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Using Django without templates?

On Wednesday, February 26, 2014 6:16:39 PM UTC-4:30, ApathyBear wrote:
He mentioned something that I hadn't really gotten a chance to ask him more about
He told me to be careful with django templates because in terms of scale, they can cause problems and almost always need to be re-written. Rather he mentioned something like using a 'full stack'.
I think back, and I don't exactly follow what he means by that. Is their a way to use Django without templates? Is it better ? Why or why not?
Hello,

A web application is based on the HTTP protocol, that is text based. The purpose of the protocol is that a web browser request a document, and the server responds with a document text (may be other kind of content types, like images). Django manages this protocol through the use of views and url configurations: each url is managed by a view. The view responsibility is to deliver a (text) document, and do so via a django.http.response.HttpResponse object. So you only need to return, in your views, HttpResponse objects.

You can simply return in every view something like this:
return HttpResponse('hello world')

and it will work, without using templates. This is faster than loading a template with the text 'hello world', render and pass it to the view.

You can do that to return complex HTML (or other types of) documents of your site. Or you can use a template system and manage the HTML more easily with a bit more processing overhead. You can use other template systems besides the provided by Django, like Jinja (that has shown to be faster in some benchmarks compared to Django's).

Regards,
Camilo

--
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/4f03f506-202a-4fce-92d4-e3dceb832ffa%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Django with rabbit (but without async celery) - can be done?


On Tuesday, February 25, 2014 10:58:47 AM UTC-4:30, Alon Nisser wrote:
I need to implement a quite simple Django server that server some http requests and listens to a rabbitmq message queue that streams information into the Django app (that should be written to the db). the data must be written to the db in a synchronized order , So I can't use the obvious celery/rabbit configuration.  I was told that there is no way to do this in the same Django project. since Django would listen to http requests on It's process. and It can't handle another process to listen for Rabbit - forcing me to to add Another python/django project for the rabbit/db writes part - working with the same models The http bound django project works with.. You can smell the trouble with this config from here. .. Any Ideas how to solve this?
Hello,

What you has been told seems to be the right way of solving this. You should have another python (not Django) application listening to the queue to process incoming messages. You can use Django models to insert the data into the database. That queue does not really streams data to _the application_ but to _the database_ via a third running application. I don't have any smell here, only curious of what 'written to the db in a _synchronized order_' means ;)

If you are going to receive a stream of data, split in messages in a queue, then I assume you may need to store the data in the DB in an ordered fashion, in a way that can then easily be retrieved in the right order or sequence to play or use the data. That is a different problem with many solutions with the tools you have, and has nothing to do with Django, but programming in general :) You can have an order field in your models. You can cache the data in your queue listener application and write to the DB only portions that make sense according to order and keep the data that is out of order in memory until it can be written.

Regards,
Camilo

--
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/3f50643c-fc7a-45f6-9ef8-a51ad74c3452%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: View function and URL Conf basic question

On Wednesday, February 26, 2014 9:24:51 AM UTC-4:30, Daniel Roseman wrote:
On Wednesday, 26 February 2014 08:10:40 UTC, ApathyBear wrote:
Here is my urls.py:
from django.conf.urls.defaults import *  from mysite.views import hello, current_datetime, hours_ahead    urlpatterns = patterns('',      url(r'^hello/$', hello),      url(r'^time/$', current_datetime),      url(r'^time/plus/(\d{1,2})/$', hours_ahead),  )
And here is my View function associated with hours_ahead
from django.http import Http404, HttpResponse  import datetime    def hours_ahead(request, offset):      try:          offset = int(offset)      except ValueError:          raise Http404()      dt = datetime.datetime.now() + datetime.timedelta(hours=offset)      html = "<html><body>In %s hour(s), it will be %s.</body></html>" % (offset, dt)      return HttpResponse(html)
Now what is throwing me off is how 'offset' is a second argument to  the hours_ahead function. Yet I am not quite sure how it being the second argument makes it the case that it is associated with whatever is entered as a URL. Let me use an example to illustrate my confusion.

Say I request the URL:  http://127.0.0.1:8000/time/plus/2/ . Why is it the case that offset is '2'? I am not seeing why '2' is plucked out? What happened with 'time' and 'plus'? How does python/django know that the '2' is referring to offset?
That is what the regular expression does in your first snippet. `time` and `plus` are just matched, but not captured: the only thing that is captured is `(\d{1,2})`, because it is surrounded in parentheses.

If that's not clear for you, you should read a guide to regexes: http://regular-expressions.info  is a good one.
Hello,

As Daniel points out, this is related to regular expressions. You can read a full explanation here:
https://docs.djangoproject.com/en/1.6/topics/http/urls/#how-django-processes-a-request

You sholud also take a look at the 're' Python module. 

Regards,
Camilo.

--
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/e7e7aace-49f6-47e4-8094-8c492c0987d4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

django-php - yeah, it happened.

Clearly this should be considered for merge into the core;

The really sad part: someone somewhere *will* use this in production, and be totally srs about it.

Excuse me whilst I cry myself to sleep.

Cal

--
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/CAHKQagH-dFwiwSePpKoSGzUKR71CF92s8g%3DfVRpiiBS-2w1vdA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Accessing a python function from a blog post stored in the db?

OK I think you are talking about something like https://docs.djangoproject.com/en/dev/intro/tutorial02/#adding-related-objects where I could just insert a slider type of entry and then a text entry and so on. Is that it?

On Wednesday, 26 February 2014 14:49:55 UTC-8, C. Kirby wrote:
It doesn't have to, I guess it depends on how involved the creation tools are that you create. Quick and dirty idea off the top of my head:
If the authoring tools define post widgets (body, text, scroller, video, etc) you could let authors drag and drop the elements as they wish. On the model side, make all resources extend a base class of BlogResource type, then for each blog post have a many to many through table that stores ordering:
PostID(foriegn=blog)
ResourceID(genericforeignkey to blog resource)
OrderID(int)

or somthing like that.

Regards,
~CK

On Wednesday, February 26, 2014 4:18:14 PM UTC-6, Dennis Marwood wrote:
Won't this force my blog posts to all be the same. i.e. Text then a image scroller?
How would I handle the case where a blog post was Text, image scroller, text, image scroller?

On Wednesday, 26 February 2014 13:35:01 UTC-8, C. Kirby wrote:
It sounds like your implementation is a little skewed.
If a blog post is made of multiple resources (summary, body, multiple image collections, etc.) You should probably have a model or models with the appropriate fields/relationships.  That way your template can house all of the template language, and you build a single, user facing blog post from the elements in the blog post model(s).
This also gives you the benefit of making the various resources available in other ways (eg. Show all my image collections, share collections, etc) as well as change your layout in the future without having hard-coded template calls in your content.

Regards
~CK

On Wednesday, February 26, 2014 3:18:54 PM UTC-6, Dennis Marwood wrote:
Thanks. I look forward to trying this soon.

I feel like I may be trying to swim against the current with this. Is this a problem with the way that I have decided to implement my blog or are these workarounds typical for django applications?

On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:
On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood <dennis...@gmail.com> wrote:
> Thanks. I believe this is what I am looking for. However I am still running
> into an issue w/ the fact that I am pulling my blog entries from the db.
> This is causing the template to interpret the {% image_slider %} as a
> string.
>
> From view.py:
> def blog(request):
>     entries =
> Project.objects.filter(destination="blog").order_by('-creation_date')
>     return render(request, 'content.html', {"entries": entries,
>                                                "page_title": "Blog",
>                                                "description": "Blog"})
>
> And in content.html:
> {% for each in entries %}
> <p>{{ each.entry }}</p>
> {% endfor %}
>
> And a blog entry:
> Hello! Check out this collection of images. {% image_slider %} And this
> collection! {% image_slider %}
>
>
> I don't want to hard code the inclusion tag in the content.html. Instead I
> want to call it from the blog post. Is this possible?

Yes. You will need to write a custom template tag to parse the
contents of the object as a template, render it within the current
context and return the generated data.

Writing a custom template tag:

https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags

Rendering templates to string:

https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context

Your content.html would then look something like this, assuming you
called the custom tag 'render':

{% for each in entries %}
<p>{% render each.entry %}</p>
{% endfor %}

Beware the massive security holes if you allow users to generate
content that your site then renders as a template.

Cheers

Tom

--
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/c2f6e17b-08eb-4aa5-8cb5-bee4169016ea%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.