Re: Invalid syntax in url.py

2015-08-07 Thread Sylvain James
Hello,

You need to import views of newsletter module :

from django.conf.urls import include, url
from django.contrib import admin

import newsletter.views as newsletter_views


After that, this shortcut can be used in your urlpatterns definition (you 
can also add a $ in the regex:

urlpatterns = [
url(r'^$', newsletter_views.home, name="home")  
#   url(r'^admin/', include(admin.site.urls)),


Hope it helps,
Sylvain



Le jeudi 6 août 2015 21:57:45 UTC+2, Matthew Yankey a écrit :
>
> this is the url.py
>
>
> from django.conf.urls import include, url
> from django.contrib import admin
>
> urlpatterns = [
>   url(r'^', .newsletter.views.home, name="home")  => this is the 
> line 20
> #   url(r'^admin/', include(admin.site.urls)),
>
>
>
> error below
>
>
> Exception Type: SyntaxError at /
> Exception Value: invalid syntax (urls.py, line 20)
>
>
>
>
>
> Environment:
>
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/
>
> Django Version: 1.8.3
> Python Version: 2.7.9
> Installed Applications:
> ('django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles')
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware',
>  'django.middleware.security.SecurityMiddleware')
>
>
> Traceback:
> File 
> "C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\handlers\base.py" 
> in get_response
>   119. resolver_match = resolver.resolve(request.path_info)
> File 
> "C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\urlresolvers.py" 
> in resolve
>   366. for pattern in self.url_patterns:
> File 
> "C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\urlresolvers.py" 
> in url_patterns
>   402. patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module)
> File 
> "C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\urlresolvers.py" 
> in urlconf_module
>   396. self._urlconf_module = import_module(self.urlconf_name)
> File "C:\Python27\Lib\importlib\__init__.py" in import_module
>   37. __import__(name)
>
>
>
>
>
>
>

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


pyjs - a compiler from Python to JavaScript

2015-08-07 Thread Uri Even-Chen
To Django users,

Are you familiar with pyjs ? I saw the website and I see
that the latest stable release is from May 2012. Is it possible to use pyjs
to compile Python to JavaScript? Which versions of Python are supported?
Are versions 2.7 and 3.4 supported? And is it possible to use Django (in
the client side) and JavaScript frameworks such as jQuery, jQuery UI and
jQuery plugins together with pyjs?

Thanks,
Uri.

*Uri Even-Chen*   [image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    
> Speedypedia in Hebrew and English


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


Re: Issue when rendering manually a form's HiddenInput

2015-08-07 Thread 'Tom Evans' via Django users
On Thu, Aug 6, 2015 at 6:55 PM,   wrote:
> So, I'm trying to use inputs with the hidden attr. I have my form class
> (IndexForm) that has this:
> field = HiddenInput()
> Then, I pass the instance of IndexForm (index_form) to the template, and
> manually render the field (index_form.field). It is alright, but then, in
> the HTML, the render of the field is this...
> 
> Why I'm seeing the str representation of the object, and not an HTML hidden
> input?

Forms are collections of Field instances, but HiddenInput is a Widget.
You should be setting the widget attribute of one of the fields to be
a HiddenInput, not assigning a HiddenInput as a member of the form.

Cheers

Tom

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


Re: Check out what we've build

2015-08-07 Thread Derek
Your $20 plan says:

* Unlimited backups
* Your AWS storage
* 3 licenses

Is that unlimited backups from multiple servers; or do you need a 
license/server?  If not, what are the licenses for?


On Wednesday, 5 August 2015 23:36:14 UTC+2, Tom Cooper wrote:
>
> Hey, guys
>
> Our team is using Django for our projects. And each time finishing the 
> projects we've had a pain with configuring backups (files and DBs) for our 
> customer's VPS. While solving this problem, we've built the BitCalm.com 
>  service.
>
> Please check it out and give us your feedback.
> Do you think it's useful for anybody else but us or is it creepy shit? =)
>
> If you're interested, here are core features:
> - It helps to configure auto backups to S3 in 1 minute.
> - incremental backups for your files and dump backups for your DBs.
> - web-dashboard to add/configure/manage multiple backups in a single place.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2f955d25-dc4d-4c73-8f36-c3087d02f5cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: raw_id_fields: How to show a name instead of id?

2015-08-07 Thread विश्वासराव साळुंखे

Hi,
Try Grappelli's Autocomplete lookups functionality.
More details can be found 
@https://django-grappelli.readthedocs.org/en/latest/customization.html#autocomplete-lookups

Thanks,
Vishwas
On Tuesday, 5 March 2013 15:15:26 UTC+5:30, Almudena Vila Forcén wrote:
>
> Customizing a Django Admin panel, I'm using raw_id_fields 
> 
>  to 
> select a ForeignKey from a Model which has thousands of elements, because 
> the default select-box drop-down is inconvenient with so many elements.
>
> It works but it shows the id as can be seen on this image:
>
>  [image: enter image description here] 
> 
>
> Is there any way to show the name or other field instead of the id? Or, is 
> there any better way to accomplish this than using raw_id_fields?
>
> This is my code in models.py:
>
> class Structure(MPTTModel):
> name = models.CharField(max_length=200, unique=True, verbose_name = 
> _('name'))
> parent = TreeForeignKey('self', null=True, blank=True, 
> related_name='children', verbose_name = _('parent'))
>
> def __unicode__(self):
> return u"%s" % (self.name)
>
> In admin.py:
>
> class StructureAdmin(tree_editor.TreeEditor):
> search_fields = ('name',)
> raw_id_fields = ('parent',)
>
> Thanks in advance.
>
>
>

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


Problem with Queryset

2015-08-07 Thread David Levy
*Guys I have a strange problem the value that we report on my filter is 
passed to the queryset but the value is changed in queryset the query 
returning an unwanted result anyone ever go through this?*


 Filter Results ***
filtro = {'visualizado': False}

 Call to Queryset *
list_emails = 
retorno_publicacao_email.objects.using('default').filter(**filtro).all()

* QUERY RESULT SET list_emails.query **
SELECT "retorno_publicacao_email"."
id", "retorno_publicacao_email"."publicacao_id", 
"retorno_publicacao_email"."delivered_to", 
"retorno_publicacao_email"."message_id", 
"retorno_publicacao_email"."subject", "retorno_publicacao_email"."de", 
"retorno_publicacao_email"."to", "retorno_publicacao_email"."received", 
"retorno_publicacao_email"."cc", 
"retorno_publicacao_email"."content_transfer_encoding", 
"retorno_publicacao_email"."content_disposition", 
"retorno_publicacao_email"."x_attachment_id", 
"retorno_publicacao_email"."body", "retorno_publicacao_email"."bodyhtml", 
"retorno_publicacao_email"."anexo", 
"retorno_publicacao_email"."visualizado", "retorno_publicacao_email"."date" 
FROM "retorno_publicacao_email" WHERE *"retorno_publicacao_email"."visualizado" 
= True*

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


Re: Issue when rendering manually a form's HiddenInput

2015-08-07 Thread durirompepc
Yeah, I deleted the post cause I thinked the same yesterday. Sorry for the 
inconvenience.

El viernes, 7 de agosto de 2015, 13:07:49 (UTC+2), Tom Evans escribió:
>
> On Thu, Aug 6, 2015 at 6:55 PM,  > 
> wrote: 
> > So, I'm trying to use inputs with the hidden attr. I have my form class 
> > (IndexForm) that has this: 
> > field = HiddenInput() 
> > Then, I pass the instance of IndexForm (index_form) to the template, and 
> > manually render the field (index_form.field). It is alright, but then, 
> in 
> > the HTML, the render of the field is this... 
> >  
> > Why I'm seeing the str representation of the object, and not an HTML 
> hidden 
> > input? 
>
> Forms are collections of Field instances, but HiddenInput is a Widget. 
> You should be setting the widget attribute of one of the fields to be 
> a HiddenInput, not assigning a HiddenInput as a member of the form. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01a874e1-02be-41bd-bdd3-5d630a9d7a30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What Did I Do Right? (url and domain name change)

2015-08-07 Thread Malik Rumi
I like the 'definitely not' to the do nothing option. Thanks to both of you!

On Thu, Aug 6, 2015 at 5:41 PM, Aaron C. de Bruyn 
wrote:

> 1. DNS doesn't really work that way in most situations.  Your browser
> should cache it, your computer should cache it (especially Windows),
> and your upstream DNS (usually your router) should cache it.  Your
> computer literally stores 'mysite.com' = '1.2.3.4'.  It doesn't store
> it per-page, but for the whole domain name.
>
> 2. How are the URLs generated in your application?  If your HTML
> template literally has:  http://mysite.herokuapp.com/{% url
> 'home' %}">Home pagethen the only way to update the URLs for
> your app would be to edit the template and fix them.  If you are
> relying on django-sites to 'know' the base URL for your site, go into
> the admin section and click on 'Sites'.  I think it's best practice to
> not prefix my URLs with http://whatever...  Just use {% url 'home' %}
> as it should return something like '/' for the URL (without
> http://mysite.com).
>
> A. Your ALLOWED_HOSTS setting should probably have both domains if you
> want your transition to be smooth.  (i.e. the site works through both
> URLs).  ALLOWED_HOSTS has no affect on what URLs you application
> displays.
>
> B. Definitely not.  Tweak, break, learn.  ;)
>
> Hope that helps.
>
> -A
>
>
> On Thu, Aug 6, 2015 at 2:03 PM, Malik Rumi  wrote:
> > I have 1 model from my django project up and running on django. Before
> > adding more models and content, I wanted to use my actual domain name,
> > instead of whatever.herokuapp.com. So after I got that straight, I
> realized
> > that while the home page was mysite.com, the links were still
> > mystite.herokuapp.com, which I think is a problem. But I also thought
> there
> > had to be an easy fix for this, especially after I saw a post while I was
> > searching for solutions that said django only cares about the stuff that
> > comes after the domain name. So the first thing I did was change a
> hardcoded
> > link in my navbar from mysite.herokuapp/newpage to mysite/newpage in my
> dev
> > site. But testing it the url still said mysite.herokuapp.com/newpage.
> Then I
> > got an idea, and I just manually changed the url to mysite/newpage and
> what
> > do you know, it came up correctly. then I clicked around and suddenly all
> > the pages on my model are coming up that way, which they were not half an
> > hour ago. So the question: What did I do right?
> >
> > Here are my working theories:
> >
> > 1. The dns change, which I also did half an hour ago, worked for the home
> > page immediately (I tested it at the time) but needed to propagate more
> for
> > the other pages to work, which they do now.
> >
> > 2. By changing the url manually, django just fed the pages as requested
> > without concern about the domain part of the url. If I start from
> > mysite.herokuapp.com home page, the links still come up with that domain
> > name.
> >
> > But how do I make this both universal and permanent?
> >
> > A. I could change allowed hosts setting, taking the herokuapp part out
> >
> > B. Do nothing, it works now and I should leave well enough alone.
> >
> > C. ? Your answer here ...
> >
> >
> > Thanks
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/3ded9a89-b20f-489d-aadb-667ab62fdb53%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/OMkN_I__30Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEE%2BrGrft480OFiVv2%3DMLCqxZk6jwsHWTotXhU1hYS5Yv7LBLw%40mail.gmail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-u

problem with get_absolute_url()

2015-08-07 Thread Александр Мусаров
Hi, just wrapping my head around django, and trying to write an ecommerce 
store, when trying to pull out all products belonging to a category getting 
such an error

NoReverseMatch at /catalog/smartphony/ 

Reverse for 'catalog_product' with arguments '()' and keyword arguments 
'{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 pattern(s) 
tried: []

Request Method: GET Request URL: http://127.0.0.1:8000/catalog/smartphony/ 
Django 
Version: 1.8.2 Exception Type: NoReverseMatch Exception Value: 

Reverse for 'catalog_product' with arguments '()' and keyword arguments 
'{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 pattern(s) 
tried: []

Exception Location: 
C:\Users\LAPTOP\djangoenvs\py34\lib\site-packages\django\core\urlresolvers.py 
in _reverse_with_prefix, line 496 Python Executable: 
C:\Users\LAPTOP\djangoenvs\py34\Scripts\python.exe Python Version: 3.4.3 Python 
Path: 

['C:\\Users\\LAPTOP\\Desktop\\djangodev\\eshop',
 
'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib\\site-packages\\setuptools-18.0.1-py3.4.egg',
 'C:\\Windows\\system32\\python34.zip',
 'C:\\Users\\LAPTOP\\djangoenvs\\py34\\DLLs',
 'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib',
 'C:\\Users\\LAPTOP\\djangoenvs\\py34\\Scripts',
 'C:\\Python34\\Lib',
 'C:\\Python34\\DLLs',
 'C:\\Users\\LAPTOP\\djangoenvs\\py34',
 'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib\\site-packages']

Server time: Пт, 7 Авг 2015 21:07:01 +0300 
Error during template rendering 

In template 
C:\Users\LAPTOP\Desktop\djangodev\eshop\catalog\templates\categories\category.html,
 
error at line *17*
Reverse for 'catalog_product' with arguments '()' and keyword arguments 
'{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 
pattern(s) tried: [] 7  8 Главная 9 Каталог 10 {{ c.category_name }} 11  12  13 {{ 
c.category_name }} 14  15 {% for p in products %} 16 


17 -- Here the debugger shows the 
mistake 


18  19  20 {{ 
p.product_name }} 21  22  23 {% endfor %} 24 
25 {% endblock %}


Here are my URL patterns 

url(r'^(?P[-\w]+)/$', views.category, name = 
'category_detail' ),
 url(r'^(?P[-\w]+)/(?P[-\w]+)/$', 
views.product, 'catalog_product', name = 'product_detail'),

Here are the corresponding views

def category(request, category_slug):
category_list = Category.objects.filter(category_is_active = True)
c = get_object_or_404(Category, category_slug = category_slug)
products = c.product_set.all()
page_title = c.category_name
meta_keywords = c.category_meta_keywords
meta_description = c.category_meta_description
return render(request, 'categories/category.html', locals())

def product(request, product_slug):
category_list = Category.objects.filter(category_is_active = True)
p = get_object_or_404(Product, product_slug = product_slug)
categories = p.product_categories.all()
page_title = p.product_name
meta_keywords = p.product_meta_keywords
meta_description = p.product_meta_description

# need to evaluate the HTTP method
if request.method == 'POST':
# add to cart... create the bound form
postdata = request.POST.copy()
form = ProductAddToCartForm(request, postdata)
# check if posted data is valid
if form.is_valid():
# add to cart and redirect to cart page
cart.add_to_cart(request)
# if test cookie worked, get rid of it
if request.session.test_cookie_worked():
request.session.delete_test_cookie()
url = urlresolvers.reverse('show_cart')
return HttpResponseRedirect(url)
else:
# it's a GET, create the unbound form. Note request as a kwarg
form = ProductAddToCartForm(request = request, label_suffix = ':')
# assign the hidden input the product slug
form.fields['product_slug'].widget.attrs['value'] = product_slug
# set the test cookie on our first GET request
request.session.set_test_cookie()
return render(request, 'products/product.html', locals())

and here is the part of the corresponding view

{% for p in products %}
  

  
  
{{ p.product_name }}


{% endfor %}   

Thanx in advance )

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d1e58e4-6f6a-4ca5-b2e9-77a7c78cba3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with get_absolute_url()

2015-08-07 Thread Александр Мусаров
 forgot to paste the model methods 

@models.permalink
def get_absolute_url(self):
return ('catalog_category', (), {'category_slug' : 
self.category_slug })

@models.permalink
def get_absolute_url(self):
return ('catalog_product', {}, {'product_slug': self.product_slug})

пятница, 7 августа 2015 г., 21:15:25 UTC+3 пользователь Александр Мусаров 
написал:
>
> Hi, just wrapping my head around django, and trying to write an ecommerce 
> store, when trying to pull out all products belonging to a category getting 
> such an error
>
> NoReverseMatch at /catalog/smartphony/ 
>
> Reverse for 'catalog_product' with arguments '()' and keyword arguments 
> '{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 pattern(s) 
> tried: []
>
> Request Method: GET Request URL: http://127.0.0.1:8000/catalog/smartphony/ 
> Django 
> Version: 1.8.2 Exception Type: NoReverseMatch Exception Value: 
>
> Reverse for 'catalog_product' with arguments '()' and keyword arguments 
> '{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 pattern(s) 
> tried: []
>
> Exception Location: 
> C:\Users\LAPTOP\djangoenvs\py34\lib\site-packages\django\core\urlresolvers.py 
> in _reverse_with_prefix, line 496 Python Executable: 
> C:\Users\LAPTOP\djangoenvs\py34\Scripts\python.exe Python Version: 3.4.3 
> Python 
> Path: 
>
> ['C:\\Users\\LAPTOP\\Desktop\\djangodev\\eshop',
>  
> 'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib\\site-packages\\setuptools-18.0.1-py3.4.egg',
>  'C:\\Windows\\system32\\python34.zip',
>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\DLLs',
>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib',
>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\Scripts',
>  'C:\\Python34\\Lib',
>  'C:\\Python34\\DLLs',
>  'C:\\Users\\LAPTOP\\djangoenvs\\py34',
>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib\\site-packages']
>
> Server time: Пт, 7 Авг 2015 21:07:01 +0300 
> Error during template rendering 
>
> In template 
> C:\Users\LAPTOP\Desktop\djangodev\eshop\catalog\templates\categories\category.html,
>  
> error at line *17*
> Reverse for 'catalog_product' with arguments '()' and keyword arguments 
> '{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 
> pattern(s) tried: [] 7  8  href="/">Главная 9 Каталог 10  class="active">{{ c.category_name }} 11  12  13 {{ 
> c.category_name }} 14  15 {% for p in products %} 16  class = "product_thumbnail">
>
>
> 17 -- Here the debugger shows the 
> mistake 
>
>
> 18  19  
> 20 {{ p.product_name }} 21  22  23 {% endfor %} 24 
> 25 {% endblock %}
>
>
> Here are my URL patterns 
>
> url(r'^(?P[-\w]+)/$', views.category, name = 
> 'category_detail' ),
>  url(r'^(?P[-\w]+)/(?P[-\w]+)/$', 
> views.product, 'catalog_product', name = 'product_detail'),
>
> Here are the corresponding views
>
> def category(request, category_slug):
> category_list = Category.objects.filter(category_is_active = True)
> c = get_object_or_404(Category, category_slug = category_slug)
> products = c.product_set.all()
> page_title = c.category_name
> meta_keywords = c.category_meta_keywords
> meta_description = c.category_meta_description
> return render(request, 'categories/category.html', locals())
>
> def product(request, product_slug):
> category_list = Category.objects.filter(category_is_active = True)
> p = get_object_or_404(Product, product_slug = product_slug)
> categories = p.product_categories.all()
> page_title = p.product_name
> meta_keywords = p.product_meta_keywords
> meta_description = p.product_meta_description
> 
> # need to evaluate the HTTP method
> if request.method == 'POST':
> # add to cart... create the bound form
> postdata = request.POST.copy()
> form = ProductAddToCartForm(request, postdata)
> # check if posted data is valid
> if form.is_valid():
> # add to cart and redirect to cart page
> cart.add_to_cart(request)
> # if test cookie worked, get rid of it
> if request.session.test_cookie_worked():
> request.session.delete_test_cookie()
> url = urlresolvers.reverse('show_cart')
> return HttpResponseRedirect(url)
> else:
> # it's a GET, create the unbound form. Note request as a kwarg
> form = ProductAddToCartForm(request = request, label_suffix = ':')
> # assign the hidden input the product slug
> form.fields['product_slug'].widget.attrs['value'] = product_slug
> # set the test cookie on our first GET request
> request.session.set_test_cookie()
> return render(request, 'products/product.html', locals())
>
> and here is the part of the corresponding view
>
> {% for p in products %}
>   
> 
>   
>   
> {{ p.product_name }}
> 
> 
> {% endfor %}   
>
> Thanx in advance )
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To

Re: Problem with Queryset

2015-08-07 Thread James Schneider
Try removing the .all() at the end, you don't need it.

What does the QS look like before applying the filter (with just .all())?
Are you using a custom model manager?

-James
On Aug 7, 2015 6:37 AM, "David Levy"  wrote:

> *Guys I have a strange problem the value that we report on my filter is
> passed to the queryset but the value is changed in queryset the query
> returning an unwanted result anyone ever go through this?*
>
>
>  Filter Results ***
> filtro = {'visualizado': False}
>
>  Call to Queryset *
> list_emails =
> retorno_publicacao_email.objects.using('default').filter(**filtro).all()
>
> * QUERY RESULT SET list_emails.query **
> SELECT "retorno_publicacao_email"."
> id", "retorno_publicacao_email"."publicacao_id",
> "retorno_publicacao_email"."delivered_to",
> "retorno_publicacao_email"."message_id",
> "retorno_publicacao_email"."subject", "retorno_publicacao_email"."de",
> "retorno_publicacao_email"."to", "retorno_publicacao_email"."received",
> "retorno_publicacao_email"."cc",
> "retorno_publicacao_email"."content_transfer_encoding",
> "retorno_publicacao_email"."content_disposition",
> "retorno_publicacao_email"."x_attachment_id",
> "retorno_publicacao_email"."body", "retorno_publicacao_email"."bodyhtml",
> "retorno_publicacao_email"."anexo",
> "retorno_publicacao_email"."visualizado", "retorno_publicacao_email"."date"
> FROM "retorno_publicacao_email" WHERE 
> *"retorno_publicacao_email"."visualizado"
> = True*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4e1b2bc2-b309-4f4c-81fd-c4815b805f92%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciX7di1eJCC8-uSVJaBcP8WK_kqs7fN4EZJBp6w8Mps4Aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with get_absolute_url()

2015-08-07 Thread James Schneider
You don't have a URL named 'catalog_product'. Check your URL's, it looks
like you are passing an arg and a kwarg to the second pattern.

-James
On Aug 7, 2015 12:33 PM, "Александр Мусаров"  wrote:

>  forgot to paste the model methods
>
> @models.permalink
> def get_absolute_url(self):
> return ('catalog_category', (), {'category_slug' :
> self.category_slug })
>
> @models.permalink
> def get_absolute_url(self):
> return ('catalog_product', {}, {'product_slug': self.product_slug})
>
> пятница, 7 августа 2015 г., 21:15:25 UTC+3 пользователь Александр Мусаров
> написал:
>>
>> Hi, just wrapping my head around django, and trying to write an ecommerce
>> store, when trying to pull out all products belonging to a category getting
>> such an error
>>
>> NoReverseMatch at /catalog/smartphony/
>>
>> Reverse for 'catalog_product' with arguments '()' and keyword arguments 
>> '{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 
>> pattern(s) tried: []
>>
>> Request Method: GET Request URL:
>> http://127.0.0.1:8000/catalog/smartphony/ Django Version: 1.8.2 Exception
>> Type: NoReverseMatch Exception Value:
>>
>> Reverse for 'catalog_product' with arguments '()' and keyword arguments 
>> '{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0 
>> pattern(s) tried: []
>>
>> Exception Location: 
>> C:\Users\LAPTOP\djangoenvs\py34\lib\site-packages\django\core\urlresolvers.py
>> in _reverse_with_prefix, line 496 Python Executable:
>> C:\Users\LAPTOP\djangoenvs\py34\Scripts\python.exe Python Version: 3.4.3 
>> Python
>> Path:
>>
>> ['C:\\Users\\LAPTOP\\Desktop\\djangodev\\eshop',
>>  
>> 'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib\\site-packages\\setuptools-18.0.1-py3.4.egg',
>>  'C:\\Windows\\system32\\python34.zip',
>>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\DLLs',
>>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib',
>>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\Scripts',
>>  'C:\\Python34\\Lib',
>>  'C:\\Python34\\DLLs',
>>  'C:\\Users\\LAPTOP\\djangoenvs\\py34',
>>  'C:\\Users\\LAPTOP\\djangoenvs\\py34\\lib\\site-packages']
>>
>> Server time: Пт, 7 Авг 2015 21:07:01 +0300
>> Error during template rendering
>>
>> In template
>> C:\Users\LAPTOP\Desktop\djangodev\eshop\catalog\templates\categories\category.html,
>> error at line *17*
>> Reverse for 'catalog_product' with arguments '()' and keyword arguments
>> '{'product_slug': 'samsung-galaxy-s5-sm-g900f-16gb'}' not found. 0
>> pattern(s) tried: [] 7  8 > href="/">Главная 9 Каталог 10 > class="active">{{ c.category_name }} 11  12  13 {{
>> c.category_name }} 14  15 {% for p in products %} 16 > class = "product_thumbnail">
>>
>>
>> 17 -- Here the debugger shows the
>> mistake
>>
>>
>> 18  19 
>> 20 {{ p.product_name }} 21  22  23 {% endfor %} 24
>> 25 {% endblock %}
>>
>>
>> Here are my URL patterns
>>
>> url(r'^(?P[-\w]+)/$', views.category, name =
>> 'category_detail' ),
>>  url(r'^(?P[-\w]+)/(?P[-\w]+)/$',
>> views.product, 'catalog_product', name = 'product_detail'),
>>
>> Here are the corresponding views
>>
>> def category(request, category_slug):
>> category_list = Category.objects.filter(category_is_active = True)
>> c = get_object_or_404(Category, category_slug = category_slug)
>> products = c.product_set.all()
>> page_title = c.category_name
>> meta_keywords = c.category_meta_keywords
>> meta_description = c.category_meta_description
>> return render(request, 'categories/category.html', locals())
>>
>> def product(request, product_slug):
>> category_list = Category.objects.filter(category_is_active = True)
>> p = get_object_or_404(Product, product_slug = product_slug)
>> categories = p.product_categories.all()
>> page_title = p.product_name
>> meta_keywords = p.product_meta_keywords
>> meta_description = p.product_meta_description
>>
>> # need to evaluate the HTTP method
>> if request.method == 'POST':
>> # add to cart... create the bound form
>> postdata = request.POST.copy()
>> form = ProductAddToCartForm(request, postdata)
>> # check if posted data is valid
>> if form.is_valid():
>> # add to cart and redirect to cart page
>> cart.add_to_cart(request)
>> # if test cookie worked, get rid of it
>> if request.session.test_cookie_worked():
>> request.session.delete_test_cookie()
>> url = urlresolvers.reverse('show_cart')
>> return HttpResponseRedirect(url)
>> else:
>> # it's a GET, create the unbound form. Note request as a kwarg
>> form = ProductAddToCartForm(request = request, label_suffix = ':')
>> # assign the hidden input the product slug
>> form.fields['product_slug'].widget.attrs['value'] = product_slug
>> # set the test cookie on our first GET request
>> request.session.set_test_cookie()
>> return render(request, 'products/product.html', locals())
>>
>> and here is the part of the corresponding v

Writing a “circuit breaker” for use in Django

2015-08-07 Thread Peter Coles
I’d like to write a circuit breaker wrapper to use with services that I 
call from inside a Django app, and I’d like to get some pointers on the 
following questions:

   1. What’s the most global, persisting, shared-across-requests type of 
   data I can read & write to memory?
   2. However I can do this, does this require using `threading.Lock()`? 
   (looking around `dispatch.Signal` I see some use of it)
   3. If this data is shared per-process, what’s a good way to see how many 
   processes it would be (for uwsgi is that just the # of worker processes)?

The term “circuit breaker” is referring to service clients that cut 
themselves off from making future requests to a service after the service 
has failed to connect or read/write after a certain error threshold. They 
can employ retries to eventually right themselves. If a service continues 
to fail, even despite strict timeouts, it can significantly slow down a 
site or even cause the webserver to run out of threads and it will 
effectively reach a DoS scenario. The clients are per-webserver (or maybe 
in this case, per-process) and all independently can open or close their 
“circuits” based on what they’re experiencing.

To effectively track the effectiveness of service calls without having a 
performance impact on the webserver, it really needs to store this info in 
memory—which is the source of my original questions—and I assume this means 
I’m stuck with only info per-process? I’m OK with the info disappearing 
after server restarts, but might there be some gotchas around other 
configurations, like the `--harakiri` option for uwsgi? As stated above, 
I’m also a little unclear on when using threading locks would be required 
vs not, given that python uses the GIL—but maybe certain configurations do 
allow for non-thread-safe things to happen?

I found 2 barebones approaches on github, but the correctness/effectiveness 
of each was quite unclear:

   - 
   
https://github.com/cuker/django-patchboard/blob/master/patchboard/circuitbreaker.py
   - 
   
https://github.com/globocom/memcached_memoize/blob/master/memcached_memoize/decorators/circuit_breaker.py
   
Any help would be appreciated—whatever I build for this would definitely be 
open-sourced to the community!

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


Re: pyjs - a compiler from Python to JavaScript

2015-08-07 Thread Russell Keith-Magee
Hi Uri,

There are multiple projects out there trying to bridge the gap between
Python and Javascript. PyJS was one of the first I was aware of, but to the
best of my knowledge, it hasn't been very active for the last couple of
years. Brython and Skulpt are two other projects - those two *have* been
kept up to date. There's also PyPy.js, which is the full PyPy interpreter
running in browser - which means you get CPython like performance inside
your browser.

Are they ready for production? That's another story. At the moment, I
wouldn't recommend it, especially if you're a beginner - but it's certainly
possible. However, you'd need to have a pretty good reason. You're going to
experience a lot of friction in the interface between the two languages, so
there would need to be a good reason for taking on that overhead.

Yours,
Russ Magee %-)

On Fri, Aug 7, 2015 at 7:00 PM, Uri Even-Chen  wrote:

> To Django users,
>
> Are you familiar with pyjs ? I saw the website and I
> see that the latest stable release is from May 2012. Is it possible to use
> pyjs to compile Python to JavaScript? Which versions of Python are
> supported? Are versions 2.7 and 3.4 supported? And is it possible to use
> Django (in the client side) and JavaScript frameworks such as jQuery,
> jQuery UI and jQuery plugins together with pyjs?
>
> Thanks,
> Uri.
>
> *Uri Even-Chen*   [image: photo] Phone: +972-54-3995700
> Email: u...@speedy.net
> Website: http://www.speedysoftware.com/uri/en/
> 
> 
>   
> > Speedypedia in Hebrew and English
> 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMQ2MsHy4hwdxgZ8uXo36LtZrKZC_0GgjsGybcdbwpAP14AN5g%40mail.gmail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq84-KiCdRYtaVY_%3DFuuCSpb77GuG4P3vsyMSb083c7YWrZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.