Re: URL design

2016-06-03 Thread Luis Zárate
I can test this right now but based in my experience in re I think could be
like this

url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P([a-zA-Z0-9_\-]+)/){7})$',
views.item_list)

Be worry with / in views

El viernes, 3 de junio de 2016, Горобец Дмитрий 
escribió:
> Hello, guys.
> I have the following URL patterns in my urls.py module and I'd like to
refactor them:
>
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list, name="item_location_category"),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list),
>
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
views.item_list)
>
> Example:
>
> http://mysite.com/london/cars/
>
> http://mysite.com/london/cars/new/
>
> http://mysite.com/london/cars/new/audi/
>
> http://mysite.com/london/cars/new/audi/a4/
>
> http://mysite.com/london/cars/new/audi/a4/2016/
>
> http://mysite.com/london/cars/new/audi/a4/2016/white/ etc...
>
> And it shouldn't be query parameter.
>
> Does anyone have any suggestions?
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/123e209e-3921-4399-affc-be8b4c67c6d9%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyNpneVSXBhz3FN%3DmmuOL%2Bcoe6Z4s0p-kh4B1B0M1P_B6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is a good practice to put app inside another?

2016-06-03 Thread Luis Zárate
Django contrib is a good example of how put app inside other package.

El viernes, 3 de junio de 2016, Carl Meyer  escribió:
> On 06/03/2016 01:37 PM, Neto wrote:
>> My project has several apps, some of them depend on others, it is ok to
>> add for example 3 apps within another app?
>
> Yep, there's nothing wrong with this. An "app" is just a Python package;
> nesting Python packages to achieve a logical grouping/hierarchy is a
> perfectly reasonable thing to do.
>
> Carl
>
> --
> 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/575209E6.6080709%40oddbird.net
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyPT5gFgQebxLMTrwUh6ModO-HNh%3DYkn-k0HhvPqGwkunw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why is my Django template not displaying?

2016-06-03 Thread Luis Zárate
Use  plays as a list in form.

You are passing context_list as context object so all variable inside
context_list are available in template but not context_list.

Other option is
return render(request,'live.html',
{"context_list": context_list})


El viernes, 3 de junio de 2016, Dave N 
escribió:
> That absolutely did it James - I thought I was accessing the instance,
but what I needed was to access the template context contents of the
instance. Also, great tip with the django debug toolbar - I've had it
installed, but didn't know how much it actually shows!
>
> On Friday, June 3, 2016 at 8:58:33 AM UTC-7, Dave N wrote:
>>
>> Assuming my model contains data, I have myapp/views.py:
>>
>> from django.template import RequestContext
>> from django.shortcuts import render
>> from .models import History
>> import datetime
>>
>> def live_view(request):
>> context = RequestContext(request)
>> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
>> context_list = {'plays':plays_list}
>> return render(request,'live.html',context_list)
>>
>> myapp/templates/live.html:
>>
>> {% extends 'base.html' %}
>> {% block content %}
>> {% for key, value in context_list.items %}
>> {{ value }}
>> {% endfor %}
>> {% endblock %}
>>
>> myapp/urls.py:
>>
>> from myapp.views import live_view
>> urlpatterns = [url(r'^live/$', live_view, name="live"),]
>>
>> The output is a page that renders only the base.html template, with no
content in the body. What's wrong with my view function or template
rendering? Should I be inheriting from TemplateView?
>
> --
> 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/2dc2c249-66bd-4466-bc45-2d5dee2ba4b9%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

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


Re: Is a good practice to put app inside another?

2016-06-03 Thread Carl Meyer
On 06/03/2016 01:37 PM, Neto wrote:
> My project has several apps, some of them depend on others, it is ok to
> add for example 3 apps within another app?

Yep, there's nothing wrong with this. An "app" is just a Python package;
nesting Python packages to achieve a logical grouping/hierarchy is a
perfectly reasonable thing to do.

Carl

-- 
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/575209E6.6080709%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: Django inside Docker

2016-06-03 Thread Ezequiel Bertti
Why didn't you use image from official django.

https://hub.docker.com/_/django/

FROM django:onbuild




On Fri, Jun 3, 2016 at 5:49 PM, Davi Diório Mendes 
wrote:

> Hi everyone,
>
> I was developing with django localy, in my laptop, and my manager asked to
> project run inside a docker.
>
> I did and now django can't find my templates :(
>
> I appreciate any help, my Dockerfile is attached.
>
> BR.
>
> --
> 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/4eb16ab5-21d0-4c69-abdf-96f614cee3f4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Ezequiel Bertti

https://telegram.me/ebertti
https://twitter.com/ebertti
https://github.com/ebertti

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


Re: Django inside Docker

2016-06-03 Thread Larry Martell
You could try posting on the docker forum: https://forums.docker.com

On Fri, Jun 3, 2016 at 4:49 PM, Davi Diório Mendes
 wrote:
> Hi everyone,
>
> I was developing with django localy, in my laptop, and my manager asked to
> project run inside a docker.
>
> I did and now django can't find my templates :(
>
> I appreciate any help, my Dockerfile is attached.

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


Django inside Docker

2016-06-03 Thread Davi Diório Mendes
Hi everyone,

I was developing with django localy, in my laptop, and my manager asked to 
project run inside a docker.

I did and now django can't find my templates :(

I appreciate any help, my Dockerfile is attached.

BR.

-- 
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/4eb16ab5-21d0-4c69-abdf-96f614cee3f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Dockerfile
Description: Binary data


Is a good practice to put app inside another?

2016-06-03 Thread Neto
My project has several apps, some of them depend on others, it is ok to add 
for example 3 apps within another app?

-- 
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/8f2d102b-6752-49d2-b9d8-c425f1ee0e80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to resize and store pics with Django

2016-06-03 Thread monoBOT
You should take a look to this plugin ... does exactly what you need.

http://djangothumbnails.com/

the user uploads the image and you create as many thumbnails for thoses
images as needed

2016-06-03 21:07 GMT+01:00 ivan77 :

> Thanks!
>
> On Friday, June 3, 2016 at 2:08:01 PM UTC-4, Ketan Bhatt wrote:
>>
>> I am storing links of these images as I need to show them on the
>> frontend, not connected to any user.
>>
>> But I have done what you are talking about too.
>> So Django gives you a Model File Field. Add that to your Model. That will
>> allow you to save and store files. While saving a model object, just use
>> the above code to compress the images.
>>
>> You can find about FileField and how to use it from here
>> https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.FileField
>>
>>
>>
>> On Fri, Jun 3, 2016 at 10:53 PM ivan77  wrote:
>>
>>> Hi Ketan,
>>>
>>> Thanks for the information!
>>>
>>> How is it that you keep the images associated with other tables in the
>>> database?
>>>
>>> What I am specifically thinking about is if you want to associate
>>> specific images with specific users who uploaded, for example?  Some kind
>>> of bridge (many to many table)?
>>>
>>> Ivan
>>>
>>> --
>>> 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/bc43f2b0-9527-407b-b66f-774ad97d565c%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/81b29b5d-3c64-4501-84db-a08e319d409f%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*monoBOT*
Visite mi sitio(Visit my site): monobotsoft.es/blog/

-- 
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/CA%2BxOsGC8g%3Dgkng3ssnjWRruK4JDq7LcCbLVkqrqA1Le5r%3D-B-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to resize and store pics with Django

2016-06-03 Thread ivan77
Thanks! 

On Friday, June 3, 2016 at 2:08:01 PM UTC-4, Ketan Bhatt wrote:
>
> I am storing links of these images as I need to show them on the frontend, 
> not connected to any user.
>
> But I have done what you are talking about too. 
> So Django gives you a Model File Field. Add that to your Model. That will 
> allow you to save and store files. While saving a model object, just use 
> the above code to compress the images.
>
> You can find about FileField and how to use it from here 
> https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.FileField
>
>
>
> On Fri, Jun 3, 2016 at 10:53 PM ivan77  
> wrote:
>
>> Hi Ketan,
>>
>> Thanks for the information!
>>
>> How is it that you keep the images associated with other tables in the 
>> database?  
>>
>> What I am specifically thinking about is if you want to associate 
>> specific images with specific users who uploaded, for example?  Some kind 
>> of bridge (many to many table)?
>>
>> Ivan
>>
>> -- 
>> 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/bc43f2b0-9527-407b-b66f-774ad97d565c%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/81b29b5d-3c64-4501-84db-a08e319d409f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why is my Django template not displaying?

2016-06-03 Thread Dave N
That absolutely did it James - I thought I was accessing the instance, but 
what I needed was to access the template context contents of the instance. 
Also, great tip with the django debug toolbar - I've had it installed, but 
didn't know how much it actually shows!

On Friday, June 3, 2016 at 8:58:33 AM UTC-7, Dave N wrote:
>
> Assuming my model contains data, I have myapp/views.py:
>
> from django.template import RequestContextfrom django.shortcuts import 
> renderfrom .models import Historyimport datetime
> def live_view(request):
> context = RequestContext(request)
> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
> context_list = {'plays':plays_list}
> return render(request,'live.html',context_list)
>
> myapp/templates/live.html:
>
> {% extends 'base.html' %}{% block content %}{% for key, value in 
> context_list.items %}
> {{ value }}{% endfor %}{% endblock %}
>
> myapp/urls.py:
>
> from myapp.views import live_view
> urlpatterns = [url(r'^live/$', live_view, name="live"),]
>
>
> The output is a page that renders only the base.html template, with no 
> content in the body. What's wrong with my view function or template 
> rendering? Should I be inheriting from TemplateView?
>
>

-- 
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/2dc2c249-66bd-4466-bc45-2d5dee2ba4b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


URL design

2016-06-03 Thread Горобец Дмитрий
Hello, guys.

I have the following URL patterns in my urls.py module and I'd like to 
refactor them:

url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list, name="item_location_category"),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list),
url(r'^(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/(?P[a-zA-Z0-9_\-]+)/$',
 views.item_list)


Example:

http://mysite.com/london/cars/

http://mysite.com/london/cars/new/

http://mysite.com/london/cars/new/audi/

http://mysite.com/london/cars/new/audi/a4/

http://mysite.com/london/cars/new/audi/a4/2016/

http://mysite.com/london/cars/new/audi/a4/2016/white/ etc...


And it shouldn't be query parameter.


Does anyone have any suggestions?


Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/123e209e-3921-4399-affc-be8b4c67c6d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to resize and store pics with Django

2016-06-03 Thread Ketan Bhatt
I am storing links of these images as I need to show them on the frontend,
not connected to any user.

But I have done what you are talking about too.
So Django gives you a Model File Field. Add that to your Model. That will
allow you to save and store files. While saving a model object, just use
the above code to compress the images.

You can find about FileField and how to use it from here
https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.FileField



On Fri, Jun 3, 2016 at 10:53 PM ivan77  wrote:

> Hi Ketan,
>
> Thanks for the information!
>
> How is it that you keep the images associated with other tables in the
> database?
>
> What I am specifically thinking about is if you want to associate specific
> images with specific users who uploaded, for example?  Some kind of bridge
> (many to many table)?
>
> Ivan
>
> --
> 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/bc43f2b0-9527-407b-b66f-774ad97d565c%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/CACyRkBXgUQUpHy1LearXu7qNhRBcxAB47ca24jO4P7sKq%3DVLOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to resize and store pics with Django

2016-06-03 Thread ivan77
Hi Ketan,

Thanks for the information!

How is it that you keep the images associated with other tables in the 
database?  

What I am specifically thinking about is if you want to associate specific 
images with specific users who uploaded, for example?  Some kind of bridge 
(many to many table)?

Ivan

-- 
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/bc43f2b0-9527-407b-b66f-774ad97d565c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to resize and store pics with Django

2016-06-03 Thread Ketan Bhatt
This is how you can compress the images while saving:

```python

import urllib2
import cStringIO

from boto3.session import Session

from PIL import Image


aws_session = Session(
aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
region_name=settings.AWS_DEFAULT_LAMBDA_REGION
)
s3_resource = aws_session.resource('s3')

im = Image.open(cStringIO.StringIO(urllib2.urlopen(image_url).read()))

w, h = im.size
w *= 0.5
h *= 0.5

im.thumbnail((w, h))
buf = cStringIO.StringIO()
im.save(buf, format="JPEG")

s3_resource.Object(bucket, filename).put(Body=buf.getvalue(), ACL='public-read')

```


I am reading images from a URL and compressing them and then saving to
S3 using boto.


See how and where you want to store your images and just change the
required line.


On Fri, Jun 3, 2016 at 10:25 PM ivan77  wrote:

> HI,
>
> I would like my Django App to have the functionality where a person can
> upload pictures (that would be resized).
>
> Can you please give me any advice on the best way to do that in Django.  I
> will be using a postgres DB for the app.
>
> Also, if there are any Python/Django apps that you can suggest, please let
> me know.
>
> I found this on stack overflow which is some generic advice:
>
> http://stackoverflow.com/a/561475/3856624
>
>
> Store the pictures on the file system and picture locations in the
> database.
>
> Why? Because...
>
>1. You will be able to serve the pictures as static files.
>2. No database access or application code will be required to fetch
>the pictures.
>3. The images could be served from a different server to improve
>performance.
>4. It will reduce database bottleneck.
>5. The database ultimately stores its data on the file system.
>6. Images can be easily cached when stored on the file system.
>7.
>
>
> Thanks for any ideas,
>
> Ivan
>
>
> --
> 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/530227c6-e9ad-4163-a15d-5afa9eab880a%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/CACyRkBWCg%2BQdF2L_5mrXwxBRqzv_hCXNo73hu4sBt_XmW-kacg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to resize and store pics with Django

2016-06-03 Thread ivan77
HI,

I would like my Django App to have the functionality where a person can 
upload pictures (that would be resized).  

Can you please give me any advice on the best way to do that in Django.  I 
will be using a postgres DB for the app. 

Also, if there are any Python/Django apps that you can suggest, please let 
me know.

I found this on stack overflow which is some generic advice:

http://stackoverflow.com/a/561475/3856624


Store the pictures on the file system and picture locations in the database.

Why? Because...

   1. You will be able to serve the pictures as static files.
   2. No database access or application code will be required to fetch the 
   pictures.
   3. The images could be served from a different server to improve 
   performance.
   4. It will reduce database bottleneck.
   5. The database ultimately stores its data on the file system.
   6. Images can be easily cached when stored on the file system.
   7. 
   

Thanks for any ideas,

Ivan


-- 
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/530227c6-e9ad-4163-a15d-5afa9eab880a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why is my Django template not displaying?

2016-06-03 Thread James Schneider
On Jun 3, 2016 8:58 AM, "Dave N"  wrote:
>
> Assuming my model contains data, I have myapp/views.py:
>
> from django.template import RequestContext
> from django.shortcuts import render
> from .models import History
> import datetime
>
> def live_view(request):
> context = RequestContext(request)
> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
> context_list = {'plays':plays_list}
> return render(request,'live.html',context_list)
>
> myapp/templates/live.html:
>
> {% extends 'base.html' %}
> {% block content %}
> {% for key, value in context_list.items %}
> {{ value }}
> {% endfor %}
> {% endblock %}
>

You probably want {% for key, value in plays.items %} since there probably
isn't a context variable called {{ context_list }}.

Install the Django-debug-toolbar. It'll tell you everything that's
available in the template context and provide what templates were actually
rendered on every page load, along with other cool stuff you didn't even
know you needed to know.

-James

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


Re: Django 1.9 ./manage.py migrate error

2016-06-03 Thread Tejesh Papineni
its working when already have a db because views.py are using Models from 
already existing db. But when creating new db, code in views.py is trying 
to access Models that have not yet been built using ./manage.py migrate. My 
solution is to comment code in views.py that accesses Models or try except 
with OperationalError , then run migrations (which will work now). 
Afterwards revert to old views.py code.

On Monday, March 7, 2016 at 4:20:16 AM UTC+5:30, Xuton Ion wrote:
>
> Hi, thanks for the reply.
> So, did you have a db in the project? I cloned the project again and tried 
> to create the db from the model, but using your suggestion doesn't work.
> I can only get 1.9 working if I already have a db from 1.8, but not 
> creating a new one from scratch.
>
> Neither the first or second line runs, they both exit with the same error. 
> Table doesn't exist
>
> On Monday, 18 January 2016 08:08:38 UTC+13, Marisa DeMeglio wrote:
>>
>> Ok I had to run these commands to make it work:
>>
>> $manage.py makemigrations  
>> $migrate --fake-initial.
>>
>> (for reference: django 1.9.1 / sqlite / OSX / python 3.4)
>>
>> On Sunday, January 17, 2016 at 9:48:22 AM UTC-8, Marisa DeMeglio wrote:
>>>
>>> Did you ever figure this out? I just upgraded from Django 1.8 to 1.9 and 
>>> I'm having the same issue.
>>>
>>> On Saturday, December 12, 2015 at 10:01:39 PM UTC-8, Xuton Ion wrote:

 Thanks for the assistance so far.

 Reading https://docs.djangoproject.com/en/1.9/topics/migrations/ it 
 says I should be able to run migrate to apply migrations.
 But does this mean I have to manually do something, or should that work 
 the same as it did on 1.8?

 I am assuming that it should also be able to create the database from 
 the model with just running that one command.

 When creating a new project the migrate line runs fine, so it seems to 
 be something specific to the project. I cant share the project though

 On Saturday, 12 December 2015 19:14:55 UTC+2, Tim Graham wrote:
>
> Is there a reason you can't use migrations? --run-syncdb is really 
> only meant for huge projects (hundreds or thousands of models) where 
> migrations are too slow. Not sure why it's not working though. You'd have 
> to project a sample project for me to debug further.
>
> On Saturday, December 12, 2015 at 11:53:37 AM UTC-5, Xuton Ion wrote:
>>
>> No, I haven't added any migrations. 
>>
>> I did try with --run-syncdb though, and still had the same error 
>> though
>>
>> On Saturday, 12 December 2015 16:26:15 UTC+2, Tim Graham wrote:
>>>
>>> Does your application have migrations? Quoting the 1.9 release 
>>> notes, "Automatic syncing of apps without migrations is removed. 
>>> Migrations 
>>> are compulsory for all apps unless you pass the --run-syncdb 
>>> 
>>>  
>>> option to migrate."
>>>
>>> On Saturday, December 12, 2015 at 8:42:58 AM UTC-5, Xuton Ion wrote:

 Hi

 I seem to have an issue with running migrate and have been googling 
 all day without any luck

 I have an app which works and runs on 1.8
 After cloning the repo and creating a new ve, I ended up with 
 Django 1.9

 Running the ./manage.py migrate creates the database, but none of 
 the tables from the model. It returns
 django.db.utils.OperationalError: no such table: table_name

 If I delete the db.sqlite3 (still in dev so not postgress yet), 
 deactivate my ve and use my ve with django 1.8, the migrate line runs 
 fine. 
 If I then re-activate my ve with 1.9, everything works fine. I can 
 make changes and run makemigrations, and it works. But the initial 
 state 
 seems to not work

 Anyone else have the same issue, or have some advice for me?

>>>

-- 
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/bdf0bcd1-a3c1-4e8e-822d-1962cda5a67b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Question regarding the separation of roles between Field and Widget

2016-06-03 Thread Raffi Enficiaud
Dear Django users,

This is my first post on this ML, please excuse me if my question sounds 
weird.

My question is about the separation of roles between Widget and Field, in 
the context of eg. a serialization/deserialization of a list of values 
using JSON. It concerns especially the "Field.to_python", "Field.clean", 
"Field.bound_data", "Widget.render" and "Widget.value_from_datadict".

More concretely, I want to manipulate a list of DB entries in a Hidden 
field of a form, use some Javascript to populate the Hidden field and send 
it back to the form. Until today, I was using 

* the to_python method to deserialize the JSON string that was arriving to 
the field, and to transform it to a proper list of objects,
* the prepare_value to initialize the JSON string to put into the Hidden 
input (non documented, this is the only way I found)

The problem was, after an erroneous form has been sent, the prepare_value 
was taking as input a non-deserialized JSON string. Example:

1* initial rendered input: 
2* after populating it with Javascript: 
3* sending the form with error renders the hidden input like this  (more or less some 
). 

It is then calling prepare_value on a JSON string received from 2/, and 
embedding a JSON into a JSON. 

After that, I thought the right approach would be to override a specific 
Widget's "render" and "value_from_datadict": the transformation of the 
python list into a JSON is done in render, and the deserialization is done 
in value_from_datadict. I find that approach cleaner and neat:

* it solves my problem with having a proper serialization/deserialization 
in case of errors
* the Field.to_python does not concentrate in the actual representation of 
the data: it receives a list of values, regardless of the way I am 
serializing the data, and it concentrates on the logic of transforming the 
list or elements of this list into adequate python objects (eg. retrieving 
entries of the DB, removing duplicates)
* the widget is agnostic to logical errors (eg. entry does not exist in the 
DB): it concentrates on serializing/deserializing whatever object has been 
passed to it, and can concentrate of malformed string/data error (eg. 
unable to deserialize)
* there is no need to call a hidden API prepare_value

However, there are other problems:
* there is no proper way to unit test that: assertFieldOutput tests the 
result of the "clean", which is indirectly calling "to_python". 
  * In the case of list of values, since those are not hashable, they 
cannot be used as keys for the "valid"/"invalid" parameters of 
assertFieldOutput
  * Some weird design issues appear: if for instance I would like to remove 
the duplicates in the "to_python", the removal of the duplicates will not 
affect the Widget, and the latter may render the duplicate values again in 
the form
* I would like to test the Widget (illformed strings) and the Field 
(inexisting users, duplicate removal) separately

The other option would be to use the BoundField.data or BoundField.value() 
to put the deserialization  there. But then 
* I would not be able to test it properly until I have a form. 
* 

To put everything in a nutshell, my question is: what is the best way to 
approach this kind of design? What are the responsibilities of those 
two/three entities?

Thanks,
Raffi

-- 
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/51ba6378-b3c7-4a93-b17d-04dd2079c21c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why is my Django template not displaying?

2016-06-03 Thread Dave N
Assuming my model contains data, I have myapp/views.py:

from django.template import RequestContextfrom django.shortcuts import 
renderfrom .models import Historyimport datetime
def live_view(request):
context = RequestContext(request)
plays_list = History.objects.filter(date=datetime.date(2016,04,22))
context_list = {'plays':plays_list}
return render(request,'live.html',context_list)

myapp/templates/live.html:

{% extends 'base.html' %}{% block content %}{% for key, value in 
context_list.items %}
{{ value }}{% endfor %}{% endblock %}

myapp/urls.py:

from myapp.views import live_view
urlpatterns = [url(r'^live/$', live_view, name="live"),]


The output is a page that renders only the base.html template, with no content 
in the body. What's wrong with my view function or template rendering? Should I 
be inheriting from TemplateView?

-- 
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/d42cb230-a86d-4efc-bbe6-42c513227784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Help with Aggregation / Annotation

2016-06-03 Thread Alex G
Hello all,

I know this is probably a really simple question, but I've been trying to 
solve it for ages now and keep failing!

I have two models:

class Subject(models.Model):
name = models.CharField(max_length=200)


class Pupil(models.Model):
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
active = models.BooleanField(default=0, db_index=True)
takes_subject = models.ManyToManyField(Subject)


Each pupil can take many subjects. Finding out how many pupils take each 
subject is easy, 

but I want to find out how many pupils take multiple subjects. Something like:


Subjects taken |  Number of pupils

===|==

4  |  20

3  |  15

2  |  7

1  |  38


That way I can know that say 15 pupils are taking 3 subjects while 38 pupils 
are taking 1 subject. 


How do I achieve this?


Thanks in advance,


Alex

-- 
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/9698832a-6f0a-45d4-ae13-ee1c9ca918ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Young & Fast growing Open Source MySQL CRUD desktop application.

2016-06-03 Thread Garry Lachman
Young & Fast growing Open Source MySQL CRUD desktop application. 

100% Open Source hosted in GitHub. 

http://garrylachman.github.io/ElectroCRUD/?utm_source=google_medium=groups_campaign=groups1
 

Thanks, 
Have, fun :) 

-- 
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/e10768a2-1605-4722-bc86-6ad67538ad5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.