Re: django dynamic template tag

2013-07-13 Thread Andriyko



Try {{ pagecontent.plugin }} instead of {% pagecontent.plugin %}



On Wednesday, July 3, 2013 3:11:08 AM UTC+3, Fadi Samara wrote:
>
> I try to build a plugins based application, I have created tags and 
> registered them for each plugin.
>
> I have a table stores each page plugins, and need to render any stored 
> plugin in the template accordingly as inclusion tag.
>
> Now for the template i use this:
>
> {% block slider_region %}{% for pagecontent in pagecontents %}
> {% pagecontent.plugin %}{% endfor %}{% endblock %}
>
> But this returns:
>
> Invalid block tag: 'pagecontent.plugin', expected 'empty' or 'endfor'
>
> My question, how can I pass the plugin as a tag from view query to a 
> template and be rendered as inclusion tag.
>

-- 
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.




form in admin to allow upload file from local machine OR upload file from local filesystem OR upload file from url - as result one filed in model that contains file path

2013-04-11 Thread Andriyko
Hello,

I need a way(form in admin) to allow user to select how he will upload a 
file:
-- from local(his) machine
-- from filesystem(where django is running)
-- from external url

Does not matter what way user selects, I want to read that file and write 
to custom location(path).
The model itself should contain only path to file (FileField?), but form 
that represents the model in admin webui should provide different ui 
controls(mentioned above) to upload the file.
How can I achieve this? Is there some kind of form wizard in admin?
If I use form wizard when adding entry, how can I edit that entry later?
How to check whether the file on the path has been changed or not?

I use django 1.5.1.

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to use jquery onclick event and django inclusion_tag/assignment_tag?

2012-12-20 Thread Andriyko
Thank you for the quick and clean answer. It is one more entry in my todo 
list - Ajax! 

On Wednesday, December 19, 2012 9:00:39 PM UTC+2, ke1g wrote:
>
>
>
> On Wed, Dec 19, 2012 at 1:34 PM, Andriyko 
> > wrote:
>
>> Hello dear Django Users!
>>
>> I'm trying to use django inclusion_tag or/and assignment_tag with jquery 
>> 'onclick' event.
>> Encountered such problems:
>> 1. When using inclusion_tag/assignment_tag the content returned by them 
>> is rendered on page load, not onclick.
>> And I suspect that it is correct behavior, once the tag is met it is 
>> rendered by template render. So, I think that should be some way to skip 
>> django tags? How?
>>
>> 2. With inclusion_tag the result returned by tag is shown in the place 
>> where it was called, not where it is 'intended' to be.
>> And again, I think it is correct. But how to use inclusion_tag really 
>> onclick event?
>> For example,
>> ---
>> 
>> $(function() {
>> var result = $("#select-result").empty();
>> $('#myid').somecontainer({animate:true,
>> onClick: function(node){
>>result.html('{% my_inclusion_tag "param1" "param2" 
>> %}');
>> }
>> });
>> });
>> 
>> ---
>> As the result(in source of loaded page) I have content returned by 
>> inclusion_tag inside , not under  #select-result div.
>> Like 
>> ...
>> onClick: function(node){
>>result.html(lalalala);
>>  }
>> ...
>>
>> The code that works as expected :), onclick not onload.
>>
>> 
>> $(function() {
>> var result = $("#select-result").empty();
>> $('#myid').somecontainer({animate:true,
>> onClick: function(node){
>>alert(node.text);
>> }
>> });
>> });
>> 
>>
>>
>> The tags are just a feature of the template language.  Their purpose is 
> to render the response that django will send to the browser.  There is no 
> automatic coupling to actions in the browser.  As you note, by the time 
> that the initial page load completes, the tags have finished all that they 
> are going to do.
>
> I'm guessing that what you want calls for an AJAX scheme: You arrange for 
> click to produce an AJAX request (there is jquery support), which the 
> browser sends back to a specified (almost certainly different) url (but 
> probably on the same server/django).  Your urlconf must route this to a 
> view that recognizes the AJAX request, and returns data (xml, json, ...) 
> needed to define the content that you want to show, and returns it as a 
> response.  When this arrives back at the browser, a JavaScript function 
> that you have designated as the AJAX request's success callback is invoked 
> with access to the returned data.  This function must modify the DOM 
> according to the data.
>
> Bill
>
>

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



how to use jquery onclick event and django inclusion_tag/assignment_tag?

2012-12-19 Thread Andriyko
Hello dear Django Users!

I'm trying to use django inclusion_tag or/and assignment_tag with jquery 
'onclick' event.
Encountered such problems:
1. When using inclusion_tag/assignment_tag the content returned by them is 
rendered on page load, not onclick.
And I suspect that it is correct behavior, once the tag is met it is 
rendered by template render. So, I think that should be some way to skip 
django tags? How?

2. With inclusion_tag the result returned by tag is shown in the place 
where it was called, not where it is 'intended' to be.
And again, I think it is correct. But how to use inclusion_tag really 
onclick event?
For example,
---

$(function() {
var result = $("#select-result").empty();
$('#myid').somecontainer({animate:true,
onClick: function(node){
   result.html('{% my_inclusion_tag "param1" "param2" %}');
}
});
});

---
As the result(in source of loaded page) I have content returned by 
inclusion_tag inside , not under  #select-result div.
Like 
...
onClick: function(node){
   result.html(lalalala);
 }
...

The code that works as expected :), onclick not onload.


$(function() {
var result = $("#select-result").empty();
$('#myid').somecontainer({animate:true,
onClick: function(node){
   alert(node.text);
}
});
});


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



Re: how to auto-populate(auto-update) model's field(s) via custom button or on Save

2012-11-26 Thread Andriyko
The problem is not how to fetch, but how to save.

On Monday, November 26, 2012 2:37:31 PM UTC+2, Sergiy Khohlov wrote:
>
> >>> import httplib 
> >>> myhost = httplib.HTTPConnection('www.google.com') 
> >>> myhost.request("GET") 
> >>> googleanswer = myhost.getresponse() 
> >>> print googleanswer.read() 
>  content="text/html;charset=utf-8"> 
> 302 Moved 
> 302 Moved 
> The document has moved 
> http://www.google.com.ua/";>here. 
>  
>
> >>> 
>
>
>  Need more ? 
>
>
> 2012/11/25 Andriyko >: 
> > Hello, 
> > 
> > Please give an advice and some examples on how can I do the following. 
> > 1. I need to fetch some data (list of items) from external url and save 
> that 
> > list into the field of the, say Model1(possible?) 
> > The problem is not how to fetch, but how to save. 
> > 2. This should be done dynamically from admin add/change Model1 page 
> using 
> > custom button or on Save. 
> > 3. Currently I use another Model2 to store that list(ManyToMany). Is it 
> > possible to store that list as field(and show these items on the Model's 
> > page) without Model2 so that I can use items of that list in a template? 
> > 
> > In short, I want to be able to auto-fill some field of the model on Save 
> > or/and with custom button. Possible? 
> > 
> > Thanks 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/ZINp_t_15zAJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

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



how to auto-populate(auto-update) model's field(s) via custom button or on Save

2012-11-24 Thread Andriyko
Hello,

Please give an advice and some examples on how can I do the following.
1. I need to fetch some data (list of items) from external url and save 
that list into the field of the, say Model1(possible?)
The problem is not how to fetch, but how to save.
2. This should be done dynamically from admin add/change Model1 page using 
custom button or on Save.
3. Currently I use another Model2 to store that list(ManyToMany). Is it 
possible to store that list as field(and show these items on the Model's 
page) without Model2 so that I can use items of that list in a template?

In short, I want to be able to auto-fill some field of the model on Save 
or/and with custom button. Possible?

Thanks 


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



how to customize delete confirmation page on deleting related objects

2011-10-29 Thread Andriyko
Hello,

I'm having troubles when deleting related objects.

class Article has:
   related_articles = models.ManyToManyField
   tags = models.ManyToManyField
   

class Attachments has:
  models.ForeignKey(Article


1. I would like to customize delete confirmation page to show(list)
related data.
(when deleting an article - show related articles and attachments etc)
2. I would like to have a possibility to define whether to delete
attachment files also.

Found something about signals and pre_delete, or delete() method of
models.Model 

Thanks in advance!

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



Re: django 1.3: how to use pagination with class based views?

2011-10-17 Thread Andriyko
Ok. page_obj is what I need.

On Oct 17, 10:34 pm, Andriyko  wrote:
> Hello,
>
> I have following view in views.py:
> .
> class  ArticleArchiveIndexView(ArticleViewAbstractClass,
> ArchiveIndexView):
>     queryset = Article.live.all()
>     date_field = 'pub_date'
>     context_object_name = 'articles_list'
>     paginate_by = ARTICLES_PER_PAGE
> ..
>
> How do I use 'paginate_by'?
> Should the Article model have Paginator instance?
> Please provide an example with template.
>
> Thanks

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



django 1.3: how to use pagination with class based views?

2011-10-17 Thread Andriyko
Hello,

I have following view in views.py:
.
class  ArticleArchiveIndexView(ArticleViewAbstractClass,
ArchiveIndexView):
queryset = Article.live.all()
date_field = 'pub_date'
context_object_name = 'articles_list'
paginate_by = ARTICLES_PER_PAGE
..

How do I use 'paginate_by'?
Should the Article model have Paginator instance?
Please provide an example with template.

Thanks

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



Re: django 1.3: how to use get_abolute_url in class based generic views

2011-10-14 Thread Andriyko
Thank you for reply, but I still get the errror
Template error

In template .../weblog/templates/blog/article_archive.html, error at
line 6

Caught ViewDoesNotExist while rendering: Tried archive_day in module
django.views.generic.dates. Error was: 'module' object has no
attribute 'archive_day'
1   {% extends "blog/index.html" %}
2
3   {% block column1 %}
4   Archive
5   
6   {% for article in object_list %}
7   {{ article.title }}

8   Posted by {{ article.author }} on {{ article.pub_date|date:"F
jS,
Y" }}
9   
10  {% endfor %}
11  
12  {% endblock %}
13  {% block column2 %}Last article here{% endblock %}

Could you please give an example about how to use get_absolute_url
with class based generic views?

On Oct 14, 1:31 pm, Fabrizio Mancini  wrote:
> On 13 October 2011 23:57, Andriyko  wrote:
>
> > urlpatterns = patterns('django.views.generic.dates',
> > (r'^(?P\d{4})/v/(?P\d{2})/(?P[-\w]+)/
> > $', DateDetailView.as_view(template_name='blog/article_detail.html',
> > **entry_info_dict)),
> > )
>
> Hi,
> You are using
> (?P\w{3})
> but in get_absolute_url you are using
> self.pub_date.strftime("%m").lower(),
> referring tohttp://docs.python.org/library/time.html#time.strftime
> %m return Month as a decimal number [01,12].
> this won't never work
> You should use %b instead of %m
> This should work
> HTH
> Fabrizio
>
>
>
>
>
>
>
> > = models.py 
>
> > class Article(models.Model):
> >    ..
> >   # with django 1.2 was
> >       @models.permalink
> >    def get_absolute_url(self):
> >        return ('article_detail', (), {  'year':
> > self.pub_date.strftime("%Y"),
> >                                         'month':
> > self.pub_date.strftime("%m").lower(),
> >                                         'day':
> > self.pub_date.strftime("%d"),
> >                                         'slug': self.slug })
> >   # how should it look with django 1.3 ??

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



Re: django 1.3: how to use get_abolute_url in class based generic views

2011-10-14 Thread Andriyko
Thank you for reply, but I still get the errror
Template error

In template /home/pinglin/DjangoProjects/weblog/templates/blog/
article_archive.html, error at line 6

Caught ViewDoesNotExist while rendering: Tried archive_day in module
django.views.generic.dates. Error was: 'module' object has no
attribute 'archive_day'
1   {% extends "blog/index.html" %}
2
3   {% block column1 %}
4   Archive
5   
6   {% for article in object_list %}
7   {{ article.title }}

8   Posted by {{ article.author }} on {{ article.pub_date|date:"F jS,
Y" }}
9   
10  {% endfor %}
11  
12  {% endblock %}
13  {% block column2 %}Last article here{% endblock %}

Could you please give an example about how to use get_absolute_url
with class based generic views?

On Oct 14, 1:31 pm, Fabrizio Mancini  wrote:
> On 13 October 2011 23:57, Andriyko  wrote:
>
> > urlpatterns = patterns('django.views.generic.dates',
> > (r'^(?P\d{4})/v/(?P\d{2})/(?P[-\w]+)/
> > $', DateDetailView.as_view(template_name='blog/article_detail.html',
> > **entry_info_dict)),
> > )
>
> Hi,
> You are using
> (?P\w{3})
> but in get_absolute_url you are using
> self.pub_date.strftime("%m").lower(),
> referring tohttp://docs.python.org/library/time.html#time.strftime
> %m return Month as a decimal number [01,12].
> this won't never work
> You should use %b instead of %m
> This should work
> HTH
> Fabrizio
>
>
>
>
>
>
>
> > = models.py 
>
> > class Article(models.Model):
> >    ..
> >   # with django 1.2 was
> >       @models.permalink
> >    def get_absolute_url(self):
> >        return ('article_detail', (), {  'year':
> > self.pub_date.strftime("%Y"),
> >                                         'month':
> > self.pub_date.strftime("%m").lower(),
> >                                         'day':
> > self.pub_date.strftime("%d"),
> >                                         'slug': self.slug })
> >   # how should it look with django 1.3 ??

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



django 1.3: how to use get_abolute_url in class based generic views

2011-10-13 Thread Andriyko
I have following:
= urls.py 
from django.conf.urls.defaults import *
from django.views.generic.dates import DateDetailView

from blog.models import Article

entry_info_dict = {
'queryset': Article.objects.all(),
'date_field': 'pub_date',
}

urlpatterns = patterns('django.views.generic.dates',
(r'^(?P\d{4})/(?P\w{3})/(?P\d{2})/(?P[-\w]+)/
$', DateDetailView.as_view(template_name='blog/article_detail.html',
**entry_info_dict)),
)

= models.py 

class Article(models.Model):
..
   # with django 1.2 was
   @models.permalink
def get_absolute_url(self):
return ('article_detail', (), {  'year':
self.pub_date.strftime("%Y"),
 'month':
self.pub_date.strftime("%m").lower(),
 'day':
self.pub_date.strftime("%d"),
 'slug': self.slug })
   # how should it look with django 1.3 ??


And this does not work in template


{% for article in object_list %} # ???
{{ article.title }}
# 
Posted by {{ article.author }} on {{ article.pub_date|
date:"F jS, Y" }}

{% endfor %}


Please give an example of how to use get_absolute_url within class
based generic views.

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



will work for food ))

2011-09-29 Thread Andriyko
hello,

I would like to get real experience in development of django based
sites, but don't know how to bring together UI and backend.
-- how to divide tasks/functionality between html, css, jquery, django
etc;
-- how to design architecture;
-- how to choose when to use already existent modules/extensions or
develop own;
-- etc

Maybe someone would like to have a junior assistant for free? ))

Thanks,
Andriyko

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