Re: Exception occurred processing WSGI script

2015-01-07 Thread sarfaraz ahmed
Issue resolved. Please close this

On Wednesday, 7 January 2015 23:02:33 UTC+5:30, sarfaraz ahmed wrote:
>
> This is what I am trying to do.
>
> I am using amazon ec2 windows free tier and i am trying to setup django on 
> XAMPP.
>
> I am using apache 2.4 Windows 32 bit version
> python 2.7.9 window 32 bit version
> mod_wsgi 3.5 windows 32 bit version
> and Django 1.7
>
> my project as nothing but just mysite project with myapp as application
> My mod_wsgi file looks like this 
>
> ==
>
> import os,sys
> sys.path.append('c:\\xampp\\htdocs\\mysite')
> os.environ['DJANGO_SETTINGS_MODULE']='mysite.settings'
>
> import django.core.handlers.wsgi
> application= django.core.handlers.wsgi.WSGIHandler()
>
> =-==
>
>
> +++
> Apache error log looks horrible 
> +++
>
>
> mod_wsgi (pid=1980): Exception occurred processing WSGI script 
> 'C:/xampp/htdocs/mysite/mod.wsgi'.
> [Wed Jan 07 16:46:37.425730 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] Traceback (most recent call last):
> [Wed Jan 07 16:46:37.425730 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 
> 187, in __call__
> [Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] response = self.get_response(request)
> [Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 
> 199, in get_response
> [Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] response = self.handle_uncaught_exception(request, resolver, 
> sys.exc_info())
> [Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 
> 236, in handle_uncaught_exception
> [Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] return debug.technical_500_response(request, *exc_info)
> [Wed Jan 07 16:46:37.427732 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\views\\debug.py", line 91, in 
> technical_500_response
> [Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] html = reporter.get_traceback_html()
> [Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\views\\debug.py", line 350, in 
> get_traceback_html
> [Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] return t.render(c)
> [Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 148, in 
> render
> [Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] return self._render(context)
> [Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 142, in 
> _render
> [Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] return self.nodelist.render(context)
> [Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 844, in 
> render
> [Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] bit = self.render_node(node, context)
> [Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\template\\debug.py", line 80, in 
> render_node
> [Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] return node.render(context)
> [Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\template\\debug.py", line 90, in 
> render
> [Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] output = self.filter_expression.resolve(context)
> [Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 624, in 
> resolve
> [Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] new_obj = func(obj, *arg_vals)
> [Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948]   File 
> "C:\\Python27\\lib\\site-packages\\django\\template\\defaultfilters.py", 
> line 769, in date
> [Wed Jan 07 16:46:37.431731 2015] [:error] [pid 1980:tid 1736] [client 
> ::1:49948] return 

Re: Recommendations for hosting service?

2015-01-07 Thread sarfaraz ahmed
I have trying to setup django on aws windows instance that not easy.

Regards,
Sarfaraz Ahmed

On Wednesday, 7 January 2015 22:57:39 UTC+5:30, Stefano Probst wrote:
>
> OK, i just see you need 100GB. At Uberspace you have only 10GB for Data 
> (excl. OS, etc).
>
> Am Mittwoch, 7. Januar 2015 18:25:44 UTC+1 schrieb Stefano Probst:
>>
>> I use DigitalOcean  (VPS) & Uberspace 
>>  (German, shared hosting, support Django 
>> ).
>>
>

-- 
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/4cb45272-f7a5-4d01-84e1-0374bd4d16b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


running template system standalone on django 1.7.1 results in AppRegistryNotReady error

2015-01-07 Thread Oliver Willekens
I'm running into a problem when I'm trying to use Django's template system 
in a standalone application. Previously, in Django 1.4, I didn't have this 
problem.

As described at configuring the template system in standalone mode 
,
 
I first configure the settings of Django and then call one of the template 
loaders. However, I get an AppRegistryNotReady error:

In [1]: from django.conf import settings

In [2]: settings.configure(**{'TEMPLATE_DIRS': 
('/home/oliver/projects/autodelayv3/templates',), 'TEMPLATE_LOADERS': 
('django.template.loaders.filesystem.Loader',)})

In [3]: from django.template.loader import render_to_string

In [4]: render_to_string('webform.html', {'first_name': 'Oliver'})
---
AppRegistryNotReady   Traceback (most recent call last)
 in ()
> 1 render_to_string('webform.html', {'first_name': 'Oliver'})

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/loader.pyc
 
in render_to_string(template_name, dictionary, context_instance, dirs)
168 t = select_template(template_name, dirs)
169 else:
--> 170 t = get_template(template_name, dirs)
171 if not context_instance:
172 return t.render(Context(dictionary))

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/loader.pyc
 
in get_template(template_name, dirs)
142 handling template inheritance recursively.
143 """
--> 144 template, origin = find_template(template_name, dirs)
145 if not hasattr(template, 'render'):
146 # template needs to be compiled

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/loader.pyc
 
in find_template(name, dirs)
130 for loader in template_source_loaders:
131 try:
--> 132 source, display_name = loader(name, dirs)
133 return (source, make_origin(display_name, loader, name, 
dirs))
134 except TemplateDoesNotExist:

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/loader.pyc
 
in __call__(self, template_name, template_dirs)
 42 
 43 def __call__(self, template_name, template_dirs=None):
---> 44 return self.load_template(template_name, template_dirs)
 45 
 46 def load_template(self, template_name, template_dirs=None):

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/loader.pyc
 
in load_template(self, template_name, template_dirs)
 48 origin = make_origin(display_name, 
self.load_template_source, template_name, template_dirs)
 49 try:
---> 50 template = get_template_from_string(source, origin, 
template_name)
 51 return template, None
 52 except TemplateDoesNotExist:

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/loader.pyc
 
in get_template_from_string(source, origin, name)
154 handling template inheritance recursively.
155 """
--> 156 return Template(source, origin, name)
157 
158 

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/base.pyc
 
in __init__(self, template_string, origin, name)
130 if settings.TEMPLATE_DEBUG and origin is None:
131 origin = StringOrigin(template_string)
--> 132 self.nodelist = compile_string(template_string, origin)
133 self.name = name
134 self.origin = origin

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/base.pyc
 
in compile_string(template_string, origin)
160 lexer = lexer_class(template_string, origin)
161 parser = parser_class(lexer.tokenize())
--> 162 return parser.parse()
163 
164 

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/base.pyc
 
in parse(self, parse_until)
288 self.invalid_block_tag(token, command, 
parse_until)
289 try:
--> 290 compiled_result = compile_func(self, token)
291 except TemplateSyntaxError as e:
292 if not self.compile_function_error(token, e):

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/defaulttags.pyc
 
in load(parser, token)
   1113 # add the library to the parser
   1114 try:
-> 1115 lib = get_library(taglib)
   1116 parser.add_library(lib)
   1117 except InvalidTemplateLibrary as e:

/home/oliver/.virtualenvs/base/local/lib/python2.7/site-packages/django/template/base.pyc
 
in get_library(library_name)
   1329 lib = libraries.get(library_name, None)
   1330 if not lib:
-> 1331 

Re: Django 1.7 problem

2015-01-07 Thread Andreas Kuhne
Ok,

What I did was modify how the dbgettext plugin loaded and changed the
registrations of the models.

You shouldn't have this problem without the plugin. Can you get the server
to run without apache? If you just use manage.py runserver?

Regards,

Andréas

2015-01-07 21:23 GMT+01:00 sarfaraz ahmed :

> I have posted the entire issue in another post. After that I found your
> reply.
>
> https://groups.google.com/forum/#!topic/django-users/mOJRvLYjzDs
>
> I m beginner in Django. I have configured Django/Python/ Apache/Mod_wsgi
> on EC2 Amazon Windows instance. I see the similar error. I am not using any
> pluggins. The project is attempt to make Django work on Apache... and it
> not working.
>
> Regards,
> Sarfaraz Ahmed
>
> On Thursday, 8 January 2015 00:59:50 UTC+5:30, Andréas Kühne wrote:
>>
>> Hi Sarfaraz,
>>
>> Are you also having problems with the dbgettext plugin? Or is it with
>> another plugin?
>>
>> Regards,
>>
>> Andréas
>>
>> 2015-01-07 18:40 GMT+01:00 sarfaraz ahmed :
>>
>>> I believe i am too facing the same issue. But from above conversation I
>>> am not able to get solution of this issue. Could please help me.
>>>
>>> Regards,
>>> Sarfaraz Ahmed
>>>
>>> On Thursday, 4 December 2014 15:21:59 UTC+5:30, Andréas Kühne wrote:

 2014-12-04 1:39 GMT+01:00 Carl Meyer :

> Hi Andreas,
>
> On 12/03/2014 01:34 PM, Andreas Kuhne wrote:
> > I am trying to migrate our current website to django 1.7.
> >
> > Currently we are using a plugin called django-dbgettext to get parts
> of our
> > database translated (we are running in 10 different languages). The
> problem
> > is that django-dbgettext starts by going through all of the models
> and does
> > this before the translation framework is running. So I get an
> exception
> > during startup that says:
> > "django.core.exceptions.AppRegistryNotReady: The translation
> infrastructure
> > cannot be initialized before the apps registry is ready. Check that
> you
> > don't make non-lazy gettext calls at import time."
> >
> > The problem seems to be that the classes are loaded before the
> models are
> > correctly loaded and the translation framework is running. All of the
> > classes use ugettext_lazy, but the stack trace includes ugettext.
> >
> > I want to rewrite the django-dbgettext plugin so that it goes
> through the
> > code AFTER the models are correctly loaded. I don't know how to do
> this
> > however. Is there anyway of running code after django is fully
> initialized?
>
> Indeed there is! See
> https://docs.djangoproject.com/en/dev/ref/applications/#djan
> go.apps.AppConfig.ready
>
> > Django admin should do the same thing, it also has a autodiscover()
> > function and I was wondering why this doesn't happen with django
> admin?
> > Could this be a good place to start looking for a solution?
>
> Yes, admin.autodiscover now runs in the admin's AppConfig.ready() in
> Django 1.7, so that would have been a good place to start looking :-)
>
> 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...@googlegroups.com.
> To post to this group, send email to django...@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/547FAD59.5090809%40oddbird.net.
> For more options, visit https://groups.google.com/d/optout.
>

 Thanks Carl,

 With your help here I was able to fix this in less than an hour. Was
 really easy :-)

 Regards,

 Andréas

>>>  --
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/5609842d-2c79-428d-b5f6-81117bbf222c%
>>> 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 

Re: Django 1.7 problem

2015-01-07 Thread sarfaraz ahmed
I have posted the entire issue in another post. After that I found your 
reply.

https://groups.google.com/forum/#!topic/django-users/mOJRvLYjzDs

I m beginner in Django. I have configured Django/Python/ Apache/Mod_wsgi on 
EC2 Amazon Windows instance. I see the similar error. I am not using any 
pluggins. The project is attempt to make Django work on Apache... and it 
not working. 

Regards,
Sarfaraz Ahmed

On Thursday, 8 January 2015 00:59:50 UTC+5:30, Andréas Kühne wrote:
>
> Hi Sarfaraz,
>
> Are you also having problems with the dbgettext plugin? Or is it with 
> another plugin?
>
> Regards,
>
> Andréas
>
> 2015-01-07 18:40 GMT+01:00 sarfaraz ahmed  >:
>
>> I believe i am too facing the same issue. But from above conversation I 
>> am not able to get solution of this issue. Could please help me. 
>>
>> Regards,
>> Sarfaraz Ahmed
>>
>> On Thursday, 4 December 2014 15:21:59 UTC+5:30, Andréas Kühne wrote:
>>>
>>> 2014-12-04 1:39 GMT+01:00 Carl Meyer :
>>>
 Hi Andreas,

 On 12/03/2014 01:34 PM, Andreas Kuhne wrote:
 > I am trying to migrate our current website to django 1.7.
 >
 > Currently we are using a plugin called django-dbgettext to get parts 
 of our
 > database translated (we are running in 10 different languages). The 
 problem
 > is that django-dbgettext starts by going through all of the models 
 and does
 > this before the translation framework is running. So I get an 
 exception
 > during startup that says:
 > "django.core.exceptions.AppRegistryNotReady: The translation 
 infrastructure
 > cannot be initialized before the apps registry is ready. Check that 
 you
 > don't make non-lazy gettext calls at import time."
 >
 > The problem seems to be that the classes are loaded before the models 
 are
 > correctly loaded and the translation framework is running. All of the
 > classes use ugettext_lazy, but the stack trace includes ugettext.
 >
 > I want to rewrite the django-dbgettext plugin so that it goes through 
 the
 > code AFTER the models are correctly loaded. I don't know how to do 
 this
 > however. Is there anyway of running code after django is fully 
 initialized?

 Indeed there is! See
 https://docs.djangoproject.com/en/dev/ref/applications/#
 django.apps.AppConfig.ready

 > Django admin should do the same thing, it also has a autodiscover()
 > function and I was wondering why this doesn't happen with django 
 admin?
 > Could this be a good place to start looking for a solution?

 Yes, admin.autodiscover now runs in the admin's AppConfig.ready() in
 Django 1.7, so that would have been a good place to start looking :-)

 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...@googlegroups.com.
 To post to this group, send email to django...@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/547FAD59.5090809%40oddbird.net.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> Thanks Carl,
>>>
>>> With your help here I was able to fix this in less than an hour. Was 
>>> really easy :-)
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>  -- 
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/5609842d-2c79-428d-b5f6-81117bbf222c%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/3900a5d4-a2de-411c-b23b-1770a46584fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 problem

2015-01-07 Thread Andreas Kuhne
Hi Sarfaraz,

Are you also having problems with the dbgettext plugin? Or is it with
another plugin?

Regards,

Andréas

2015-01-07 18:40 GMT+01:00 sarfaraz ahmed :

> I believe i am too facing the same issue. But from above conversation I am
> not able to get solution of this issue. Could please help me.
>
> Regards,
> Sarfaraz Ahmed
>
> On Thursday, 4 December 2014 15:21:59 UTC+5:30, Andréas Kühne wrote:
>>
>> 2014-12-04 1:39 GMT+01:00 Carl Meyer :
>>
>>> Hi Andreas,
>>>
>>> On 12/03/2014 01:34 PM, Andreas Kuhne wrote:
>>> > I am trying to migrate our current website to django 1.7.
>>> >
>>> > Currently we are using a plugin called django-dbgettext to get parts
>>> of our
>>> > database translated (we are running in 10 different languages). The
>>> problem
>>> > is that django-dbgettext starts by going through all of the models and
>>> does
>>> > this before the translation framework is running. So I get an exception
>>> > during startup that says:
>>> > "django.core.exceptions.AppRegistryNotReady: The translation
>>> infrastructure
>>> > cannot be initialized before the apps registry is ready. Check that you
>>> > don't make non-lazy gettext calls at import time."
>>> >
>>> > The problem seems to be that the classes are loaded before the models
>>> are
>>> > correctly loaded and the translation framework is running. All of the
>>> > classes use ugettext_lazy, but the stack trace includes ugettext.
>>> >
>>> > I want to rewrite the django-dbgettext plugin so that it goes through
>>> the
>>> > code AFTER the models are correctly loaded. I don't know how to do this
>>> > however. Is there anyway of running code after django is fully
>>> initialized?
>>>
>>> Indeed there is! See
>>> https://docs.djangoproject.com/en/dev/ref/applications/#
>>> django.apps.AppConfig.ready
>>>
>>> > Django admin should do the same thing, it also has a autodiscover()
>>> > function and I was wondering why this doesn't happen with django admin?
>>> > Could this be a good place to start looking for a solution?
>>>
>>> Yes, admin.autodiscover now runs in the admin's AppConfig.ready() in
>>> Django 1.7, so that would have been a good place to start looking :-)
>>>
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/547FAD59.5090809%40oddbird.net.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> Thanks Carl,
>>
>> With your help here I was able to fix this in less than an hour. Was
>> really easy :-)
>>
>> Regards,
>>
>> Andréas
>>
>  --
> 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/5609842d-2c79-428d-b5f6-81117bbf222c%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/CALXYUb%3DFYaYetViWQSThEJ-kg6biNKD5YfJLafHB6fb6WFXAyg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django form field validation and error display

2015-01-07 Thread James Schneider
You should remove the inner else: clause and the redirect() line. If
is_valid() fails, the last return statement will be used, which will pass
along the bound form in signup_form that was snagged inside of your first
if statement. Mimic the behavior here:
https://docs.djangoproject.com/en/1.7/topics/forms/#the-view

BTW, django.shortcuts.redirect should handle the reverse() for you, so you
can take that out to make your code a bit cleaner. Also, not sure if this
is a copy/paste issue, but I think render() requires that request be sent
along as the first argument, although I don't use FBV's, so don't quote me
on that.

-James

On Wed, Jan 7, 2015 at 6:03 AM, 赵飞  wrote:

> I want to make a signup page just like:
>
>
> 
> When user click signup, I want to check the if the two password are the
> same, when not, give a error message after "confirm password".  Here is my
> code:
>
> *forms.py*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *class SignupForm(forms.Form):username = forms.CahrField(
> label=_("username"),max_length=30,)email =
> forms.EmailField(label=_('email'),)password_1 = forms.CharField(
> label=_("password"),widget=forms.PasswordInput,)password_2
> = forms.CharField(label=_("password_confirmed"),
> widget=forms.PasswordInput,)def clean_password_2(self):
> password_1 = self.cleaned_data.get("password_1")password_2 =
> self.cleaned_data.get("password_2")if password_1 and password_2 and
> password_1 != password_2:raise
> forms.ValidationError(_('password confirm failed'))return
> password_2 signup.html*
>
> 
> {% csrf_token %}
> 
> {% for field in form %}
> 
> {{ field.label_tag }}
> {{ field }}
> {{ field.errors }}
> 
> {% endfor %}
> 
>
> 
> {% trans "Already have
> accounts?" %}
> 
>
>
>
> *views.py*
>
> def signup_post(request):
> if request.method == 'POST':
> signup_form = forms.SignupForm(request.POST)
>
> if signup_form.is_valid():
> signup_info = signup_form.cleaned_data
> username = signup_info['username']
> email = signup_info['email']
> password = signup_info['password_1']
> user = User.objects.create_user(
> username=username,
> email=email,
> password=password)
> user.save()
> # redirect to main page(not written so far)
> else:
> # I guess something wrong here, but no idea how to fix it.
> return redirect(reverse("accounts:signup"))
>
> else:
> signup_form = forms.SignupForm()
>
> return render(reverse("accounts:signup"), {'form': signup_form})
>
> Can anyone help me out?
> *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/d969fed6-5041-4093-aa35-35d611993cd3%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%2BciUcZytC8tQk8CtH_p5PSrpCCZTszhP-W1ywhdQ61aMPKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 problem

2015-01-07 Thread sarfaraz ahmed
I believe i am too facing the same issue. But from above conversation I am 
not able to get solution of this issue. Could please help me. 

Regards,
Sarfaraz Ahmed

On Thursday, 4 December 2014 15:21:59 UTC+5:30, Andréas Kühne wrote:
>
> 2014-12-04 1:39 GMT+01:00 Carl Meyer :
>
>> Hi Andreas,
>>
>> On 12/03/2014 01:34 PM, Andreas Kuhne wrote:
>> > I am trying to migrate our current website to django 1.7.
>> >
>> > Currently we are using a plugin called django-dbgettext to get parts of 
>> our
>> > database translated (we are running in 10 different languages). The 
>> problem
>> > is that django-dbgettext starts by going through all of the models and 
>> does
>> > this before the translation framework is running. So I get an exception
>> > during startup that says:
>> > "django.core.exceptions.AppRegistryNotReady: The translation 
>> infrastructure
>> > cannot be initialized before the apps registry is ready. Check that you
>> > don't make non-lazy gettext calls at import time."
>> >
>> > The problem seems to be that the classes are loaded before the models 
>> are
>> > correctly loaded and the translation framework is running. All of the
>> > classes use ugettext_lazy, but the stack trace includes ugettext.
>> >
>> > I want to rewrite the django-dbgettext plugin so that it goes through 
>> the
>> > code AFTER the models are correctly loaded. I don't know how to do this
>> > however. Is there anyway of running code after django is fully 
>> initialized?
>>
>> Indeed there is! See
>>
>> https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.ready
>>
>> > Django admin should do the same thing, it also has a autodiscover()
>> > function and I was wondering why this doesn't happen with django admin?
>> > Could this be a good place to start looking for a solution?
>>
>> Yes, admin.autodiscover now runs in the admin's AppConfig.ready() in
>> Django 1.7, so that would have been a good place to start looking :-)
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/547FAD59.5090809%40oddbird.net
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> Thanks Carl,
>
> With your help here I was able to fix this in less than an hour. Was 
> really easy :-)
>
> Regards,
>
> Andréas
>

-- 
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/5609842d-2c79-428d-b5f6-81117bbf222c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Exception occurred processing WSGI script

2015-01-07 Thread sarfaraz ahmed
This is what I am trying to do.

I am using amazon ec2 windows free tier and i am trying to setup django on 
XAMPP.

I am using apache 2.4 Windows 32 bit version
python 2.7.9 window 32 bit version
mod_wsgi 3.5 windows 32 bit version
and Django 1.7

my project as nothing but just mysite project with myapp as application
My mod_wsgi file looks like this 

==

import os,sys
sys.path.append('c:\\xampp\\htdocs\\mysite')
os.environ['DJANGO_SETTINGS_MODULE']='mysite.settings'

import django.core.handlers.wsgi
application= django.core.handlers.wsgi.WSGIHandler()

=-==


+++
Apache error log looks horrible 
+++


mod_wsgi (pid=1980): Exception occurred processing WSGI script 
'C:/xampp/htdocs/mysite/mod.wsgi'.
[Wed Jan 07 16:46:37.425730 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] Traceback (most recent call last):
[Wed Jan 07 16:46:37.425730 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 
187, in __call__
[Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] response = self.get_response(request)
[Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 
199, in get_response
[Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] response = self.handle_uncaught_exception(request, resolver, 
sys.exc_info())
[Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 
236, in handle_uncaught_exception
[Wed Jan 07 16:46:37.426729 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] return debug.technical_500_response(request, *exc_info)
[Wed Jan 07 16:46:37.427732 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\views\\debug.py", line 91, in 
technical_500_response
[Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] html = reporter.get_traceback_html()
[Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\views\\debug.py", line 350, in 
get_traceback_html
[Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] return t.render(c)
[Wed Jan 07 16:46:37.428730 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 148, in 
render
[Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] return self._render(context)
[Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 142, in 
_render
[Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] return self.nodelist.render(context)
[Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 844, in 
render
[Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] bit = self.render_node(node, context)
[Wed Jan 07 16:46:37.429731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\template\\debug.py", line 80, in 
render_node
[Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] return node.render(context)
[Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\template\\debug.py", line 90, in 
render
[Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] output = self.filter_expression.resolve(context)
[Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\template\\base.py", line 624, in 
resolve
[Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] new_obj = func(obj, *arg_vals)
[Wed Jan 07 16:46:37.430731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\template\\defaultfilters.py", 
line 769, in date
[Wed Jan 07 16:46:37.431731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] return format(value, arg)
[Wed Jan 07 16:46:37.431731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948]   File 
"C:\\Python27\\lib\\site-packages\\django\\utils\\dateformat.py", line 343, 
in format
[Wed Jan 07 16:46:37.432731 2015] [:error] [pid 1980:tid 1736] [client 
::1:49948] return 

Re: Recommendations for hosting service?

2015-01-07 Thread Stefano Probst
OK, i just see you need 100GB. At Uberspace you have only 10GB for Data 
(excl. OS, etc).

Am Mittwoch, 7. Januar 2015 18:25:44 UTC+1 schrieb Stefano Probst:
>
> I use DigitalOcean  (VPS) & Uberspace 
>  (German, shared hosting, support Django 
> ).
>

-- 
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/5f0b2c35-2b65-44d0-92c7-a6d843114090%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recommendations for hosting service?

2015-01-07 Thread Stefano Probst
I use DigitalOcean  (VPS) & Uberspace 
 (German, shared hosting, support Django 
).

-- 
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/0662f26e-c40f-4dda-800c-0a8227b9c999%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django form field validation and error display

2015-01-07 Thread 赵飞
I want to make a signup page just like:


When user click signup, I want to check the if the two password are the 
same, when not, give a error message after "confirm password".  Here is my 
code:

*forms.py*

























*class SignupForm(forms.Form):username = forms.CahrField(
label=_("username"),max_length=30,)email = 
forms.EmailField(label=_('email'),)password_1 = forms.CharField(
label=_("password"),widget=forms.PasswordInput,)password_2 
= forms.CharField(label=_("password_confirmed"),
widget=forms.PasswordInput,)def clean_password_2(self):
password_1 = self.cleaned_data.get("password_1")password_2 = 
self.cleaned_data.get("password_2")if password_1 and password_2 and 
password_1 != password_2:raise 
forms.ValidationError(_('password confirm failed'))return 
password_2 signup.html*


{% csrf_token %}

{% for field in form %}

{{ field.label_tag }}
{{ field }}
{{ field.errors }}

{% endfor %}



{% trans "Already have accounts?" 
%}
 



*views.py*

def signup_post(request):
if request.method == 'POST':
signup_form = forms.SignupForm(request.POST)

if signup_form.is_valid():
signup_info = signup_form.cleaned_data
username = signup_info['username']
email = signup_info['email']
password = signup_info['password_1']
user = User.objects.create_user(
username=username,
email=email,
password=password)
user.save()
# redirect to main page(not written so far)
else:
# I guess something wrong here, but no idea how to fix it.
return redirect(reverse("accounts:signup"))

else:
signup_form = forms.SignupForm()

return render(reverse("accounts:signup"), {'form': signup_form}) 

Can anyone help me out? 
*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/d969fed6-5041-4093-aa35-35d611993cd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: modelformset question - interspersing extra forms among existing forms

2015-01-07 Thread Richard Brockie
Hi Collin,

Thanks again for the suggestion - I have the bare-bones version working in 
my code. Now to add in race_number validation and pretty up the form...

R.

On Sunday, January 4, 2015 11:41:36 AM UTC-8, Collin Anderson wrote:
>
> Hi,
>
> If the field on the model is already blank=True, then you don't need that.
>
> Also, I realized my (completely untested :) code doesn't exactly match the 
> behavior you want, but I hope it's a good enough start. You may need to 
> store a reference to the original race_number to decide if you need to 
> .save() or not.
>
> Collin
>
> On Friday, January 2, 2015 9:42:47 PM UTC-5, Richard Brockie wrote:
>>
>> Hi Collin,
>>
>> Thanks very much for the advice. I'll be getting to this part of my 
>> development in the next few days and will report back when I have things 
>> working.
>>
>> One question in the meantime - what does this line do given that my model 
>> will already explicitly not require the race_number?
>>
>> race_number = Entry._meta.get_field('race_number').formfield(required=
>> False)
>>
>> Wishing everyone a prosperous New Year.
>> R.
>>
>>
>> On Thursday, January 1, 2015 3:31:45 PM UTC-8, Collin Anderson wrote:
>>>
>>> Hi,
>>>
>>> Your case is complicated enough that I'd actually recommend not using 
>>> formsets here and processing a list of plain ModelForms yourself in the 
>>> view. I bet formsets will ending out getting in your way.
>>>
>>> Here's a some messy code:
>>>
>>> class EntryForm(forms.ModelForm):
>>> race_number = Entry._meta.get_field('race_number').formfield(
>>> required=False)
>>> class Meta:
>>> model = Entry
>>> fields = ['race_number']
>>>
>>> def the_view(request, athlete_id):
>>> athlete = get_object_or_404(Athlete, id=athlete_id)
>>> existing = {e.category_id: e for e in athlete.entry_set.all()}
>>> entries = []
>>> for category in Category.objects.order_by('particular'):
>>> entries.append(existing.get(category.pk, Entry(athlete=athlete, 
>>> category=category)))
>>> if request.method = 'POST':
>>> forms = [EntryForm(request.POST, instance=e, prefix=e.category.
>>> pk) for e in entries]
>>> if all([f.is_valid() for f in forms]):  # be sure to call 
>>> is_valid() on every form
>>> for entry in entries:
>>> if entry.race_number:
>>> entry.save()
>>> if entry.pk and not entry.race_number:
>>> entry.delete()
>>> else:
>>> forms = [EntryForm(instance=e, prefix=e.category.pk) for e in 
>>> entries]
>>> return render(request, 'template.html', {'athlete': athlete, 'forms'
>>> : forms})
>>>
>>> {% for form in forms %}
>>> Category: {{ form.instance.category }}
>>> {{ form }}
>>> {% endfor %}
>>>
>>> Collin
>>>
>>> On Monday, December 29, 2014 6:07:19 PM UTC-5, Richard Brockie wrote:

 Hi,

 I have the following pseudo model that I will use as the basis of a 
 modelformset:

 class Entry:
 athlete = ForeignKey(athlete)
 category = ForeignKey(category)
 race_number = IntegerField

 I have a page that displays each athlete's details so the choice of 
 athlete has already been made. I want to add a formset that allows a user 
 to specify a race_number for each of the possible categories available.

 An obvious way would be for there to be one Entry for each 
 athlete/category, but in practise this will result in a large entry table 
 that is only ~10% actual data, with the rest being superfluous rows. I'd 
 prefer to avoid this.

 Let's assume that an athlete is already entered in 2 categories out of 
 a possible 10. The queryset will return the 2 existing entries, and I can 
 use extra=8 to add in the other possibilities. However, I am not yet done. 
 I want to do the following and would like advice on how to accomplish this:

1. The category for each the 8 possible new entries needs to be 
assigned before displaying the form - I already know what they are and 
 want 
to display these categories to the user, leaving the race_number as the 
only input field.
2. The categories have a particular (chronological) order that I 
want respected in displaying the forms to the user, so the 2 existing 
 and 8 
possible new categories need to be interspersed to follow the correct 
 order.
3. When it comes time to save the formset, I want only those 
categories that have been changed by having a race_number assigned or 
removed to be saved. I want the entries where the race_number has been 
removed to remain in the entry table. I think I need a way to detect 
 and 
remove the forms that have not been changed by the user before saving 
 the 
formset.

 Any pointers as to how to do this?

 Thanks!
 R.

>>>

-- 
You received this 

porting to 1.7

2015-01-07 Thread MikeKJ
I have hit a snag and reading the relevant ticket has left me none the 
wiser

RuntimeError: Conflicting 'category' models in application 'smartpages': 
 and .

this is the structure

jade - directories( apache2, bin, jadeempire, lib
jadeempire - directories(jadeempire) files(manage.py)
jadeempire - directories(various apps) files(__init__.py, cp.py, 
settings.py, urls.py, wsgi.py)

>>> import sys
>>> print(sys.path)
['/home/jones124/webapps/jade/jadeempire', 
'/home/jones124/webapps/jade/lib/python2.7/Django-1.7.1-py2.7.egg', 
'/home/jones124/webapps/jade/lib/python2.7', 
'/home/jones124/lib/python2.7', '/usr/local/lib/python27.zip', 
'/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', 
'/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', 
'/usr/local/lib/python2.7/lib-dynload', 
'/usr/local/lib/python2.7/site-packages', 
'/usr/local/lib/python2.7/site-packages/PIL']

I kind of understand that that the model is being addressed twice and under 
1.7 that is now forbidden but where and how I do not know, any help much 
appreciated 






-- 
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/68251a24-e6b8-4b18-998f-fc1d8436f81a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how can I choose option price from checkbox option and calculate the sum.

2015-01-07 Thread rdyact
I tried to like this but still got problem. I think Only thing to do more 
is "How can I link the price value to check option's value?"
What is wrong?  (It's still tough to the newbie.)

 javascript* I put on html file.


$(document).ready(function() {
$("input").click(function(event) {
var total = 0;
$("input:checked").each(function() {
total += parseInt($(this).val());
});
if (total == 0) {
$('#TotalCost').val('');
}
else {
$('#TotalCost').val('$' + total);
}
});
});
   


***  I changed the code in *single.html *as below



{% if product.choice_set.all %}
 {% for item in product.*choice*_set.all %}
   {{ item.name }}{{ 
item.price|capfirst }}Add price 
 {% endfor %}

*Total Choice's Amount* :  
{% endif %}




2015년 1월 6일 화요일 오후 5시 4분 46초 UTC+9, rdyact 님의 말:
>
> Oh, thanks a lot, I'll try it anyway. ~~
>
> 2015년 1월 6일 화요일 오후 12시 45분 49초 UTC+9, Collin Anderson 님의 말:
>>
>> Hi,
>>
>> You probably need to use javascript to make the total price auto-update 
>> when you check or uncheck each box. Check out jQuery if you haven't.
>>
>> Once you have that, then, yes, you'll want to re-calculate the price in 
>> django to be sure it's correct.
>>
>> You could create an Order or Cart model that stores which (or how many of 
>> each) items have been select, and maybe the total price too.
>>
>> Collin
>>
>> On Sunday, January 4, 2015 12:55:02 AM UTC-5, rdyact wrote:
>>>
>>>
>>> 
>>> I want to program to calculate sum of user sleclecion of options with 
>>> checkbox.
>>> Pls help me how to keep away from this suffer.
>>> I summarize what I want to do in my attached ppt file.
>>>
>>> How can I code for this in my viws.py & models.py each?
>>>
>>>
>>> #Product Model - models.py
>>>
>>> class Product(models.Model):
>>> title = models.CharField(max_length=120)
>>> description = models.TextField(null=True, blank=True)
>>> price = models.DecimalField(decimal_places=0, max_digits=100, 
>>> default=1)
>>>
>>> class Choice(models.Model):
>>> product = models.ForeignKey(Product)
>>> name = models.CharField(max_length=255)
>>> price = models.DecimalField(decimal_places=0, max_digits=100, default=0)
>>>
>>> # single.html
>>>
>>> Your Product Price : {{ product.price }}$
>>>
>>> {% for item in product.choice_set.all %}
>>> {% csrf_token %}>> value='{{ item.id }}' name='choice'> {{ item.name }} : {{ item.price 
>>> }}$ 
>>> {% endfor %}
>>> 
>>> 
>>> ~~
>>>
>>

-- 
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/5ea9ef49-5f19-4bdf-adc5-fe71f7e5dd90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.