Re: exploring django framework source code

2013-07-11 Thread Tom Evans
On Wed, Jul 10, 2013 at 10:25 PM, Ahmad  wrote:
> Hi every body,
> I'd like to know how to explore the django framework source code like if you 
> are reading a book, like where to start, where to get a general overview of 
> the code organization,  where to head next and so on until you become 
> familiar with all of the framework parts.
> Thanks in advance

Start with the request handler - django/core/handlers/base.py - and
keep reading.

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.
For more options, visit https://groups.google.com/groups/opt_out.




Error in return the view (The view did not return an HttpResponse object)

2013-07-11 Thread Hélio Miranda
Good.
I have the following view:
*def characValue(request, name):*
*if request.method == 'POST':*
*charac = CharacteristicsValue.objects(name=name)*
*val = []*
*for aa in charac:*
*val.append(aa.value)*
*jsonString = json.dumps(val)*
*return HttpResponse(jsonString, content_type='application/json')*

But when I go to the url, the following error appears: *The view 
Football.views.characValue did not return an HttpResponse object.*

Someone can help me? What am I doing wrong?

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error in return the view (The view did not return an HttpResponse object)

2013-07-11 Thread Brett Parker
On 11 Jul 04:23, Hélio Miranda wrote:
> Good.
> I have the following view:
> *def characValue(request, name):*
> *if request.method == 'POST':*
> *charac = CharacteristicsValue.objects(name=name)*
> *val = []*
> *for aa in charac:*
> *val.append(aa.value)*
> *jsonString = json.dumps(val)*
> *return HttpResponse(jsonString, content_type='application/json')*
> 
> But when I go to the url, the following error appears: *The view 
> Football.views.characValue did not return an HttpResponse object.*
> 
> Someone can help me? What am I doing wrong?

Well, you're only returning something if it's a POST, if you're just
visiting the URL then you'll be getting a GET request, which, erm, you
don't appear to have coded for...

-- 
Brett Parker

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error in return the view (The view did not return an HttpResponse object)

2013-07-11 Thread Larry Martell
On Thu, Jul 11, 2013 at 5:23 AM, Hélio Miranda  wrote:
> Good.
> I have the following view:
> def characValue(request, name):
> if request.method == 'POST':
> charac = CharacteristicsValue.objects(name=name)
> val = []
> for aa in charac:
> val.append(aa.value)
> jsonString = json.dumps(val)
> return HttpResponse(jsonString, content_type='application/json')
>
> But when I go to the url, the following error appears: The view
> Football.views.characValue did not return an HttpResponse object.
>
> Someone can help me? What am I doing wrong?

Why don't you set a breakpoint in the code, run the development
server, step through the code and see what is going on.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




custom authenticate method

2013-07-11 Thread adroit . goose
Hello,

In the custom authentication documentation, I saw a example of how to 
authenticate using email address and password. 
But, I did not understand how we can authenticate using 3 parameters for 
eg, [userid, password] from user table and [companyid] (from company table 
as a foreign key in user table). Also, in my custom user model, can I 
include foreign key from company table. 

Thanks,
Goose

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error in return the view (The view did not return an HttpResponse object)

2013-07-11 Thread Hélio Miranda
Yes, this really was the problem Brett

Already decided, 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Add an icon "not displayed on website" to certain fields on Admin interface.

2013-07-11 Thread Jérémie Ferry
I found solution... but not sure is the best.

here it is:

https://gist.github.com/mothsART/acf73a13e5298348e463

I update admin css files to catch my css class and bring me an icon before 
"fields not visible"...

What did you think about?

Le mardi 9 juillet 2013 15:46:48 UTC+2, Jérémie Ferry a écrit :
>
> Add an icon "not displayed on website" to certain fields on Admin 
> interface.
>
> The best idea would be to override Fields properties without touching the 
> code of it. (for example : on an external app)
>
> How to do that properly?
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: video app

2013-07-11 Thread Michael Hernandez
There is no package in the world that will do your work for you.
What are you trying to do. Limit the scope of your question and then ask
for help?

Heres some help though.

First, divide up your application into high level segments.
1. Chat Application ( if there is text based chat on top of video )
2. Video Application

Or if you are just talking webcam chat then your not talking about django
anymore really.

Lets consider its a webcam chat.
1. Django will serve the views, and create the sockets for chat to occur.
2. Django will manage users. ( You need to create models for this )
3. Django will handle sessions of groups of users chatting )

Now how do you want to handle the webcam chat?
Do you want to?
A. Roll Your own video/audio encoder and your own html5 based player.
B. Use a prebuilt flash library
C. Research possible Javascript implementations that already exist.
D. Something else?

This is a difficult project for someone who has to ask the question ("Is
there something that does everything that I want")



On Mon, Jul 8, 2013 at 3:11 PM, Scheck Nyori  wrote:

> Hi,
> Is there any way then i can make a video chat app in django? I searched
> for this package but culdn't find. Please share your views.
>
> 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 http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: video app

2013-07-11 Thread Michael Hernandez
I am sorry if that response came off a bit rude, I meant totally just to
help, I am having a stressful day, and just wanted to stress that you
should breakdown things in your head or on paper, and research the
individual components.
There is never a one size fits all solution.


On Thu, Jul 11, 2013 at 12:12 PM, Michael Hernandez <
michael.hernandez1...@gmail.com> wrote:

> There is no package in the world that will do your work for you.
> What are you trying to do. Limit the scope of your question and then ask
> for help?
>
> Heres some help though.
>
> First, divide up your application into high level segments.
> 1. Chat Application ( if there is text based chat on top of video )
> 2. Video Application
>
> Or if you are just talking webcam chat then your not talking about django
> anymore really.
>
> Lets consider its a webcam chat.
> 1. Django will serve the views, and create the sockets for chat to occur.
> 2. Django will manage users. ( You need to create models for this )
> 3. Django will handle sessions of groups of users chatting )
>
> Now how do you want to handle the webcam chat?
> Do you want to?
> A. Roll Your own video/audio encoder and your own html5 based player.
> B. Use a prebuilt flash library
> C. Research possible Javascript implementations that already exist.
> D. Something else?
>
> This is a difficult project for someone who has to ask the question ("Is
> there something that does everything that I want")
>
>
>
> On Mon, Jul 8, 2013 at 3:11 PM, Scheck Nyori wrote:
>
>> Hi,
>> Is there any way then i can make a video chat app in django? I searched
>> for this package but culdn't find. Please share your views.
>>
>> 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 http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




duda

2013-07-11 Thread Ernesto Pulgaron
hola, estoy introduciendome en django por lo que tengo algunas dudas, 
quisiera sabes como es que se usa UserChangeForm ya que cdo trato de 
accecer al link de 
 password = ReadOnlyPasswordHashField(label=_("Password"),
help_text=_("Raw passwords are not stored, so there is no way to 
see "
"this user's password, but you can change the password "
"using this form."))

me muestra el sgte error :Exception Type: TemplateDoesNotExist
  Exception 
Value:registration/password_change_done.html
  Exception Location: 
C:\Python27\lib\site-packages\django\template\loader.py in find_template, 
line 139

esta es mi view.py:
#Editar usuarios
@login_required(login_url='/ingresar')
def editar_usuario(request):
if request.method == 'POST':
formulario = UserChangeForm(request.POST)
if formulario.is_valid():
formulario.save()
return HttpResponseRedirect('/')
else:
formulario = UserChangeForm()
return 
render_to_response('nuevousuario.html',{'formulario':formulario},context_instance=RequestContext(request))

el html:
{% extends 'baseAdmin.html' %}

{% block content %}

{% csrf_token %}

{{ formulario }}




{% endblock %}

el url:
urlpatterns = patterns('',
   
url(r'^usuario/nuevo$','Administracion.views.nuevo_usuario'),
   
url(r'^usuario/editar$','Administracion.views.editar_usuario'),
   url(r'^ingresar/$','Administracion.views.ingresar'),
   url(r'^privado/$','Administracion.views.privado'),
   url(r'^cerrar/$', 'Administracion.views.cerrar'),
   url(r'^password/$', 
'django.contrib.auth.views.password_change_done'),

Tambien me surge la duda sobre PasswordChangeForm da el mismo error y por 
ultimo pero no menos importante quisiera saber si existe una forma de 
gestionar los usuarios (eliminar, insertar y modificar) qu no sea 
habilitando el modulo de administracion, lo mismo para los grupos
gracias

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: duda

2013-07-11 Thread Rafael E. Ferrero
Evidentemente tenes un lio de Templates ... no te encuentra el
"registration/password_
change_done.html"

Por la segunda pregunta... con forms hechos a mano supongo? fijate cuando
haces el syncdb y habilitaste el middleware de usuarios te crea las
tablas...
Fijate por acá:
https://docs.djangoproject.com/en/1.5/topics/auth/default/#user-objects


2013/7/11 Ernesto Pulgaron 

> hola, estoy introduciendome en django por lo que tengo algunas dudas,
> quisiera sabes como es que se usa UserChangeForm ya que cdo trato de
> accecer al link de
>  password = ReadOnlyPasswordHashField(label=_("Password"),
> help_text=_("Raw passwords are not stored, so there is no way to
> see "
> "this user's password, but you can change the password
> "
> "using this form."))
>
> me muestra el sgte error :Exception Type: TemplateDoesNotExist
>   Exception
> Value:registration/password_change_done.html
>   Exception Location:
> C:\Python27\lib\site-packages\django\template\loader.py in find_template,
> line 139
>
> esta es mi view.py:
> #Editar usuarios
> @login_required(login_url='/ingresar')
> def editar_usuario(request):
> if request.method == 'POST':
> formulario = UserChangeForm(request.POST)
> if formulario.is_valid():
> formulario.save()
> return HttpResponseRedirect('/')
> else:
> formulario = UserChangeForm()
> return
> render_to_response('nuevousuario.html',{'formulario':formulario},context_instance=RequestContext(request))
>
> el html:
> {% extends 'baseAdmin.html' %}
>
> {% block content %}
> 
> {% csrf_token %}
> 
> {{ formulario }}
> 
> 
> 
> 
> {% endblock %}
>
> el url:
> urlpatterns = patterns('',
>
> url(r'^usuario/nuevo$','Administracion.views.nuevo_usuario'),
>
> url(r'^usuario/editar$','Administracion.views.editar_usuario'),
>url(r'^ingresar/$','Administracion.views.ingresar'),
>url(r'^privado/$','Administracion.views.privado'),
>url(r'^cerrar/$', 'Administracion.views.cerrar'),
>url(r'^password/$',
> 'django.contrib.auth.views.password_change_done'),
>
> Tambien me surge la duda sobre PasswordChangeForm da el mismo error y por
> ultimo pero no menos importante quisiera saber si existe una forma de
> gestionar los usuarios (eliminar, insertar y modificar) qu no sea
> habilitando el modulo de administracion, lo mismo para los grupos
> gracias
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: video app

2013-07-11 Thread Rafael E. Ferrero
XMPP... and have fun!


2013/7/11 Michael Hernandez 

> I am sorry if that response came off a bit rude, I meant totally just to
> help, I am having a stressful day, and just wanted to stress that you
> should breakdown things in your head or on paper, and research the
> individual components.
> There is never a one size fits all solution.
>
>
> On Thu, Jul 11, 2013 at 12:12 PM, Michael Hernandez <
> michael.hernandez1...@gmail.com> wrote:
>
>> There is no package in the world that will do your work for you.
>> What are you trying to do. Limit the scope of your question and then ask
>> for help?
>>
>> Heres some help though.
>>
>> First, divide up your application into high level segments.
>> 1. Chat Application ( if there is text based chat on top of video )
>> 2. Video Application
>>
>> Or if you are just talking webcam chat then your not talking about django
>> anymore really.
>>
>> Lets consider its a webcam chat.
>> 1. Django will serve the views, and create the sockets for chat to occur.
>> 2. Django will manage users. ( You need to create models for this )
>> 3. Django will handle sessions of groups of users chatting )
>>
>> Now how do you want to handle the webcam chat?
>> Do you want to?
>> A. Roll Your own video/audio encoder and your own html5 based player.
>> B. Use a prebuilt flash library
>> C. Research possible Javascript implementations that already exist.
>> D. Something else?
>>
>> This is a difficult project for someone who has to ask the question ("Is
>> there something that does everything that I want")
>>
>>
>>
>> On Mon, Jul 8, 2013 at 3:11 PM, Scheck Nyori wrote:
>>
>>> Hi,
>>> Is there any way then i can make a video chat app in django? I searched
>>> for this package but culdn't find. Please share your views.
>>>
>>> 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 http://groups.google.com/group/django-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Submit a form but stay on the page and the form changes

2013-07-11 Thread Cody Scott
I would like to put a Poll Voting Form on any page like a blog post page or 
the homepage.
Here is the page that I display the form and the view that it gets posted 
to in the form action attribute.
I would like to be able to submit the form but stay on that page and have 
the form change into the results or a link to the results.

class DetailView(PublishedMixin, generic.DetailView):
model = Poll
template_name = 'polls/detail.html'

def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
context['form'] = PollForm(instance=self.get_object())
return context
{% csrf_token 
%}{{form.as_p}}


class VoteView(PublishedMixin, generic.DetailView):
model = Poll

'''def get_form(self, *args, **kwargs):form = 
PollForm(instance=self.get_object())#return super(VoteView, 
self).get_form(*args, **kwargs)return form'''
@property
def success_url(self):
return reverse(
'polls:results', args=(self.get_object().id,))

def post(self, request, *args, **kwargs):
form = PollForm(request.POST, instance=self.get_object())
if form.is_valid():
selected_choice = form.cleaned_data['choice']
selected_choice.votes += 1
selected_choice.save()  


return HttpResponseRedirect(request.META['HTTP_REFERER'])






I also thought about doing a mixin on the page, but I can't just render the 
page with the form attribute equal to something else, becuase I would need to 
redirect to avoid the refresh problem.



class PollFormMixin(SingleObjectMixin):"""puts form and "view results 
link" in contextand validates and saves the form"""model = Poll
def get_context_data(self, **kwargs):context = super(PollFormMixin, 
self).get_context_data(**kwargs)form = 
PollForm(instance=self.get_object())context['form'] = form
return contextdef post(self, request, *args, **kwargs):form = 
PollForm(request.POST, instance=self.get_object())if form.is_valid():   
 form.save()return HttpResponseRedirect(self.success_url)   
 else:return render(request, self.template_name,
{'form': form, 'poll': self.get_object()})


class VoteView(PublishedPollMixin, PollFormMixin, DetailView):"""Vote 
on a poll"""model = Polltemplate_name = 'polls/detail.html'
@propertydef success_url(self):return reverse(
'polls:results', args=(self.get_object().id,))

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




form.errors

2013-07-11 Thread Kakar Arunachal Service
Hi,
I am learning Django from an old Django version book, and i am stuck with a
problem regarding forms. When i render forms, i get the registration right,
but if its incorrect, it does not show the error msg in the html. I tried
{{form.errors}}, but couldn't fix he problem. Please guide me.
Thank you.

This is my forms.py:

from django import forms
import re
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist


class RegistrationForm(forms.Form):
username = forms.CharField(label='Username', max_length=30)
email = forms.EmailField(label="Email",)
password1 = forms.CharField(
label='Password',
widget=forms.PasswordInput()
)
password2 = forms.CharField(
label = 'Password (Again)',
widget=forms.PasswordInput()
)

def clean_password2(self):
if 'password1' in self.cleaned_data:
password1 = self.cleaned_data['password1']
password2 = self.cleaned_data['password2']
if password1 == password2:
return password2
raise forms.ValidationError('Password do not match.')

def clean_username(self):
username = self.cleaned_data['username']
if not re.search(r'^\w+$', username):
raise forms.ValidationError('Username can only contain
alphanumeric characters and the underscore.')
try:
User.objects.get(username=username)
except ObjectDoesNotExist:
return username
raise forms.ValidationError('Username is already taken.')

def clean_email(self):
if 'email' in self.cleaned_data:
email = self.cleaned_data['email']
try:
User.objects.get(email=email)
except ObjectDoesNotExist:
return email
raise forms.ValidationError('Email is already taken.')

And this is my views.py:

def register_page(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(
username=form.cleaned_data['username'],
email=form.cleaned_data['email'],
password=form.cleaned_data['password1']
)
return HttpResponseRedirect('/register/success/')
else:
form = RegistrationForm()
variables = RequestContext(request,{
'form':form
})
return
render_to_response('registration/register.html',variables)
else:
form = RegistrationForm()
variables = RequestContext(request,{
'form':form
})
return render_to_response('registration/register.html',variables)

And my register.html:

{% extends "base.html" %}
{% block title %}User Registration{% endblock %}
{% block head %}User Registration{% endblock %}
{% block content %}

{% csrf_token %}
{{form.as_p}}


{% endblock %}

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: form.errors

2013-07-11 Thread carlos
try this with django 1.5.1
from django.shortcuts import render

def register_page(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/register/success/')
 else:
form = RegistrationForm()
 return render(request, 'registration/register.html', {'form':form})

Cheers


On Thu, Jul 11, 2013 at 4:08 PM, Kakar Arunachal Service <
kakararunachalserv...@gmail.com> wrote:

> Hi,
> I am learning Django from an old Django version book, and i am stuck with
> a problem regarding forms. When i render forms, i get the registration
> right, but if its incorrect, it does not show the error msg in the html. I
> tried {{form.errors}}, but couldn't fix he problem. Please guide me.
> Thank you.
>
> This is my forms.py:
>
> from django import forms
> import re
> from django.contrib.auth.models import User
> from django.core.exceptions import ObjectDoesNotExist
>
>
> class RegistrationForm(forms.Form):
> username = forms.CharField(label='Username', max_length=30)
> email = forms.EmailField(label="Email",)
> password1 = forms.CharField(
> label='Password',
> widget=forms.PasswordInput()
> )
> password2 = forms.CharField(
> label = 'Password (Again)',
> widget=forms.PasswordInput()
> )
>
> def clean_password2(self):
> if 'password1' in self.cleaned_data:
> password1 = self.cleaned_data['password1']
> password2 = self.cleaned_data['password2']
> if password1 == password2:
> return password2
> raise forms.ValidationError('Password do not match.')
>
> def clean_username(self):
> username = self.cleaned_data['username']
> if not re.search(r'^\w+$', username):
> raise forms.ValidationError('Username can only contain
> alphanumeric characters and the underscore.')
> try:
> User.objects.get(username=username)
> except ObjectDoesNotExist:
> return username
> raise forms.ValidationError('Username is already taken.')
>
> def clean_email(self):
> if 'email' in self.cleaned_data:
> email = self.cleaned_data['email']
> try:
> User.objects.get(email=email)
> except ObjectDoesNotExist:
> return email
> raise forms.ValidationError('Email is already taken.')
>
> And this is my views.py:
>
> def register_page(request):
> if request.method == 'POST':
> form = RegistrationForm(request.POST)
> if form.is_valid():
> user = User.objects.create_user(
> username=form.cleaned_data['username'],
> email=form.cleaned_data['email'],
> password=form.cleaned_data['password1']
> )
> return HttpResponseRedirect('/register/success/')
> else:
> form = RegistrationForm()
> variables = RequestContext(request,{
> 'form':form
> })
> return
> render_to_response('registration/register.html',variables)
> else:
> form = RegistrationForm()
> variables = RequestContext(request,{
> 'form':form
> })
> return render_to_response('registration/register.html',variables)
>
> And my register.html:
>
> {% extends "base.html" %}
> {% block title %}User Registration{% endblock %}
> {% block head %}User Registration{% endblock %}
> {% block content %}
> 
> {% csrf_token %}
> {{form.as_p}}
> 
> 
> {% endblock %}
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: form.errors

2013-07-11 Thread Kakar Arunachal Service
I am sorry, but its still not displaying any errors after it renders.


On Fri, Jul 12, 2013 at 3:47 AM, carlos  wrote:

> try this with django 1.5.1
> from django.shortcuts import render
>
> def register_page(request):
> if request.method == 'POST':
> form = RegistrationForm(request.POST)
> if form.is_valid():
> form.save()
>
> return HttpResponseRedirect('/register/success/')
>  else:
> form = RegistrationForm()
>  return render(request, 'registration/register.html', {'form':form})
>
> Cheers
>
>
> On Thu, Jul 11, 2013 at 4:08 PM, Kakar Arunachal Service <
> kakararunachalserv...@gmail.com> wrote:
>
>> Hi,
>> I am learning Django from an old Django version book, and i am stuck with
>> a problem regarding forms. When i render forms, i get the registration
>> right, but if its incorrect, it does not show the error msg in the html. I
>> tried {{form.errors}}, but couldn't fix he problem. Please guide me.
>> Thank you.
>>
>> This is my forms.py:
>>
>> from django import forms
>> import re
>> from django.contrib.auth.models import User
>> from django.core.exceptions import ObjectDoesNotExist
>>
>>
>> class RegistrationForm(forms.Form):
>> username = forms.CharField(label='Username', max_length=30)
>> email = forms.EmailField(label="Email",)
>> password1 = forms.CharField(
>> label='Password',
>> widget=forms.PasswordInput()
>> )
>> password2 = forms.CharField(
>> label = 'Password (Again)',
>> widget=forms.PasswordInput()
>> )
>>
>> def clean_password2(self):
>> if 'password1' in self.cleaned_data:
>> password1 = self.cleaned_data['password1']
>> password2 = self.cleaned_data['password2']
>> if password1 == password2:
>> return password2
>> raise forms.ValidationError('Password do not match.')
>>
>> def clean_username(self):
>> username = self.cleaned_data['username']
>> if not re.search(r'^\w+$', username):
>> raise forms.ValidationError('Username can only contain
>> alphanumeric characters and the underscore.')
>> try:
>> User.objects.get(username=username)
>> except ObjectDoesNotExist:
>> return username
>> raise forms.ValidationError('Username is already taken.')
>>
>> def clean_email(self):
>> if 'email' in self.cleaned_data:
>> email = self.cleaned_data['email']
>> try:
>> User.objects.get(email=email)
>> except ObjectDoesNotExist:
>> return email
>> raise forms.ValidationError('Email is already taken.')
>>
>> And this is my views.py:
>>
>> def register_page(request):
>> if request.method == 'POST':
>> form = RegistrationForm(request.POST)
>> if form.is_valid():
>> user = User.objects.create_user(
>> username=form.cleaned_data['username'],
>> email=form.cleaned_data['email'],
>> password=form.cleaned_data['password1']
>> )
>> return HttpResponseRedirect('/register/success/')
>> else:
>> form = RegistrationForm()
>> variables = RequestContext(request,{
>> 'form':form
>> })
>> return
>> render_to_response('registration/register.html',variables)
>> else:
>> form = RegistrationForm()
>> variables = RequestContext(request,{
>> 'form':form
>> })
>> return render_to_response('registration/register.html',variables)
>>
>> And my register.html:
>>
>> {% extends "base.html" %}
>> {% block title %}User Registration{% endblock %}
>> {% block head %}User Registration{% endblock %}
>> {% block content %}
>> 
>> {% csrf_token %}
>> {{form.as_p}}
>> 
>> 
>> {% endblock %}
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop recei

Re: form.errors

2013-07-11 Thread Kakar Arunachal Service
Its just displaying form again, but without any errors. Please guide me to
where am missing something.


On Fri, Jul 12, 2013 at 4:34 AM, Kakar Arunachal Service <
kakararunachalserv...@gmail.com> wrote:

> I am sorry, but its still not displaying any errors after it renders.
>
>
> On Fri, Jul 12, 2013 at 3:47 AM, carlos  wrote:
>
>> try this with django 1.5.1
>> from django.shortcuts import render
>>
>> def register_page(request):
>> if request.method == 'POST':
>> form = RegistrationForm(request.POST)
>> if form.is_valid():
>> form.save()
>>
>> return HttpResponseRedirect('/register/success/')
>>  else:
>> form = RegistrationForm()
>>  return render(request, 'registration/register.html', {'form':form})
>>
>> Cheers
>>
>>
>>  On Thu, Jul 11, 2013 at 4:08 PM, Kakar Arunachal Service <
>> kakararunachalserv...@gmail.com> wrote:
>>
>>>  Hi,
>>> I am learning Django from an old Django version book, and i am stuck
>>> with a problem regarding forms. When i render forms, i get the registration
>>> right, but if its incorrect, it does not show the error msg in the html. I
>>> tried {{form.errors}}, but couldn't fix he problem. Please guide me.
>>> Thank you.
>>>
>>> This is my forms.py:
>>>
>>> from django import forms
>>> import re
>>> from django.contrib.auth.models import User
>>> from django.core.exceptions import ObjectDoesNotExist
>>>
>>>
>>> class RegistrationForm(forms.Form):
>>> username = forms.CharField(label='Username', max_length=30)
>>> email = forms.EmailField(label="Email",)
>>> password1 = forms.CharField(
>>> label='Password',
>>> widget=forms.PasswordInput()
>>> )
>>> password2 = forms.CharField(
>>> label = 'Password (Again)',
>>> widget=forms.PasswordInput()
>>> )
>>>
>>> def clean_password2(self):
>>> if 'password1' in self.cleaned_data:
>>> password1 = self.cleaned_data['password1']
>>> password2 = self.cleaned_data['password2']
>>> if password1 == password2:
>>> return password2
>>> raise forms.ValidationError('Password do not match.')
>>>
>>> def clean_username(self):
>>> username = self.cleaned_data['username']
>>> if not re.search(r'^\w+$', username):
>>> raise forms.ValidationError('Username can only contain
>>> alphanumeric characters and the underscore.')
>>> try:
>>> User.objects.get(username=username)
>>> except ObjectDoesNotExist:
>>> return username
>>> raise forms.ValidationError('Username is already taken.')
>>>
>>> def clean_email(self):
>>> if 'email' in self.cleaned_data:
>>> email = self.cleaned_data['email']
>>> try:
>>> User.objects.get(email=email)
>>> except ObjectDoesNotExist:
>>> return email
>>> raise forms.ValidationError('Email is already taken.')
>>>
>>> And this is my views.py:
>>>
>>> def register_page(request):
>>> if request.method == 'POST':
>>> form = RegistrationForm(request.POST)
>>> if form.is_valid():
>>> user = User.objects.create_user(
>>> username=form.cleaned_data['username'],
>>> email=form.cleaned_data['email'],
>>> password=form.cleaned_data['password1']
>>> )
>>> return HttpResponseRedirect('/register/success/')
>>> else:
>>> form = RegistrationForm()
>>> variables = RequestContext(request,{
>>> 'form':form
>>> })
>>> return
>>> render_to_response('registration/register.html',variables)
>>> else:
>>> form = RegistrationForm()
>>> variables = RequestContext(request,{
>>> 'form':form
>>> })
>>> return render_to_response('registration/register.html',variables)
>>>
>>> And my register.html:
>>>
>>> {% extends "base.html" %}
>>> {% block title %}User Registration{% endblock %}
>>> {% block head %}User Registration{% endblock %}
>>> {% block content %}
>>> 
>>> {% csrf_token %}
>>> {{form.as_p}}
>>> 
>>> 
>>> {% endblock %}
>>>
>>> --
>>> 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.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> 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

Unable to get python manage.py runserver to work

2013-07-11 Thread Yves S. Garret
I was able to import django from inside of python 2.6.6 (which is what I'm
going with
at the moment).  However, when I try to display something in a browser,
this is the
problem that I'm getting:

$ python /path/to/file/manage.py runserver
Traceback (most recent call last):
  File
"/home/azureuser/Downloads/django/Django-1.5.1/django/conf/project_template/manage.py",
line 10, in 
execute_from_command_line(sys.argv)
  File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line
453, in execute_from_command_line
utility.execute()
  File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line
392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line
263, in fetch_command
app_name = get_commands()[subcommand]
  File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line
109, in get_commands
apps = settings.INSTALLED_APPS
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 53,
in __getattr__
self._setup(name)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 48,
in _setup
self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line
134, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?):
%s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings '{{ project_name }}.settings' (Is it
on sys.path?): No module named {{ project_name }}.settings

What am I screwing up?

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Unable to get python manage.py runserver to work

2013-07-11 Thread Yves S. Garret
Note, I'm trying to avoid using a database.  I'm, ultimately, planning on 
getting
Django Dynamic Scraper to work and figured that this is a good first step.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Unable to get python manage.py runserver to work

2013-07-11 Thread Kamal Kaur
On Fri, Jul 12, 2013 at 8:31 AM, Yves S. Garret
 wrote:
> What am I screwing up?

Try using quote:
[...] project_name.settings [...]

instead of
[...] {{ project_name }}.settings [...]



--
Kamaljeet Kaur

Blog:http://kamalkaur188.wordpress.com/

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Unable to get python manage.py runserver to work

2013-07-11 Thread Mike Dewhirst

On 12/07/2013 1:01pm, Yves S. Garret wrote:

I was able to import django from inside of python 2.6.6 (which is what
I'm going with
at the moment).  However, when I try to display something in a browser,
this is the
problem that I'm getting:

$ python /path/to/file/manage.py runserver
Traceback (most recent call last):
   File
"/home/azureuser/Downloads/django/Django-1.5.1/django/conf/project_template/manage.py",


The problem reported in the traceback indicates the path to your app 
isn't in sys.path


Try cd'ing into the directory containing manage.py [1] so the path 
automatically gets put into sys.pth then ...


$ python manage.py runserver

That should get the dev server running and you browser should display 
something useful at http://localhost:8000/


[1] https://docs.djangoproject.com/en/1.5/intro/tutorial01/


line 10, in 
 execute_from_command_line(sys.argv)
   File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 453, in execute_from_command_line
 utility.execute()
   File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 392, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 263, in fetch_command
 app_name = get_commands()[subcommand]
   File
"/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 109, in get_commands
 apps = settings.INSTALLED_APPS
   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line
53, in __getattr__
 self._setup(name)
   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line
48, in _setup
 self._wrapped = Settings(settings_module)
   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line
134, in __init__
 raise ImportError("Could not import settings '%s' (Is it on
sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings '{{ project_name }}.settings' (Is
it on sys.path?): No module named {{ project_name }}.settings

What am I screwing up?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.




--
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.
For more options, visit https://groups.google.com/groups/opt_out.




how can an abstract class know which class inherits it

2013-07-11 Thread Mike Dewhirst
I have four models, all of which inherit the fields and methods of a 
single abstract model.


For one of those abstract fields, I would like help_text to vary 
depending on which model has inherited it.


Is this possible?

If so, how can I do it?

Thanks

Mike

--
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.
For more options, visit https://groups.google.com/groups/opt_out.