Re: Theming

2017-04-08 Thread Russell Keith-Magee
On Sat, Apr 8, 2017 at 1:28 AM, Clinton Blackburn <
clinton.blackb...@gmail.com> wrote:

> Has anyone solved site-aware theming? I have a multi-tenant site (using
> sites framework) and I want to render custom templates for each site. My
> current design calls for a default design, and overrides of the base
> template (or child templates) for each site. Obviously, I can achieve the
> overrides by prepending the site/theme name when I include a
> template/static file. However, this does not allow for easy support of a
> default fall-back.
>

Actually - it does.

Any time you specify a template to render, you can also specify a *list* of
templates. So, you can do something like this:

def my_view(request):
…
return render(request, [
‘path/to/template/%s/template.html’ % user_theme,
‘path/to/template/default/template.html’,
], {…context…})

That will pick the user’s theme by default; if the user’s theme doesn’t
specify a given template, or the user doesn’t have a theme (or the user’s
theme is set to default), it will use the default theme directory.

Hope that helps!

Yours,
Russ Magee %-)


> How have others solved this problem? Are you using thread.local/global
> variables, as I've seen in some locations?
>
> Are there any plans to support a request/site-aware template loader?
>
> Thanks,
>
> Clinton
>
> --
> 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/8aaf04dc-2de7-4972-8ae5-aaaefa2bf17f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/CAJxq84-T8hYB5NrC0PY9%3D_J6nw%2BY57cK-Zrt5Qj-Qz5C%3DQggag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-08 Thread Fabio C. Barrionuevo da Luz
Hello Shahab.

Perhaps the real problem is that you apparently have not completed a good
tutorial to learn how django works and how to use it.

I would recommend these two tutorials: https://tutorial.djangogirls.org/
and http://www.marinamele.com/taskbuster-django-tutorial

said that, this is the relevant documentation about django Middleware:
https://docs.djangoproject.com/en/1.11/topics/http/middleware/

Note: The django Middleware configuration on settings.py was renamed in
Django 1.10, from MIDDLEWARE_CLASSES to MIDDLEWARE .

Learn more about why this change in:
https://github.com/django/deps/blob/master/final/0005-improved-middleware.rst

About django-secretballot specifically, the available

https://github.com/jamesturk/django-secretballot/blob/master/secretballot/middleware.py#L13-L18


MIDDLEWARE = [
# other previous middleware configurations

# Add the below line, on final of MIDDLEWARE variable in your
settings.py
'secretballot.middleware.SecretBallotIpUseragentMiddleware',
]


I hope this has helped. Good studies :-)

On Sat, Apr 8, 2017 at 3:23 AM, shahab emami  wrote:

> I knew where middleware is myself.
> if you read my first post you will see that .
> my question is:
> what i have to add to middleware?
>
> On Friday, April 7, 2017 at 7:16:36 PM UTC+4:30, shahab emami wrote:
>>
>> hello
>> i have a simple question
>> please help me if you can
>>
>>
>> i want to install this package on my project:
>>
>> https://pypi.python.org/pypi/django-secretballot/
>>
>> I am doing the installation step by step but after adding 'secretballot',
>> to my installed_apps It says:
>>
>> * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware
>> section for details)
>>
>>
>> I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after
>> installed_apps but i don't
>> what I have to add to it.
>> can you tell me what's the point when it says "add a secretballot
>> middleware" ?
>> i mean how many secretballot middleware we have that i have to add one of
>> them to my installed_apps?
>>
>> thank you again
>>
>> --
> 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/63d353bb-8ef6-4c15-ba79-eb6ce9b80023%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul

http://pythonclub.com.br/

Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e
mandar o pull-request. Leia mais sobre como publicar em README.md e
contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python
ou é útil para quem usa Python? Está esperando o que? Publica logo, que
estou louco para ler...

-- 
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/CAPVjvMZGdpxQanwxLLANABY_bydJuas-7mmX%3D49mQtuf7BwmLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting Django app into a Desktop app

2017-04-08 Thread officeworked
Hello,

It can be helped by see.

A lot of apps.

www.apparelexportgr.com



On Wednesday, December 19, 2012 at 3:39:21 AM UTC+6, Chris Cogdon wrote:
>
> Personally, I'd prefer something that didn't require packaging up 
> additional programs (xampp and python, in this example).
>
> It should be _perfectly possible_ to find a native-python moderate 
> performance webserver, then wrap up that, django, the application and the 
> python interpreter into a single package.
>
>
> On Tuesday, December 18, 2012 12:14:59 PM UTC-8, peter_julian wrote:
>>
>> Don't realy mathers is xampp comes or not with python, you just need to 
>> add wsgi module to xampp. and then configure your app to run from
>> xampp.
>>  
>>
>

-- 
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/4c1a849a-2370-4098-ab05-9b4b553a69d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to structure this django application

2017-04-08 Thread Rich Shepard

On Sat, 8 Apr 2017, Sithembewena Lloyd Dube wrote:


Do take the time to peruse the book. It would be time well spent. Also, do
keep in mind that the recommendations therein do not apply to a Django
blog or CRM sustem etc, per se. They would apply just as well if you were
building a RESTful mobile app backend.


Sithembewena,

  I recognized this the first time I considered using django.


The problem you describe of managing users etc is just a requirements
specification. The advice in the book is general enough across
implementations of solutions in broad problem domains. It's not a recipe
book, but more a collection of chefs' knives.


  My original question was not about structuring django code but the logical
design of the project itself. I believe that question was answered by a
message on another thread: there is at least one plug-in package that allows
individual users to work in their own database area and keeps users from
areas assigned to others. This is independent of the django project/app code
arrangement.

Thanks again,

Rich


Re: Just learning about auth in django and getting error NoReverseMatch ; Exception Value: Reverse for 'password_reset_done' with arguments

2017-04-08 Thread ludovic coues
It's hard to tell what is wrong without the full traceback or thecode
causing the exception.

I would suggest to replace reverse("password_reset_done") with
reverse("myapp:password_reset_done").
Might be as simple as that.

2017-04-07 19:55 GMT+02:00 Thames Khi :

> My example is simple, I am happy to use the standard views and templates
> provided by Django.
>
>
> NoReverseMatch at /myapp/password/reset/
>
> Reverse for 'password_reset_done' with arguments '()' and keyword arguments 
> '{}' not found. 0 pattern(s) tried: []
>
> Request Method: GET
> Request URL: http://192.168.0.2:8000/myapp/password/reset/
> Django Version: 1.10.6
> Exception Type: NoReverseMatch
> Exception Value:
>
> Reverse for 'password_reset_done' with arguments '()' and keyword arguments 
> '{}' not found. 0 pattern(s) tried: []
>
> Exception Location: 
> H:\APPS\Python35-32\lib\site-packages\django\urls\resolvers.py
> in _reverse_with_prefix, line 392
> Python Executable: H:\APPS\Python35-32\python.exe
>
>
> My code:
>
> Urls.py
>
> from django.conf.urls import url
> from django.core.urlresolvers import reverse_lazy
> from . import views
> from django.contrib.auth.views import ( login,
> logout,
> password_reset,
> password_reset_done,
> password_reset_confirm,
> password_reset_complete
> )
>
> app_name = 'myapp'
>
> urlpatterns = [
> # /prices/
>
>   url(r'^$', views.home, name='home'),
>   url(r'^myapp/',views.home, name='home'),
>   url(r'^login/$', login, {'template_name':'myapp/login.html'}),
>   url(r'^logout/$', logout, {'template_name': 'myapp/logged_out.html'}),
>   url(r'^register/', views.register, name='register'),
>   url(r'^profile/$', views.profile, name='profile'),
>   url(r'^edit/$', views.edit_profile, name='edit_profile'),
>   url(r'^change-pass', views.change_password, name='change_password'),
>   url(r'^password/reset/done/$', password_reset_done,
> name='password_reset_done'),
>   url(r'^password/reset/$', password_reset, name='password_reset'),
>   url(r'^password/reset/confirm/$', password_reset_confirm,
> name='password_reset_confirm'),
>   url(r'^password/reset/complete/$', password_reset_complete,
> name='password_reset_complete')
>
> ]
>
>
>
> --
> 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/1a9a9f0e-21d8-4038-a681-1736c1cc0073%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Cordialement, Ludovic Coues
+33 6 14 87 43 42

-- 
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/CAEuG%2BTY%3D-HwvRCgtnUmPyqaBYmkVTjwUxLQ0PbyfSH_Bd2VhJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Theming

2017-04-08 Thread Clinton Blackburn
Russ,

How would this work for base/nested templates? Say my view is rendering the 
potential templates ['my-theme/page.html', 'page.html'], and the templates 
inherits base.html. Do I have to override base.html for every theme if I 
want base.html (or any other child/parent template) to be theme-able? Is 
there a version of {%include%} that takes an array, or will I need to write 
my own tag?

I would like to avoid duplicating templates unnecessarily (e.g. every theme 
*has* to have all of the templates, even if there is no override) if 
possible. So far I see my options as either duplicating templates or 
writing a custom {% include %} tag that is theme-aware.

Thanks,
Clinton

On Saturday, April 8, 2017 at 5:44:17 AM UTC-4, Russell Keith-Magee wrote:
>
>
> On Sat, Apr 8, 2017 at 1:28 AM, Clinton Blackburn  > wrote:
>
>> Has anyone solved site-aware theming? I have a multi-tenant site (using 
>> sites framework) and I want to render custom templates for each site. My 
>> current design calls for a default design, and overrides of the base 
>> template (or child templates) for each site. Obviously, I can achieve the 
>> overrides by prepending the site/theme name when I include a 
>> template/static file. However, this does not allow for easy support of a 
>> default fall-back.
>>
>
> Actually - it does.
>
> Any time you specify a template to render, you can also specify a *list* 
> of templates. So, you can do something like this:
>
> def my_view(request):
> …
> return render(request, [
> ‘path/to/template/%s/template.html’ % user_theme,
> ‘path/to/template/default/template.html’,
> ], {…context…})
>
> That will pick the user’s theme by default; if the user’s theme doesn’t 
> specify a given template, or the user doesn’t have a theme (or the user’s 
> theme is set to default), it will use the default theme directory.
>
> Hope that helps!
>
> Yours,
> Russ Magee %-)
>  
>
>> How have others solved this problem? Are you using thread.local/global 
>> variables, as I've seen in some locations?
>>
>> Are there any plans to support a request/site-aware template loader?
>>
>> Thanks,
>>
>> Clinton
>>
>> -- 
>> 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/8aaf04dc-2de7-4972-8ae5-aaaefa2bf17f%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/56df3fa6-a4dd-4b47-904e-1c597e6321d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Extending a image and adding text on the extended area using python pil

2017-04-08 Thread Aamu Padi
I am creating QRcode for each ticket. The QRcode is in image format.

​I want to extend this image vertically on both the sides (i.e. Top and
Bottom). And in the extended area I want to add some additional data like
this:

Theater Name
_
||
||
|   QR CODE  |
||
||
||
||
||
||
Seat id: 24 C
Movie: The baby boss
Showtime: 2:30 pm
Date: 09/04/17



Now I am doing this way to add image:

image = Image.open('qrcode.jpg')
width, height = image.size
draw = ImageDraw.Draw(image)
text_cinema = "RPG Cinema"
text_seat = "Seat: 15C Balcony"
text_movie = "The baby boss"
text_showtime = "02:30 pm"
text_date = "09/04/17"
font = ImageFont.truetype('font.ttf', 24)
draw.text((40, 5), text_cinema, font=font)
draw.text((40,height - 40), text_seat, font=font)
draw.text((40,height + 40), text_movie, font=font)
draw.text((40,height + 40), text_showtime, font=font)
image.save(str(time()).replace('.', '_') + '.jpg')


And the image turns out to be in this way:


​

As you can see, the text are added into the image and not extending the
image itself. Also, other data like text_movie, text_showtime and text_date are
not being inserted as the text does not extend the image.

How can I extend the image and insert texts into the extended image area?

-- 
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/CAHSNPWun8vu1eAprO_46iRPsq-qJuejjsLkWPXc%2BgxjKFsp5cQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Extending a image and adding text on the extended area using python pil

2017-04-08 Thread ludovic coues
Look like a question for the pil mailing list.

Anyway, stackoverflow suggest that you create a new image then paste the
old image onto the new one.
Here is the code from stackoverflow

newImage = Image.new(mode, (newWidth,newHeight))
newImage.paste(srcImage, (x1,y1, x1+oldWidth,y1+oldHeight))

I fear there is no way to make the image fit your content, you'll have to
create an image big enough. I hope that won't be an issue for you



2017-04-08 16:27 GMT+02:00 Aamu Padi :

> I am creating QRcode for each ticket. The QRcode is in image format.
>
> ​I want to extend this image vertically on both the sides (i.e. Top and
> Bottom). And in the extended area I want to add some additional data like
> this:
>
> Theater Name
> _
> ||
> ||
> |   QR CODE  |
> ||
> ||
> ||
> ||
> ||
> ||
> Seat id: 24 C
> Movie: The baby boss
> Showtime: 2:30 pm
> Date: 09/04/17
>
>
>
> Now I am doing this way to add image:
>
> image = Image.open('qrcode.jpg')
> width, height = image.size
> draw = ImageDraw.Draw(image)
> text_cinema = "RPG Cinema"
> text_seat = "Seat: 15C Balcony"
> text_movie = "The baby boss"
> text_showtime = "02:30 pm"
> text_date = "09/04/17"
> font = ImageFont.truetype('font.ttf', 24)
> draw.text((40, 5), text_cinema, font=font)
> draw.text((40,height - 40), text_seat, font=font)
> draw.text((40,height + 40), text_movie, font=font)
> draw.text((40,height + 40), text_showtime, font=font)
> image.save(str(time()).replace('.', '_') + '.jpg')
>
>
> And the image turns out to be in this way:
>
>
> ​
>
> As you can see, the text are added into the image and not extending the
> image itself. Also, other data like text_movie, text_showtime and
> text_date are not being inserted as the text does not extend the image.
>
> How can I extend the image and insert texts into the extended image area?
>
> --
> 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/CAHSNPWun8vu1eAprO_46iRPsq-qJuejjsLkWPXc%2BgxjKFsp5cQ%
> 40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Cordialement, Ludovic Coues
+33 6 14 87 43 42

-- 
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/CAEuG%2BTbYeJSznqF49oH3YP7WiLNg3E_QtPvouxc%3D4yUdUCbr7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Music streaming

2017-04-08 Thread IaMtheMcee
Hi, i'm new to django.. I want to make a music streaming service much like 
itunes where users can purchase and download music. I'm using the 
audiotracks django package to handle my upload and streaming, but im having 
trouble with it.. any pointers?

-- 
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/02e8c8b0-8490-42d1-a384-d5390261a0ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-08 Thread Samuel Brunel
Sorry. I think i'ts in "tokens and SecretBallotMiddleware"

Have à look to http://www.pygarden.com/pkg/django-likes,
http://stackoverflow.com/questions/1954/django-likes-setup-and-error,
http://stackoverflow.com/questions/16179080/django-django-secretballot-middleware


Le ven. 7 avr. 2017 23:29, shahab emami  a écrit :

tanks
but my problem is:
I don't know where middleware section  is.
i looked for middleware section  in the app but i couldn't find anything.
that's why i asked that question here

On Friday, April 7, 2017 at 9:10:05 PM UTC+4:30, Daniel Roseman wrote:



On Friday, 7 April 2017 15:46:36 UTC+1, shahab emami wrote:

hello
i have a simple question
please help me if you can


i want to install this package on my project:

https://pypi.python.org/pypi/django-secretballot/

I am doing the installation step by step but after adding 'secretballot',
to my installed_apps It says:

* add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware
section for details)


I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after
installed_apps but i don't
what I have to add to it.
can you tell me what's the point when it says "add a secretballot
middleware" ?
i mean how many secretballot middleware we have that i have to add one of
them to my installed_apps?

thank you again



Well, as you quoted, the instruction goes on to say "see middleware section
for details". That section does indeed show you what to put in the setting.
--
DR.

-- 
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/a51dbbf7-c195-4563-a1e2-0f2526447ce7%40googlegroups.com

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/CAJVNoBeHKRRw5zttzD9e8gLigsuxDqDayzH6B6QutONeg9ufrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Theming

2017-04-08 Thread Russell Keith-Magee
Hi Clinton,

On Sat, Apr 8, 2017 at 4:05 PM, Clinton Blackburn <
clinton.blackb...@gmail.com> wrote:

> Russ,
>
> How would this work for base/nested templates? Say my view is rendering
> the potential templates ['my-theme/page.html', 'page.html'], and the
> templates inherits base.html. Do I have to override base.html for every
> theme if I want base.html (or any other child/parent template) to be
> theme-able? Is there a version of {%include%} that takes an array, or will
> I need to write my own tag?
>

The template loading list (i.e., [‘my-theme/page.html’,
‘page.html’]) indicates which template will be rendered. Each of those
template can, themselves, include or extend any other template they want.
So, ‘my-theme/page.html’ could extend ‘page.html’, which could, in turn,
extend ‘base.html’ - or both templates could directly extend ‘base.html’.

The argument that is passed to {% extends %} is also something that can be
paramterized - so, for example, you can pass in a variable as template
context that contains the “parent” template - so you could do something
like having “page.html” that starts “{% extends theme %}”, and then pass in
{“theme”: “path/to/theme.html”} as context.

The same applies to {% include %} - anywhere that you pass in a string in a
template could, potentially, be a variable.

The approach that will work best depends on exactly what “theming” means in
your context.

Is it the same basic structure that just has a different style sheet? Then
having a template with {% include theme %} will probably be best.

Or is it a base structure where key bits of content are different? In that
case, having a my-theme/page.html that extends page.html, and using the
template loader trick will probably be best.

Or are the same *pieces* on each page, but laid out differently for each
user?  In that case, you probably want a page.html that starts with {%
extends theme %}, so that the theme establishes basic page structure, and
the page defines the blocks that are placed into that structure.

Yours,
Russ Magee %-)

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


Re: Django Music streaming

2017-04-08 Thread ludovic coues
Could you tell what kind of trouble you have ?

2017-04-08 17:00 GMT+02:00 IaMtheMcee :
> Hi, i'm new to django.. I want to make a music streaming service much like
> itunes where users can purchase and download music. I'm using the
> audiotracks django package to handle my upload and streaming, but im having
> trouble with it.. any pointers?
>
> --
> 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/02e8c8b0-8490-42d1-a384-d5390261a0ad%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Ludovic Coues
+33 6 14 87 43 42

-- 
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/CAEuG%2BTbZXGfyo-q2T6L6eyontK590vjZt2Uf2bfpdv4fCHqt1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Music streaming

2017-04-08 Thread IaMtheMcee

>
> setting up audiotracks in a new project.. im forced to use the example 
> project, whose structure i don't fully understand.. 


the documentation says..

Add ``audiotracks`` to your app
~~~

Edit ``settings.py`` and add ``audiotracks`` to your list of
``INSTALLED_APPS``. Then synchronize your database with::

$ python manage.py syncdb

Edit your ROOT_URLCONF_ and add a piece of code similar to::

urlpatterns += patterns('',
# Here we mount the app under /music. Feel free to use something 
else
url("^music", include("audiotracks.urls")),
# Some URLs require a Django username
url("^(?P[\w\._-]+)/music", include("audiotracks.urls")),
)

Visit the URL ``/music/upload`` to upload your first track.


but i get an error everytime i try 

-- 
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/25f1645f-6b80-435d-9bd5-8ccf26742db4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM for structured Logs

2017-04-08 Thread Scot Hacker
On Tuesday, April 4, 2017 at 5:18:42 AM UTC-7, guettli wrote:
>
> In the past I was told: Don't store logs in the database.
>

For general purposes, I agree with this. Logging is a python standard, logs 
can be verbose, logrolling solutions are well established (and built in), 
etc. However, there are certain situations or activities where database 
logging makes sense, most likely *in addition to* standard logging rather 
than instead of. In one of my projects, half a dozen non-technical managers 
need the ability to track certain types of actions (related to account 
activations at a school). For this, I developed a simple ORM logging 
solution that lets those managers search and filter these special logs in 
the Django admin. 

It's not something that really deserves to be its own project, IMO - just a 
typical thing a dev might do in Django to satisfy an institutional need. 
But I've put my solution in this gist, in case its helpful:

https://gist.github.com/shacker/05bc1de527a2d7412de361ac659aecde
 

-- 
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/c9486b92-010d-445b-b137-1b18f7ca5efb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filter list dict in JsonField Postgres

2017-04-08 Thread Camilo Torres
Hi.
I have been thinking more about this.
I think you cannot filter the list in the query with the JSONField from 
django. At most, you can get the object and filter the field in the 
resulting list.

Example with this simple model:
from django.db import models
from django.contrib.postgres.fields import JSONField
class DataModel(models.Model):
data_field = JSONField(default=dict)

You can do:
DataModel.objects.create(data_field=[{'number': '1160188479', 'id': 0, 
'content': 'hello', 'processed': True}, {'number': '1160188479', 'id': 1, 
'content': 'hello', 'processed': False}, {'number': '1160188479', 'id': 2 
,'content': 'hello', 'processed': False}, {'number': '1162341721', 'id': 3, 
'content': 'hello', 'processed': False}, {'number': '1162341721', 'id': 4, 
'content': 'hello', 'processed':False}, {'number': '1162341721', 'id': 5, 
'con tent': 'hello', 'processed': False}])
Then you can query the database to get that record:
o = DataModel.objects.get()
processed = [x for x in o.data_field if x['processed']]
Variable 'processed' will have the processed data.


If you want to query your models by having the 'processed' field to true, I 
found you can do it if you change the way you save your data, one option 
may be:
DataModel.objects.create(data_field={'*processed*': [{'number': 
'1160188479', 'id': 0, 'content': 'hello', 'processed': True}], '
*not_processed'*: [{'number': '1160188479', 'id': 1, 'content': 'hello', 
'processed': False}, {'number': '1160188479', 'id': 2 ,'content': 'hello', 
'processed': False}, {'number': '1162341721', 'id': 3, 'content': 'hello', 
'processed': False}, {'number': '1162341721', 'id': 4, 'content': 'hello', 
'processed':False}, {'number': '1162341721', 'id': 5, 'con tent': 'hello', 
'processed': False}]})
Notice I saved the data separeting the processed and the not_processed. The 
you can query objects with any of these keys:
queryset = DataModel.objects.filter(data_field__has_key='processed')
Then you can iterate over the queryset and the the data from every dict.

Anyway, to do advanced queries over that data you may be forced to save it 
in a different way. You can even save the "processed" and "not processed" 
data in different list in different JSONFields on the same model, and query 
like this:
queryset = DataModel.objects.filter(processed__isnull=False)


On Monday, April 3, 2017 at 10:34:18 AM UTC-4, Martin Peveri wrote:
>
> Hi, I have this model:
>
> class ItemCampaign(models.Model):
>
>campaign = models.ForeignKey(
>Campaign, related_name="itemscampaign", verbose_name="Item campaña"
>)
>data = JSONField(default=dict)
>
>def __str__(self):
>return self.campaign.name 
>
> With a record with this data: 
>
> [{'number': '1160188479', 'id': 0, 'content': 'hello', 'processed': True},
>  {'number': '1160188479', 'id': 1, 'content': 'hello', 'processed': False
> }, {'number': '1160188479', 'id': 2,'content': 'hello', 'processed': False
> }, {'number': '1162341721', 'id': 3, 'content': 'hello', 'processed': 
> False}, {'number': '1162341721', 'id': 4, 'content': 'hello', 'processed':
> False}, {'number': '1162341721', 'id': 5, 'content': 'hello', 'processed':
>  False}]
>
> I want filter this list dict, like this:
>
> c.itemscampaign.filter(data__processed=True)
>
> But not work. That does not give me back anything.
>
> The content type of data is:
>
> >>> type(c.itemscampaign.all()[0].data)
> 
>
> I understand that it has to be a dict, but how can I insert many 
> dictionaries in the field, as I have in my data if it is not in a list?
>
> 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/4d4c0b43-d357-4dca-9677-73d93896bf7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Binding data to one o many forms from one view - BadHeaderError at - Header values can't contain newlines ()

2017-04-08 Thread Bernardo Garcia

I have the following forms to each user profile

class UserUpdateForm(forms.ModelForm):
class Meta:
widgets = {'gender':forms.RadioSelect,}
fields = ("username", "email", "is_student",   
"is_professor", "is_executive",)
model = get_user_model() #My model User

class StudentProfileForm(forms.ModelForm):
class Meta:
model = StudentProfile
fields = ('origin_education_school',current_education_school',
'extra_occupation')

class ProfessorProfileForm(forms.ModelForm):
class Meta:
model = ProfessorProfile
fields = ('occupation',)

class ExecutiveProfileForm(forms.ModelForm):
class Meta:
model = ExecutiveProfile
fields = ('occupation', 'enterprise_name', 
'culturals_arthistic','ecological')

I have an URL which call to my AccountProfilesView class based view which 
create an instance of the previous forms according to the user profile:

url(r"^profile/(?P[\w\-]+)/$",
views.AccountProfilesView.as_view(),
name='profile'
),


My AccountProfilesView  is this:

I this moment, from the AccountProfilesView class based view I am create 
the different instances of each one of these forms, according to the 
user profile, then, if an user have the is_student profile their related 
form will be generated, and so, of this way to is_professor  and 
is_executive profiles

If an user have the three profiles (is_student, is_professor,is_executive ) 
in one single form will be created or rendered the fields of the three 
forms associated to each user profile related.

class AccountProfilesView(LoginRequiredMixin, UpdateView):
# All users can access this view
model = get_user_model()
#success_url = reverse_lazy('dashboard')
template_name = 'accounts/profile_form.html'
fields = '__all__'

def get_context_data(self, **kwargs):
context = super(AccountProfilesView, 
self).get_context_data(**kwargs)
user = self.request.user

if not self.request.POST:
if user.is_student:
profile = user.get_student_profile()
context['userprofile'] = profile
context['form_student'] = forms.StudentProfileForm()
if user.is_professor:
profile = user.get_professor_profile()
context['userprofile'] = profile
context['form_professor'] = forms.ProfessorProfileForm()
print ("profesor form is", context['form_professor'])
if user.is_executive:
profile = user.get_executive_profile()
context['userprofile'] = profile
context['form_executive'] = forms.ExecutiveProfileForm()
return context

def post(self, request, *args, **kwargs):
self.object = self.get_object()
context = super(AccountProfilesView, self).post(request, *args, 
**kwargs)
user = self.request.user
# if self.request.method == 'POST':
if user.is_student:
context['form_student'] = forms.StudentProfileForm(
self.request.POST)
elif user.is_professor:
context['form_professor'] = forms.ProfessorProfileForm(
self.request.POST)
elif user.is_executive:
context['form_executive'] = forms.ExecutiveProfileForm(
self.request.POST)
return context

def form_valid(self, form):
context = self.get_context_data(form=form)
user = self.request.user
user = form.save()
if user.is_student:
student = context['form_student'].save(commit=False)
student.user = user
student.save()
if user.is_professor:
professor = context['form_professor'].save(commit=False)
professor.user = user
professor.save()
if user.is_executive:
executive = context['form_executive'].save(commit=False)
executive.user = user
executive.save()
return super(AccountProfilesView, self).form_valid(form)

def get_success_url(self):
return reverse('dashboard')

 And in my template, I have the following small logic:


{% csrf_token %}
{% if userprofile.user.is_student %}

My Student Profile data
{% bootstrap_form form_student %}
{% endif %}
 

{% if userprofile.user.is_professor %}
My Professor Profile data
{% bootstrap_form form_professor %}
{% endif %}

   

Re: add a secretballot middleware to MIDDLEWARE_CLASSES

2017-04-08 Thread shahab emami
thank you fabio
I needed this line:
'secretballot.middleware.SecretBallotIpUseragentMiddleware',

my problem solved
thanks again

On Saturday, April 8, 2017 at 3:52:51 PM UTC+4:30, Fabio Caritas 
Barrionuevo da Luz wrote:
>
> Hello Shahab. 
>
> Perhaps the real problem is that you apparently have not completed a good 
> tutorial to learn how django works and how to use it.
>
> I would recommend these two tutorials: https://tutorial.djangogirls.org/ 
> and http://www.marinamele.com/taskbuster-django-tutorial
>
> said that, this is the relevant documentation about django Middleware: 
> https://docs.djangoproject.com/en/1.11/topics/http/middleware/
>
> Note: The django Middleware configuration on settings.py was renamed in 
> Django 1.10, from MIDDLEWARE_CLASSES to MIDDLEWARE .
>
> Learn more about why this change in: 
> https://github.com/django/deps/blob/master/final/0005-improved-middleware.rst
>
> About django-secretballot specifically, the available 
>
>
> https://github.com/jamesturk/django-secretballot/blob/master/secretballot/middleware.py#L13-L18
>
>
> MIDDLEWARE = [
> # other previous middleware configurations
> 
> # Add the below line, on final of MIDDLEWARE variable in your 
> settings.py
> 'secretballot.middleware.SecretBallotIpUseragentMiddleware',
> ]
>
>
> I hope this has helped. Good studies :-)
>
> On Sat, Apr 8, 2017 at 3:23 AM, shahab emami  > wrote:
>
>> I knew where middleware is myself.
>> if you read my first post you will see that .
>> my question is:
>> what i have to add to middleware?
>>
>> On Friday, April 7, 2017 at 7:16:36 PM UTC+4:30, shahab emami wrote:
>>>
>>> hello 
>>> i have a simple question
>>> please help me if you can
>>>
>>>
>>> i want to install this package on my project:
>>>
>>> https://pypi.python.org/pypi/django-secretballot/
>>>
>>> I am doing the installation step by step but after adding 
>>> 'secretballot', to my installed_apps It says:
>>>
>>> * add a secretballot middleware to MIDDLEWARE_CLASSES (see middleware 
>>> section for details)
>>>
>>>
>>> I now where MIDDLEWARE_CLASSES is. it's in setteings.py right after 
>>> installed_apps but i don't
>>> what I have to add to it. 
>>> can you tell me what's the point when it says "add a secretballot 
>>> middleware" ?
>>> i mean how many secretballot middleware we have that i have to add one 
>>> of them to my installed_apps?
>>>
>>> thank you again
>>>
>>> -- 
>> 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/63d353bb-8ef6-4c15-ba79-eb6ce9b80023%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Fábio C. Barrionuevo da Luz
> Palmas - Tocantins - Brasil - América do Sul
>
> http://pythonclub.com.br/
>
> Blog colaborativo sobre Python e tecnologias Relacionadas, mantido 
> totalmente no https://github.com/pythonclub/pythonclub.github.io .
>
> Todos são livres para publicar. É só fazer fork, escrever sua postagem e 
> mandar o pull-request. Leia mais sobre como publicar em README.md e 
> contributing.md.
> Regra básica de postagem:
> "Você" acha interessante? É útil para "você"? Pode ser utilizado com 
> Python ou é útil para quem usa Python? Está esperando o que? Publica logo, 
> que estou louco para ler...
>
>

-- 
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/911b1e61-6cd8-491d-afce-cfdfb7c1a5d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get a mentor

2017-04-08 Thread Babatunde Akinyanmi
I'd joyfully be of assistance. Email me.

On 5 Apr 2017 16:47, "Joe Landrigan"  wrote:

> Thanks Mark!  I'll take all the free mentoring I can get.  ;)  I could use
> both types of mentors, but wasn't expecting an entrepreneurial mentor on a
> Django site.  The idea is actually pretty well thought out, but I doubt
> most people in this list would care for business plans.  I have a local
> group of 143 churches that want what I'd like to build, but building is the
> difficulty.  I'm sure if I can build it I'll be able to attract churches
> outside my town.
>
> On Tuesday, April 4, 2017 at 4:04:57 PM UTC-4, mark wrote:
>>
>> Joe,
>>
>> It is not clear from your post if you just need a django mentor for
>> technical questions, or if you need a business mentor to flesh out your
>> idea. There are hundreds (thousands??) of expert django mentors on this
>> list all willing to give you free advice. Learn how to ask direct questions
>> (https://www.gerv.net/hacking/how-to-ask-good-questions/, ht
>> tp://www.catb.org/~esr/faqs/smart-questions.html) on this list and the
>> time spent spinning your wheels will vanish.
>>
>> A couple more thoughts -
>>
>> * Refine the business idea first, then tackle the technological
>> components. There are many source of business mentors in every city -
>> bankers, lawyers, accountants all have Rolodexes of successful people who
>> are retired and are willing to mentor entrepreneurs. Check with the local
>> Rotary group. Check with you college or high school alumni group. Mentors
>> do not need to be local. Before you build a better mouse trap, be sure
>> there are mice out there who want it.
>>
>> * You will need an attorney to help you get 501c3 (or some other
>> non-profit) status with the IRS - expect to pay ~$1,000 for that. The forms
>> are easy to fill out, but you want an expert to review what you have filled
>> out in order to not shoot yourself in the foot - easy to do. You first need
>> to create a local corporation or partnership before you  tackle the IRS -
>> this will cost a couple of hundred dollars.
>>
>> * Non-profit - have you suggested open sourcing your idea? You could
>> start an open source project as a way to attract developers for the django
>> development. If you plan to make money from this venture, then you would
>> have to figure out how to separate the parts of you idea that give you a
>> competitive advantage from those things that don't. Open source the ones
>> that don't.
>>
>> I can't emphasize enough the need to spend 99% of your time to refine
>> your business idea before you invest in other areas. Spend 1% learning how
>> to create a django site with the help of this list until you and your
>> business mentors are convinced you have a rock solid and defensible idea.
>>
>> Just my 2 cents and some free mentoring! ;)
>>
>> Mark
>>
>> On Tue, Apr 4, 2017 at 9:56 AM, Joe Landrigan  wrote:
>>
>>> I'm in Fort Wayne, Indiana.  I'm not aware of any meetups in the area.
>>> The nearest that I know about are in Chicago, but that's a 3 hour drive one
>>> way.
>>>
>>> On Tuesday, April 4, 2017 at 10:21:14 AM UTC-4, Avraham Serour wrote:

 Hi,

 I suggest going to local meetups, you may meet people that could mentor
 or help you on specific issues, or help you to find a mentor, they could
 either know someone or know of local mentorship programs.

 Where are you located?

 On Tue, Apr 4, 2017 at 4:26 PM, Joe Landrigan  wrote:

> I need a mentor.  I've got an idea for a non-profit that I think could
> be spectacular, and I think Django is the right platform.  But, every time
> I run into a challenge it takes me days to solve for multiple reasons: I'm
> a father of 6, my job has nothing to do with Python, and I don't know what
> I don't know.  If I had someone who has actually made a site to guide me, 
> I
> bet most of my time consuming roadblocks would be decimated. If anyone
> could suggest a good route to find a mentor, I'd be very grateful.  I've
> wasted far too much time trying to solve problems only to find a package
> that solves the problem perfectly weeks later.  Ideally, I'd like to find
> someone who has some entrepreneurial experience, but I'll take any help I
> can get!  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/f2a34670-12ad
> -41da-af56-bf7518b2d4b1%40googlegroups.com
> 

Re: Binding data to one o many forms from one view - BadHeaderError at - Header values can't contain newlines ()

2017-04-08 Thread Camilo Torres
Hi,

Inside your "post" method, you have this line:
context = super(AccountProfilesView, self).post(request, *args, **kwargs)
in that case "context" is a HttpResponse object[0]. May be, from the name 
you use for the variable, you think this is a simple dict as those used to 
pass context to render functions; it is not.
You can use HttpResponse as a dictionary to put HTTP headers in the 
response [1], so line 184 is setting an HTTP header with a value of the 
HTML to render the form; that is not what you want.
You have to remove that line and create your context with something like:
context = {}
And you have to return an HttpResponse object, probably by calling one of 
the render functions [2].


[0] 
https://docs.djangoproject.com/en/1.11/ref/request-response/#httpresponse-objects
[1] 
https://docs.djangoproject.com/en/1.11/ref/request-response/#setting-header-fields
[2] https://docs.djangoproject.com/en/1.11/topics/http/shortcuts/#render

On Saturday, April 8, 2017 at 5:06:34 PM UTC-4, Bernardo Garcia wrote:
>
>
> I have the following forms to each user profile
>
> class UserUpdateForm(forms.ModelForm):
> class Meta:
> widgets = {'gender':forms.RadioSelect,}
> fields = ("username", "email", "is_student",   
> "is_professor", "is_executive",)
> model = get_user_model() #My model User
> 
> class StudentProfileForm(forms.ModelForm):
> class Meta:
> model = StudentProfile
> fields = ('origin_education_school',current_education_school',
> 'extra_occupation')
> 
> class ProfessorProfileForm(forms.ModelForm):
> class Meta:
> model = ProfessorProfile
> fields = ('occupation',)
> 
> class ExecutiveProfileForm(forms.ModelForm):
> class Meta:
> model = ExecutiveProfile
> fields = ('occupation', 'enterprise_name', 
> 'culturals_arthistic','ecological')
>
> I have an URL which call to my AccountProfilesView class based view which 
> create an instance of the previous forms according to the user profile:
>
> url(r"^profile/(?P[\w\-]+)/$",
> views.AccountProfilesView.as_view(),
> name='profile'
> ),
>
>
> My AccountProfilesView  is this:
>
> I this moment, from the AccountProfilesView class based view I am create 
> the different instances of each one of these forms, according to the 
> user profile, then, if an user have the is_student profile their related 
> form will be generated, and so, of this way to is_professor  and 
> is_executive profiles
>
> If an user have the three profiles (is_student, is_professor,is_executive ) 
> in one single form will be created or rendered the fields of the three 
> forms associated to each user profile related.
>
> class AccountProfilesView(LoginRequiredMixin, UpdateView):
> # All users can access this view
> model = get_user_model()
> #success_url = reverse_lazy('dashboard')
> template_name = 'accounts/profile_form.html'
> fields = '__all__'
> 
> def get_context_data(self, **kwargs):
> context = super(AccountProfilesView, 
> self).get_context_data(**kwargs)
> user = self.request.user
> 
> if not self.request.POST:
> if user.is_student:
> profile = user.get_student_profile()
> context['userprofile'] = profile
> context['form_student'] = forms.StudentProfileForm()
> if user.is_professor:
> profile = user.get_professor_profile()
> context['userprofile'] = profile
> context['form_professor'] = 
> forms.ProfessorProfileForm()
> print ("profesor form is", context['form_professor'])
> if user.is_executive:
> profile = user.get_executive_profile()
> context['userprofile'] = profile
> context['form_executive'] = 
> forms.ExecutiveProfileForm()
> return context
> 
> def post(self, request, *args, **kwargs):
> self.object = self.get_object()
> context = super(AccountProfilesView, self).post(request, 
> *args, **kwargs)
> user = self.request.user
> # if self.request.method == 'POST':
> if user.is_student:
> context['form_student'] = forms.StudentProfileForm(
> self.request.POST)
> elif user.is_professor:
> context['form_professor'] = forms.ProfessorProfileForm(
> self.request.POST)
> elif user.is_executive:
> context['form_executive'] = forms.ExecutiveProfileForm(
> self.request.POST)
> return context
> 
> def form_valid(self, form):
> context = self.get_context_data(form=form)
>

Re: Django Music streaming

2017-04-08 Thread Camilo Torres
Hi, you forgot to include the error you get and probably other relevant 
information.
You may be interested in reading these articles:

https://developer.jboss.org/wiki/HowToAskAForumQuestion?_sscc=t

https://www.biostars.org/p/75548/

On Saturday, April 8, 2017 at 12:38:57 PM UTC-4, IaMtheMcee wrote:
>
> setting up audiotracks in a new project.. im forced to use the example 
>> project, whose structure i don't fully understand.. 
>
>
> the documentation says..
>
> Add ``audiotracks`` to your app
> ~~~
>
> Edit ``settings.py`` and add ``audiotracks`` to your list of
> ``INSTALLED_APPS``. Then synchronize your database with::
>
> $ python manage.py syncdb
>
> Edit your ROOT_URLCONF_ and add a piece of code similar to::
>
> urlpatterns += patterns('',
> # Here we mount the app under /music. Feel free to use something 
> else
> url("^music", include("audiotracks.urls")),
> # Some URLs require a Django username
> url("^(?P[\w\._-]+)/music", include("audiotracks.urls")),
> )
>
> Visit the URL ``/music/upload`` to upload your first track.
>
>
> but i get an error everytime i try 
>

-- 
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/8da5ca14-3735-4247-8298-006fcff46bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Annotated queryset + Prefetch object

2017-04-08 Thread Simon Charette
Hello Jose,

I wouldn't be surprised if this was caused by a Django bug with prefetches 
doing
weird things when the same model is referenced through different 
relations[0].

Simon

[0] https://code.djangoproject.com/ticket/26318

Le samedi 4 mars 2017 13:36:20 UTC-5, Jose Kilo a écrit :
>
> Hi all,
>
> I'm trying to use an annotated queryset inside a Prefetch object. For some 
> reason I'm not getting the expected result.
> This is a simplified version of my models and query.
>
>
> class User(models.Model):
>
> following = models.ManyToManyField('User', related_name='followers', 
> through='Follow')
>
>
> class Follow(models.Model):
>
> following = models.ForeignKey(User, on_delete=models.CASCADE, 
> related_name='_followed')
> followed = models.ForeignKey(User, on_delete=models.CASCADE, 
> related_name='_following')
>
>
> def test():
>
> User.objects.all().delete()
>
> user_1 = User.objects.create()
> user_2 = User.objects.create()
>
> Follow.objects.create(following=user_1, followed=user_2)
>
> queryset = (
> User.objects.all()
> .prefetch_related(
> Prefetch(
> 'followers', to_attr='prefetched_annotated_followers',
> queryset=(User.objects.all().annotate(
> followers_count=Count('followers', distinct=True),
> ))
> ),
> Prefetch(
> 'followers', to_attr='prefetched_followers',
> queryset=User.objects.all()
> ),
> )
> )
>
> user = queryset.last()
> print(list(user.followers.all()))# []
> print(user.prefetched_followers) # []
> print(user.prefetched_annotated_followers)   # []
>
> return queryset
>
>
> Why the last result is empty ? 
>
> Just in case, I added 'prefetched_followers' to compare both results. If 
> I remove it, 'prefetched_annotated_followers' still doesn't get anything.
>

-- 
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/a79f26af-b4ef-4ba7-9c5a-353a900d891a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Password reset custom view

2017-04-08 Thread sarfaraz ahmed
urlpatterns =   [
url(r'^login/',login,name='login'),
url(r'^auth_view/',auth_view, name='auth_view'),

url(r'^signup_success/',signup_success,name='signup_success'),
url(r'^signup/',signup,name='signup'),
url(r'^logout/',logout,name='logout'),

url(r'^signup_confirm/(?P\w+)',signup_confirm,name='signup_confirm'),
url(r'^account_info/',account_info,name='account_info'),
url(r'^user_profile/',user_profile,name='user_profile'),
url(r'^address/',address,name='address'),

url(r'^change_password/',change_password,name='change_password'),
url(r'^add_address/',add_address,name='add_address'),

url(r'^edit_address/(?P\d+)',edit_address,name='edit_address'),

url(r'^delete_address/(?P\d+)',delete_address,name='delete_address'),

url(r'^change_password/',change_password,name='change_password'),
url(r'^email_test/',email_test,name='email_test'),
url(r'^password_reset/$', auth_views.password_reset
,{'template_name':'user_management/password_reset.html','email_template_name':
'user_management/password_reset_email.html'}),
url(r'^password_reset/done/$',
auth_views.password_reset_done,  {'template_name':
'user_management/password_reset_done.html','post_reset_redirect':'password_reset_confirm'}),

url(r'^reset/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.password_reset_confirm,
name='password_reset_confirm'),
url(r'^reset/done/$', auth_views.password_reset_complete,
{'template_name':'user_management/password_reset_complete.html'},name='password_reset_complete'),
]



ERROR

Request Method: GET Request URL: http://127.0.0.1:8000/password_reset/
Django Version: 1.10.5 Exception Type: NoReverseMatch Exception Value:

Reverse for 'password_reset_done' with arguments '()' and keyword arguments
'{}' not found. 0 pattern(s) tried: []

Exception Location:
C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\urls\resolvers.py
in _reverse_with_prefix, line 392 Python Executable: C:\Python27\python.exe
Python Version: 2.7.9

Please help


-- 
Thanks with regards,
Sarfaraz Ahmed



-- 
Thanks with regards,
Sarfaraz Ahmed

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