Templates in Django

2020-05-14 Thread אורי
Hi,

I noticed that an app's template can't extend a template with exactly the
same path in another app. Recently I had a need to extend such a template,
called 'accounts/edit_profile/base.html', so I renamed it
to 'accounts/edit_profile/core_base.html' and added a new
template 'accounts/edit_profile/base.html' which only contains one line:

{% extends 'accounts/edit_profile/core_base.html' %}

And then, in the other app, I extend the same template with my changes:

{% extends 'accounts/edit_profile/core_base.html' %}


{% load core_tags_and_filters %}
{% load i18n %}

{% block edit_profile_links_1 %}
{% if request.user.profile.is_active %}


{% endif %}
{% endblock %}

Is this the correct way to do this? Or is there a better way to extend
templates?

Thanks,
Uri.

אורי
u...@speedy.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABD5YeF8uDqt9uY%3Dy70ev-UotZdUV28dFLK4awAXvSDnukmFTg%40mail.gmail.com.


Re: New Question How to Let a user upload a Video and then show the content on Templates in Django?

2018-03-12 Thread djangorobert
Hi Carlos I figured it out actually i put this {{user.profile.vid.url}}

On Monday, March 12, 2018 at 2:29:11 PM UTC-5, sacrac wrote:
>
> what use Imagefield?,  you use FileField is you need the user upload a 
> video like mp4. avi, mpg etc.
> and in your html use tag  for render. {{object.video}}
> example
> 
>   
> Your browser does not support the video tag.
> 
>
>
>
> On Mon, Mar 12, 2018 at 1:16 PM, djangorobert  > wrote:
>
>> Hi Im not sure if i am the only one in the Django community who has been 
>> trying to add this feauture for a couple of years Basically what i want is 
>> to let the user upload videos.
>> I know that you could add the line in your models with a ImageField is 
>> that right? 
>>
>> but then in the template with a 
>>
>>
>> {{ object.photo.url}}.
>>
>> you could do something like that 
>>
>> but when i load the page it just does not load the pictures or videos 
>>
>> any help would be great 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0e2b1c19-5aa9-4dab-bec7-b61a689006f7%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> att.
> Carlos Rocha
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/afe2b044-665d-42c0-b9d7-913450cf8c1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New Question How to Let a user upload a Video and then show the content on Templates in Django?

2018-03-12 Thread anuch thakker
try to create one folder "{% static 'your folder name /file name' %}"also 
create static folder


On Tuesday, 13 March 2018 00:46:52 UTC+5:30, djangorobert wrote:
>
> Hi Im not sure if i am the only one in the Django community who has been 
> trying to add this feauture for a couple of years Basically what i want is 
> to let the user upload videos.
> I know that you could add the line in your models with a ImageField is 
> that right? 
>
> but then in the template with a 
>
>
> {{ object.photo.url}}.
>
> you could do something like that 
>
> but when i load the page it just does not load the pictures or videos 
>
> any help would be great 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fe8aa5d1-b359-4443-9cb0-0d8738dfbb3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New Question How to Let a user upload a Video and then show the content on Templates in Django?

2018-03-12 Thread carlos
what use Imagefield?,  you use FileField is you need the user upload a
video like mp4. avi, mpg etc.
and in your html use tag  for render. {{object.video}}
example

  
Your browser does not support the video tag.




On Mon, Mar 12, 2018 at 1:16 PM, djangorobert 
wrote:

> Hi Im not sure if i am the only one in the Django community who has been
> trying to add this feauture for a couple of years Basically what i want is
> to let the user upload videos.
> I know that you could add the line in your models with a ImageField is
> that right?
>
> but then in the template with a
>
>
> {{ object.photo.url}}.
>
> you could do something like that
>
> but when i load the page it just does not load the pictures or videos
>
> any help would be great 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/0e2b1c19-5aa9-4dab-bec7-b61a689006f7%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
att.
Carlos Rocha

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM-7rO1PuJngmq-gpEmojW8T9HaemhKVDqpTzu_yre%3DVLrxFfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


New Question How to Let a user upload a Video and then show the content on Templates in Django?

2018-03-12 Thread djangorobert
Hi Im not sure if i am the only one in the Django community who has been 
trying to add this feauture for a couple of years Basically what i want is 
to let the user upload videos.
I know that you could add the line in your models with a ImageField is that 
right? 

but then in the template with a 


{{ object.photo.url}}.

you could do something like that 

but when i load the page it just does not load the pictures or videos 

any help would be great 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e2b1c19-5aa9-4dab-bec7-b61a689006f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Custom Templates in Django Sitemaps Index

2015-11-06 Thread Andreas Dickow
See my new tutorial on Custom Templates in Django Sitemaps:
https://biz-factory.de/django-sitemap-index-tutorial/

-- 
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/ce701ceb-4634-46fb-b492-0f2b91dcf94f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Order of finding static files and templates in django-apps

2014-01-10 Thread Aleksey Rezvov


It is duplicate of question in 
stackoverflow<http://stackoverflow.com/questions/21020472/order-of-finding-static-files-and-templates-in-django-apps>
.

For example I have 2 apps in my django project with templates and static 
files with identical subpath:

app1 / 
static /
style.css
templates /
index.html
app2 / 
static /
style.css
templates /
index.html

than, in settings.py I added this two apps:

INSTALLED_APPS = (
'app1',
'app2',)

now I use in some way 'style.css' and 'index.html' in templates, e.g.

{% include 'index.html' %}

so, question is:

*Does Django guarantee that when I reference to 'style.css' or 'index.html' 
will be used files from app2 subdirectories?*

Is it any other way to point Django preferable variants of files in such 
situation?

-- 
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/64abdb46-741a-4234-9cef-dbee4d12efa3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Using Cheetah Templates in django

2010-03-08 Thread srini
hi all,

do anybody think that Using Cheetah Templates in django is more than
any normal Html

Thank you,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Is there a TRIM feature for templates in Django 0.91

2007-09-19 Thread Russell Keith-Magee

On 9/19/07, Frank Peterson <[EMAIL PROTECTED]> wrote:
>
> TRIM would delete any whitespace from the string (tabs, newlines,
> spaces, ...). SPACELESS comes close as it will convert all the
> whitespace into just 1 space.

This behaviour has changed in the SVN version of Django. Now spaceless
will remove all spaces between tags. The documentation for the tag
explains a few other cases where spaces won't be removed.

> I'm not sure SPACELESS doesnt work, maybe because its around the
> variable story.tease?  I cant do anything via python either, I dont
> have permission and I wouldnt know how anyway, all I deal with is
> templates

Unfortunately, I don't think there is much we can do to help, then. If
you can't update Django, and you can't write a custom template, you're
pretty much stuck with the tags 0.91 offers, and spaceless is pretty
much the only tag that does something like you describe.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a TRIM feature for templates in Django 0.91

2007-09-19 Thread Tim Chase

> TRIM would delete any whitespace from the string (tabs, newlines,
> spaces, ...). SPACELESS comes close as it will convert all the
> whitespace into just 1 space.

Should TRIM delete *all* whitespace, or just leading/trailing 
whitespace?  Trim functions usually just remove leading/trailing 
whitespace.

> {% block data %}{% spaceless %}{{ story.tease }}{% endspaceless %}
> {%endblock %}

You may be able to get away with simply using

   {{ story.tease.strip }}

If you need to remove *all* whitespace, not just the 
leading/trailing whitespace, you'll have to create your own 
filter to do it.  However, it's a fairly simple filter process:


import re
from django.template.defaultfilters import stringfilter
from django import template
register = template.Library()
whitespace_re = re.compile(r'\s')

@register.filter(name='remove_whitespace')
@stringfilter
def remove_whitespace(s):
 return whitespace_re.sub('', s)


If the above "{{ story.tease.strip }}" doesn't work for some 
reason (because "tease" is an object rather than a string, most 
likely), you can create a filter out of it the same way, only using

@register.filter(name='strip')
@stringfilter
def strip(s):
 return s.strip()

Either of these should then be usable as

   {{ story.tease|strip }}
or
   {{ story.tease|remove_whitespace }}

You can learn all about creating custom filters at

http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters

-tim





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a TRIM feature for templates in Django 0.91

2007-09-19 Thread Frank Peterson

TRIM would delete any whitespace from the string (tabs, newlines,
spaces, ...). SPACELESS comes close as it will convert all the
whitespace into just 1 space.

I'm stuck on 0.91 at work and I dont think they plan on upgrading
anytime soon (its beyond my control)

I'm not sure SPACELESS doesnt work, maybe because its around the
variable story.tease?  I cant do anything via python either, I dont
have permission and I wouldnt know how anyway, all I deal with is
templates

{% block data %}{% spaceless %}{{ story.tease }}{% endspaceless %}
{%endblock %}


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a TRIM feature for templates in Django 0.91

2007-09-18 Thread Tim Chase

>> I looked over the docs
>> http://www.djangoproject.com/documentation/0_91/templates/
>>
>> but the closest thing was SPACELESS
> 
> - What does a TRIM filter do? Perhaps it change the colour of the trim
> on your website?

I suspect what some languages call Trim is the Python
function/method "strip()".  Since this is a method of all string
objects, and Django calls callables, just using {{
story.tease.strip }} may do what the OP wanted.

> - Why doesn't SPACELESS 'work'? It works fine for me, and there are an
> extensive set of tests that demonstrate all the ways it works. What
> should it be doing that it isn't doing?

I suspect that the OP misunderstood "spaceless" to mean strip()
which of course doesn't work as strip() :)

> Secondly - Django 0.91 is extremely old; I _really_ wouldn't recommend
> building new sites on this version if you can possibly avoid doing so.

Seconded.  .95 or .96 at a minimum :)

-tim



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a TRIM feature for templates in Django 0.91

2007-09-18 Thread Russell Keith-Magee

On 9/19/07, Frank Peterson <[EMAIL PROTECTED]> wrote:
>
> I looked over the docs
> http://www.djangoproject.com/documentation/0_91/templates/
>
> but the closest thing was SPACELESS
>
> I tried to use it like this:
> {% block data %}{% spaceless %}{{ story.tease }}{% endspaceless %}{%
> endblock %}
>
> But it didnt work.

First off - you're going to need to help us out a bit:

- What does a TRIM filter do? Perhaps it change the colour of the trim
on your website?

- Why doesn't SPACELESS 'work'? It works fine for me, and there are an
extensive set of tests that demonstrate all the ways it works. What
should it be doing that it isn't doing?

Secondly - Django 0.91 is extremely old; I _really_ wouldn't recommend
building new sites on this version if you can possibly avoid doing so.
If there _was_ a problem with SPACELESS in v0.91, it has almost
certainly been fixed in the two years since 0.91 was released; if it
hasn't been fixed, we won't be making a point release of 0.91 to
include the change.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is there a TRIM feature for templates in Django 0.91

2007-09-18 Thread Frank Peterson

I looked over the docs
http://www.djangoproject.com/documentation/0_91/templates/

but the closest thing was SPACELESS

I tried to use it like this:
{% block data %}{% spaceless %}{{ story.tease }}{% endspaceless %}{%
endblock %}

But it didnt work.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Myghty Templates in Django - ver. 1

2006-08-02 Thread [EMAIL PROTECTED]

Thanks :)
Wikified here:
http://code.djangoproject.com/wiki/MyghtyTemplatesInDjango


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Myghty Templates in Django - ver. 1

2006-08-01 Thread Simon Willison

> 2a. The easy way to use mygthy templates is to render them and send the
> result to a "Blank" django template which will show the results
> a simple view:
> [...]
> def myview(request):
> file = AFile()
> #execute a template
> interpreter.execute('mytemplate.myt', out_buffer = file)
> # show it via django template
> return render_to_response('index.html', {'content': file.read()})

There's no need to involve the Django template system at all, or to
use a "fake" file object. Django's design ensures that templating is
decoupled from views, so if you want to use myghty you can just do
this:

from django.http import HttpResponse

def myview(request):
response = HttpResponse() # A file-like object
interpreter.execute('mytemplate.myt', out_buffer = response)
return response

Cheers,

Simon

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Myghty Templates in Django - ver. 1

2006-08-01 Thread Russell Keith-Magee
On 8/1/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
1. Install myghty (http://www.myghty.org)
Hi,Thanks for the contribution. I would suggest adding this as a page to the Wiki so that it isn't forgotten. Create a page somewhere in the vicinity of:
http://code.djangoproject.com/wiki/CookBookMyghtyTemplatesand add your content there (and add it to the index at the CookBook wikiword).YoursRuss Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---


Myghty Templates in Django - ver. 1

2006-08-01 Thread [EMAIL PROTECTED]

1. Install myghty (http://www.myghty.org)
2. edit your views.
2a. The easy way to use mygthy templates is to render them and send the
result to a "Blank" django template which will show the results
a simple view:
##
from django.shortcuts import render_to_response
import myghty.interp as interp

interpreter = interp.Interpreter(
data_dir = './cache', # path to cache dir
component_root = '/path/to/myghty/templates',
)

class AFile(object):
"""I'm a file :) from http://blog.zabiello.com""";
__content = ''
def write(self, txt):
self.__content += txt
def read(self):
return self.__content

def myview(request):
file = AFile()
#execute a template
interpreter.execute('mytemplate.myt', out_buffer = file)
# show it via django template
return render_to_response('index.html', {'content': file.read()})
#
Example myghty template:
#
%m.write('I am a Myghty template!')

%for i in range(1,10):
loop
%
#

- How to pass data to myghty templates?
USE request_args, like:
interpreter.execute('mytemplate.myt', out_buffer = file, request_args =
{'foo' : 'banana'})

And in myghty it could look like this:
##
<%args>
foo


%m.write(foo)
##


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---