Change link on img in template using forms

2016-07-09 Thread Dariusz Mysior
How in template.html change link  on . 

Zdjecie: Teraz: avatar/n.jpg

In forms.py like below I see that I can change label name, but how can I do 
this with  ???

class MysiteUserForm(forms.ModelForm):
#age  = 
forms.IntegerField(min_value=1, max_value=99, 
widget=forms.NumberInput(attrs={}))
#avatar  = 
forms.ImageField()
class Meta:
model = MysiteUser
fields = ['sex','age','province','city','martial_status','religion',
'kids','education',
  'are_smoke','are_drink','avatar']
labels = {
'avatar': _('Zdjecie'),
}


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


Try delete image file

2016-06-15 Thread Dariusz Mysior
I want change image and delete this changed when i save this new. I write 
delete method like below but it is not work, what is wrong?

models.py

from django.db import models
from django.contrib.auth.models import AbstractUser
from django.core.validators import MaxValueValidator, MinValueValidator
##

class MysiteUser(AbstractUser):
SINGLE = 'SI'
MARRIED = 'MA'
WIDOW = 'WI'
DIVORCEE = 'DI'
MARTIAL_STATUS = (
(SINGLE, 'kawaler'),
(MARRIED, 'zamężna/żonaty'),
(WIDOW, 'wdowiec/wdowa'),
(DIVORCEE, 'rozwodnik')
)
WOMAN = 'WO'
MAN = 'MA'
SEX = (
(WOMAN, 'kobieta'),
(MAN, 'mężczyzna')
)
DOLNOSLASKIE = 'DO'
KUJAWSKO_POMORSKIE = 'KP'
LUBELSKIE = 'LE'
LUBUSKIE = 'LU'
LODZKIE = 'LO'
MALOPOLSKIE = 'MA'
MAZOWIECKIE = 'MZ'
OPOLSKIE = 'OP'
PODKARPACKIE = 'PO'
PODLASKIE = 'PD'
POMORSKIE = 'PM'
SLASKIE = 'SL'
SWIETOKRZYSKIE = 'SW'
WARMINSKO_MAZURSKIE = 'WM'
WIELKOPOLSKIE = 'WI'
ZACHODNIOPOMORSKIE = 'ZA'
PROVINCE = (
(DOLNOSLASKIE, 'dolnośląskie'),
(KUJAWSKO_POMORSKIE, 'kujawsko-pomorskie'),
(LUBELSKIE, 'lubelskie'),
(LUBUSKIE, 'lubuskie'),
(LODZKIE, 'łódzkie'),
(MALOPOLSKIE, 'małopolskie'),
(MAZOWIECKIE, 'mazowieckie'),
(OPOLSKIE, 'opolskie'),
(PODKARPACKIE, 'podkarpackie'),
(PODLASKIE, 'podlaskie'),
(POMORSKIE, 'pomorskie'),
(SLASKIE, 'śląskie'),
(SWIETOKRZYSKIE, 'świętokrzyskie'),
(WARMINSKO_MAZURSKIE, 'warmińsko-mazurskie'),
(WIELKOPOLSKIE, 'wielkopolskie'),
(ZACHODNIOPOMORSKIE, 'zachodniopomorskie')
)
PODSTAWOWE = 'PO'
SREDNIE = 'SR'
WYZSZE = 'WY'
EDUCATION = (
(PODSTAWOWE,'podstawowe'),
(SREDNIE,'średnie'),
(WYZSZE,'wyższe'),
)
KATOLIK = 'KA'
PRAWOSLAWNY = 'PR'
PROTESTANT = 'PO'
BUDDYZM = 'BU'
ISLAM = 'IS'
ATEISTA = 'AT'
INNA_RELIGIA = 'IN'
RELIGION = (
(KATOLIK, 'katolik'),
(PRAWOSLAWNY, 'prawosławny'),
(PROTESTANT, 'protestant'),
(BUDDYZM, 'buddyzm'),
(ISLAM, 'islam'),
(ATEISTA, 'ateista'),
(INNA_RELIGIA, 'inna religia')
)
YES = 'YS'
NO = 'NO'
CHOICES = (
(YES, 'tak'),
(NO, 'nie')
)

sex = models.CharField(blank=False, max_length=20, choices=SEX, 
default=WOMAN)
avatar = models.ImageField(upload_to="avatar", null=True, blank=True)
age = models.PositiveSmallIntegerField(null=True, blank=True, 
validators=[MinValueValidator(1), MaxValueValidator(100)])
joined_time = models.DateTimeField(auto_now_add=True)
martial_status = models.CharField(max_length=20, choices=MARTIAL_STATUS, 
default=SINGLE)
province = models.CharField(max_length=20, choices=PROVINCE, 
default=DOLNOSLASKIE)
city = models.CharField(max_length=30)
education = models.CharField(max_length=20, choices=EDUCATION, 
default=PODSTAWOWE)
religion = models.CharField(max_length=20, choices=RELIGION, 
default=KATOLIK)
kids = models.NullBooleanField(blank=True, choices=CHOICES)
are_smoke = models.NullBooleanField(blank=True, choices=CHOICES)
are_drink = models.NullBooleanField(blank=True, choices=CHOICES)
def __str__(self):
return self.username

   def delete(self):
MysiteUser.objects.filter(avatar = self).delete()
self.avatar.delete()
return super(MysiteUser,self).delete()

def save(self):
self.delete()
return super(MysiteUser, self).save()



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


UpdateView - problem with change model

2016-05-28 Thread Dariusz Mysior
I have that problem when I change model in view class EditView on 
PersonalInfo I have response that "Not found personal info that meet your 
criteria" when I have model = MysiteUser than it is ok but when I change on 
model = PersonalInfo than it's a problem.

views.py

from django.contrib.messages.views import SuccessMessageMixin
from django.views.generic import TemplateView, UpdateView
from users.models import MysiteUser, PersonalInfo

class ProfileView(TemplateView):
template_name = 'profile.html'

class EditView(SuccessMessageMixin, UpdateView):
model = PersonalInfo
fields = ['age']
pk_url_kwarg = 'pk'
template_name = 'update_form.html'
success_url = '/myprofile/'
success_message = "Zmiany zostały wprowadzone."


models.py

from django.db import models
from django.contrib.auth.models import AbstractUser

##

class MysiteUser(AbstractUser):
avatar = models.ImageField(upload_to="avatar")
#age = models.IntegerField()

def __str__(self):
return self.username

class PersonalInfo(models.Model):
mysiteuser = models.OneToOneField(MysiteUser)
age = models.IntegerField()



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


Re: UpdateView not saved

2016-05-27 Thread Dariusz Mysior
Yes it help :), thanks!

W dniu piątek, 27 maja 2016 16:29:37 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I try update my photo in avatar field but it not save changes, please look 
> on it
>
> update_form.html
>
> {% extends 'base.html' %}
> {% block title %}Edycja profilu{% endblock %}
>
>
> {% if user.is_authenticated %}
> {% block top_menu %}
> {{ user.username }}
> Wyloguj się
> {% endblock %}
>
> {% block content %}
> 
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
> {% endblock %}
> {% else %}
>
> {% endif %}
>
>
> views.py
>
> from django.shortcuts import render
> from django.views.generic import TemplateView, UpdateView
> from users.models import MysiteUser
>
> class ProfileView(TemplateView):
> template_name = 'profile.html'
>
> class EditView(UpdateView):
> model = MysiteUser
> fields = ['avatar']
> pk_url_kwarg = 'pk'
> template_name = 'update_form.html'
> success_url = '/myprofile/'
>
> def form_valid(self, form):
> self.object = form.save()
> return super(EditView,self).form_valid(form)
>
>
> models.py
>
> from django.db import models
> from django.contrib.auth.models import AbstractUser
>
> ##
>
> class MysiteUser(AbstractUser):
> avatar = models.ImageField(upload_to="avatar")
>
> def __str__(self):
> return self.username
>
>
>
>

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


UpdateView not saved

2016-05-27 Thread Dariusz Mysior
I try update my photo in avatar field but it not save changes, please look 
on it

update_form.html

{% extends 'base.html' %}
{% block title %}Edycja profilu{% endblock %}


{% if user.is_authenticated %}
{% block top_menu %}
{{ user.username }}
Wyloguj się
{% endblock %}

{% block content %}

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


{% endblock %}
{% else %}

{% endif %}


views.py

from django.shortcuts import render
from django.views.generic import TemplateView, UpdateView
from users.models import MysiteUser

class ProfileView(TemplateView):
template_name = 'profile.html'

class EditView(UpdateView):
model = MysiteUser
fields = ['avatar']
pk_url_kwarg = 'pk'
template_name = 'update_form.html'
success_url = '/myprofile/'

def form_valid(self, form):
self.object = form.save()
return super(EditView,self).form_valid(form)


models.py

from django.db import models
from django.contrib.auth.models import AbstractUser

##

class MysiteUser(AbstractUser):
avatar = models.ImageField(upload_to="avatar")

def __str__(self):
return self.username



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


Re: template not see img from Imagefiles

2016-05-13 Thread Dariusz Mysior
Ok I have it 

urls

url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': 
settings.MEDIA_ROOT,}),


settings

PROJECT_ROOT = os.path.join(os.path.dirname(__file__), '..')
SITE_ROOT = PROJECT_ROOT
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media')
MEDIA_URL = '/media/'



W dniu piątek, 13 maja 2016 21:46:03 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I can't find where is a problem, I try show in template image and he don't 
> show it. Please help...
>
> my code
>
> models
>
> from django.db import models
> from django.contrib.auth.models import AbstractUser
>
> ##
>
> class MysiteUser(AbstractUser):
> avatar = models.ImageField(upload_to="avatar")
>
> def __str__(self):
> return self.username
>
>
>
> template
>
> 
> 
> 
> 
> 
> 
> 
> {% load staticfiles %}
>
> {% block content %}
> {% if user.is_authenticated %}
> Mój profil  {{ user.username }} 
>  border="1" />
> Wyloguj się
> {% else %}
> {% block logout %}
> Nie jesteś zalogowany
>
> {% endblock %}
> {% endif %}
> {% endblock %}
> 
> 
>
>
>
> url
>
> from django.conf.urls import  include, url
> from django.contrib import admin
> from users.views import LoginView
> from django.conf import settings
> from django.conf.urls.static import static
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
> url(r'^users/', include('users.urls', namespace='users')),
> url(r'^$', LoginView.as_view(), name='login-view'),
>
>
> ]
>
> static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
>
>
>
> settings
>
> MEDIA_ROOT = '/mysite/media/'
> MEDIA_URL = '/media/'
>
> STATIC_URL = '/static/'
>
>

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


template not see img from Imagefiles

2016-05-13 Thread Dariusz Mysior
I can't find where is a problem, I try show in template image and he don't 
show it. Please help...

my code

models

from django.db import models
from django.contrib.auth.models import AbstractUser

##

class MysiteUser(AbstractUser):
avatar = models.ImageField(upload_to="avatar")

def __str__(self):
return self.username



template








{% load staticfiles %}

{% block content %}
{% if user.is_authenticated %}
Mój profil  {{ user.username }} 

Wyloguj się
{% else %}
{% block logout %}
Nie jesteś zalogowany

{% endblock %}
{% endif %}
{% endblock %}





url

from django.conf.urls import  include, url
from django.contrib import admin
from users.views import LoginView
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^users/', include('users.urls', namespace='users')),
url(r'^$', LoginView.as_view(), name='login-view'),


]

static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)



settings

MEDIA_ROOT = '/mysite/media/'
MEDIA_URL = '/media/'

STATIC_URL = '/static/'

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


Re: Add id to url after login user

2016-04-30 Thread Dariusz Mysior
I have now code like below and I have message. I try split success_url with 
id number and compare it with urls.py 


AttributeError at /users/login/ 
>
> 'int' object has no attribute 'get'
>
>

views.py

class LoginView(FormView):
template_name = 'login_form.html'
model = MysiteUser
form_class = AuthenticationForm

def form_valid(self, form):
x = form.get_user_id()
return x
def get_success_url(self):
x = self.x
success_url = '/users/profile/{}'.format(x)
return success_url




W dniu piątek, 29 kwietnia 2016 09:36:30 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use FormView do login user, but I don't know how I should add his ID 
> number to success url that when he will log in adres will be 
> users/profile/id
>
> urls.py
>
> from users.views import RegisterView, LoginView, ProfileView
>
> urlpatterns = [
>
> url(r'^register/$', RegisterView.as_view(), name='register-view'),
> url(r'^login/$', LoginView.as_view(), name='login-view'),
> url(r'^profile/(?P\d+)/$', ProfileView.as_view(), 
> name='profile-view'),
>
>
>
> views.py
>
> class LoginView(FormView):
> template_name = 'login_form.html'
> model = MysiteUser
> form_class = AuthenticationForm
> success_url = '/users/profile/'
>
>
urls.py

from django.conf.urls import   url
from users.views import RegisterView, LoginView, ProfileView

urlpatterns = [

url(r'^register/$', RegisterView.as_view(), name='register-view'),
url(r'^login/$', LoginView.as_view(), name='login-view'),
url(r'^profile/(?P[0-9]+)/$', ProfileView.as_view(), 
name='profile-view'),

]


 

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


Re: Add id to url after login user

2016-04-29 Thread Dariusz Mysior
Sory I thought that You are from Poland like I :)

Hmm I try Your code but there is comment 

name 'request' is not defined


W dniu piątek, 29 kwietnia 2016 09:36:30 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use FormView do login user, but I don't know how I should add his ID 
> number to success url that when he will log in adres will be 
> users/profile/id
>
> urls.py
>
> from users.views import RegisterView, LoginView, ProfileView
>
> urlpatterns = [
>
> url(r'^register/$', RegisterView.as_view(), name='register-view'),
> url(r'^login/$', LoginView.as_view(), name='login-view'),
> url(r'^profile/(?P\d+)/$', ProfileView.as_view(), 
> name='profile-view'),
>
>
>
> views.py
>
> class LoginView(FormView):
> template_name = 'login_form.html'
> model = MysiteUser
> form_class = AuthenticationForm
> success_url = '/users/profile/'
>
>

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


Re: Add id to url after login user

2016-04-29 Thread Dariusz Mysior
Hej ja po angielsku słabo piszę, chciałem się nauczyć Class Based View i na 
tym zrobić system rejestracji, masz pomysł jak to dalej zrobić? Chciałbym 
wyciagnąć pk i dodać do adresu succes_url...

W dniu piątek, 29 kwietnia 2016 09:36:30 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use FormView do login user, but I don't know how I should add his ID 
> number to success url that when he will log in adres will be 
> users/profile/id
>
> urls.py
>
> from users.views import RegisterView, LoginView, ProfileView
>
> urlpatterns = [
>
> url(r'^register/$', RegisterView.as_view(), name='register-view'),
> url(r'^login/$', LoginView.as_view(), name='login-view'),
> url(r'^profile/(?P\d+)/$', ProfileView.as_view(), 
> name='profile-view'),
>
>
>
> views.py
>
> class LoginView(FormView):
> template_name = 'login_form.html'
> model = MysiteUser
> form_class = AuthenticationForm
> success_url = '/users/profile/'
>
>

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


Re: Add id to url after login user

2016-04-29 Thread Dariusz Mysior
Hi I try learn Django, and I want do authenticated system in CBV. My nxt 
try is that I wright it like below but in url adrees instead of id number I 
have "None" :/

 success_url = '/users/profile/'+ str(MysiteUser.pk)


W dniu piątek, 29 kwietnia 2016 09:36:30 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use FormView do login user, but I don't know how I should add his ID 
> number to success url that when he will log in adres will be 
> users/profile/id
>
> urls.py
>
> from users.views import RegisterView, LoginView, ProfileView
>
> urlpatterns = [
>
> url(r'^register/$', RegisterView.as_view(), name='register-view'),
> url(r'^login/$', LoginView.as_view(), name='login-view'),
> url(r'^profile/(?P\d+)/$', ProfileView.as_view(), 
> name='profile-view'),
>
>
>
> views.py
>
> class LoginView(FormView):
> template_name = 'login_form.html'
> model = MysiteUser
> form_class = AuthenticationForm
> success_url = '/users/profile/'
>
>

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


Add id to url after login user

2016-04-29 Thread Dariusz Mysior
I use FormView do login user, but I don't know how I should add his ID 
number to success url that when he will log in adres will be 
users/profile/id

urls.py

from users.views import RegisterView, LoginView, ProfileView

urlpatterns = [

url(r'^register/$', RegisterView.as_view(), name='register-view'),
url(r'^login/$', LoginView.as_view(), name='login-view'),
url(r'^profile/(?P\d+)/$', ProfileView.as_view(), 
name='profile-view'),



views.py

class LoginView(FormView):
template_name = 'login_form.html'
model = MysiteUser
form_class = AuthenticationForm
success_url = '/users/profile/'

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


Pycharm and DJANGO_SETTINGS_MODULE

2016-04-07 Thread Dariusz Mysior
Hi in linux console it's ok but in Pycharm in IPython console when I 
execute f.e. from django.contrib.auth.models import AbstractUser i have bug 
like below


django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but 
> settings are not configured. You must either define the environment 
> variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
> accessing settings.
>
>
In Run Configuration in environment paramets I have DJANGO_SETTINGS_MODULE 
with mysite.settings, wsgi and manage also have this info, where can I 
check it else...

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


Re: Problem with create new instance

2016-03-09 Thread Dariusz Mysior
Ok I have it. I put it to starting scripts

W dniu środa, 9 marca 2016 18:48:15 UTC+1 użytkownik Dariusz Mysior napisał:
>
> I have Django 1.8 Python 3.4 
>
> My app contact. I have model and form like below and when I run command 
>
>  
>
>> from contact.forms import MessageForm
>>
>  and next 
>
>> form = MessageForm()
>>
>
> I have error
>
> In[2]: from contact.forms import MessageForm
>>> In[3]: form = MessageForm()
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 161, in _add_installed_apps_translations
>>> app_configs = reversed(list(apps.get_app_configs()))
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 137, in get_app_configs
>>> self.check_apps_ready()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 124, in check_apps_ready
>>> raise AppRegistryNotReady("Apps aren't loaded yet.")
>>> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>>>
>>> During handling of the above exception, another exception occurred:
>>>
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/IPython/core/interactiveshell.py",
>>>  
>>> line 3066, in run_code
>>> exec(code_obj, self.user_global_ns, self.user_ns)
>>>   File "", line 1, in 
>>> form = MessageForm()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/models.py",
>>>  
>>> line 329, in __init__
>>> error_class, label_suffix, empty_permitted)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/forms.py",
>>>  
>>> line 129, in __init__
>>> self.label_suffix = label_suffix if label_suffix is not None else 
>>> _(':')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/__init__.py",
>>>  
>>> line 84, in ugettext
>>> return _trans.ugettext(message)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 317, in gettext
>>> return do_translate(message, 'gettext')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 300, in do_translate
>>> _default = _default or translation(settings.LANGUAGE_CODE)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 206, in translation
>>> _translations[language] = DjangoTranslation(language)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 116, in __init__
>>> self._add_installed_apps_translations()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 164, in _add_installed_apps_translations
>>> "The translation infrastructure cannot be initialized before the "
>>> 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.
>>
>>
> models.py
>  
>
> from django.db import models
>
> # Create your models here.
>
> class Message(models.Model):
> name = models.CharField(max_length=250)
> email = models.EmailField()
> message = models.TextField()
>
> def __str__(self):
> return "message from {name}".format(name=self.name)
>
>
>
>
> forms.py
>
> #!/usr/bin/env python
> from django import forms
> from .models import Message
>
> class MessageForm(forms.ModelForm):
> class Meta:
> model = Message
> fields = ['name', 'email', 'message']
>
>
>
>
>

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


Re: Problem with create new instance

2016-03-09 Thread Dariusz Mysior
I found that when I write import django and next django.setup() to terminal 
than it works. But next question, when I put it to automaticly run it...

W dniu środa, 9 marca 2016 18:48:15 UTC+1 użytkownik Dariusz Mysior napisał:
>
> I have Django 1.8 Python 3.4 
>
> My app contact. I have model and form like below and when I run command 
>
>  
>
>> from contact.forms import MessageForm
>>
>  and next 
>
>> form = MessageForm()
>>
>
> I have error
>
> In[2]: from contact.forms import MessageForm
>>> In[3]: form = MessageForm()
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 161, in _add_installed_apps_translations
>>> app_configs = reversed(list(apps.get_app_configs()))
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 137, in get_app_configs
>>> self.check_apps_ready()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 124, in check_apps_ready
>>> raise AppRegistryNotReady("Apps aren't loaded yet.")
>>> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>>>
>>> During handling of the above exception, another exception occurred:
>>>
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/IPython/core/interactiveshell.py",
>>>  
>>> line 3066, in run_code
>>> exec(code_obj, self.user_global_ns, self.user_ns)
>>>   File "", line 1, in 
>>> form = MessageForm()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/models.py",
>>>  
>>> line 329, in __init__
>>> error_class, label_suffix, empty_permitted)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/forms.py",
>>>  
>>> line 129, in __init__
>>> self.label_suffix = label_suffix if label_suffix is not None else 
>>> _(':')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/__init__.py",
>>>  
>>> line 84, in ugettext
>>> return _trans.ugettext(message)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 317, in gettext
>>> return do_translate(message, 'gettext')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 300, in do_translate
>>> _default = _default or translation(settings.LANGUAGE_CODE)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 206, in translation
>>> _translations[language] = DjangoTranslation(language)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 116, in __init__
>>> self._add_installed_apps_translations()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 164, in _add_installed_apps_translations
>>> "The translation infrastructure cannot be initialized before the "
>>> 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.
>>
>>
> models.py
>  
>
> from django.db import models
>
> # Create your models here.
>
> class Message(models.Model):
> name = models.CharField(max_length=250)
> email = models.EmailField()
> message = models.TextField()
>
> def __str__(self):
> return "message from {name}".format(name=self.name)
>
>
>
>
> forms.py
>
> #!/usr/bin/env python
> from django import forms
> from .models import Message
>
> class MessageForm(forms.ModelForm):
> class Meta:
> model = Message
> fields = ['name', 'email', 'message']
>
>
>
>
>

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


Problem with create new instance

2016-03-09 Thread Dariusz Mysior
I have Django 1.8 Python 3.4 

My app contact. I have model and form like below and when I run command 

 

> from contact.forms import MessageForm
>
 and next 

> form = MessageForm()
>

I have error

In[2]: from contact.forms import MessageForm
>> In[3]: form = MessageForm()
>> Traceback (most recent call last):
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 161, in _add_installed_apps_translations
>> app_configs = reversed(list(apps.get_app_configs()))
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>  
>> line 137, in get_app_configs
>> self.check_apps_ready()
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>  
>> line 124, in check_apps_ready
>> raise AppRegistryNotReady("Apps aren't loaded yet.")
>> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/IPython/core/interactiveshell.py",
>>  
>> line 3066, in run_code
>> exec(code_obj, self.user_global_ns, self.user_ns)
>>   File "", line 1, in 
>> form = MessageForm()
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/models.py",
>>  
>> line 329, in __init__
>> error_class, label_suffix, empty_permitted)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/forms.py",
>>  
>> line 129, in __init__
>> self.label_suffix = label_suffix if label_suffix is not None else 
>> _(':')
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/__init__.py",
>>  
>> line 84, in ugettext
>> return _trans.ugettext(message)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 317, in gettext
>> return do_translate(message, 'gettext')
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 300, in do_translate
>> _default = _default or translation(settings.LANGUAGE_CODE)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 206, in translation
>> _translations[language] = DjangoTranslation(language)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 116, in __init__
>> self._add_installed_apps_translations()
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 164, in _add_installed_apps_translations
>> "The translation infrastructure cannot be initialized before the "
>> 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.
>
>
models.py
 

from django.db import models

# Create your models here.

class Message(models.Model):
name = models.CharField(max_length=250)
email = models.EmailField()
message = models.TextField()

def __str__(self):
return "message from {name}".format(name=self.name)




forms.py

#!/usr/bin/env python
from django import forms
from .models import Message

class MessageForm(forms.ModelForm):
class Meta:
model = Message
fields = ['name', 'email', 'message']




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


Re: Problem with DJANGO_SETTINGS_MODULE

2016-03-07 Thread Dariusz Mysior
When I use Console system it work's using manage shell and next import but 
in PyCharm Edu 2 in Python Console I have this message like below I wright. 
In PyCharm Ipython run automaticly I am not using manage shell command. How 
can I set it in PyCharm?

W dniu poniedziałek, 7 marca 2016 20:34:42 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I use Django 1.8 Python 3.4.3 and I have problem when i go to Ipython or 
> Python and I try use command from contact.forms import MessageForm2 I have 
> a error like below. I add that in wsgi.py and manage.py I have line 
>
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "biblio.settings")
>
> where biblio is my main project name
>
>
>
> Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not 
>> configured. You must either define the environment variable 
>> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
>> settings.
>>
>
>

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


Problem with DJANGO_SETTINGS_MODULE

2016-03-07 Thread Dariusz Mysior
I use Django 1.8 Python 3.4.3 and I have problem when i go to Ipython or 
Python and I try use command from contact.forms import MessageForm2 I have 
a error like below. I add that in wsgi.py and manage.py I have line 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "biblio.settings")

where biblio is my main project name



Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not 
> configured. You must either define the environment variable 
> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
> settings.
>

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


How change info about register user

2015-12-30 Thread Dariusz Mysior
In Django\contrib\auth\forms.py I have clas like below. When I use it and 
create a form to register a user with fields user, password, confirm 
password I have also info about correct characters to register user. How 
can I change this info?

class UserCreationForm(forms.ModelForm):
"""
A form that creates a user, with no privileges, from the given username and
password.
"""
error_messages = {
'password_mismatch': _("The two password fields didn't match."),
}
password1 = forms.CharField(label=_("Password"),
widget=forms.PasswordInput)
password2 = forms.CharField(label=_("Password confirmation"),
widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification."))

class Meta:
model = User
fields = ("username",)

def clean_password2(self):
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError(
self.error_messages['password_mismatch'],
code='password_mismatch',
)
return password2

def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
return user



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


Where can I write subclass to oryginal form

2015-12-19 Thread Dariusz Mysior
 

I want manage form's properties.


I have a question, where I must write a subclass to UserCreationForm.

In oryginal file "form" i directory ...site-packages\django\contrib\auth ???

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


Re: Problem with a view - MultiValueDictKeyError

2015-12-18 Thread Dariusz Mysior
Hmm I split index view on two views index and register_user and now it is 
ok heh.

W dniu czwartek, 17 grudnia 2015 22:16:33 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I have this view and I have a bug why?
>
> def index(request):
> # jezeli formularz coś wysłał
> if request.method == 'POST':
> form_r = UserCreationForm(request.POST)
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
>
> # jezeli uzytkownik istnieje
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('profile')
>
> else:
> # Return a 'disabled account' error message
> ...
> else:
> # Return an 'invalid login' error message.
> return HttpResponseRedirect('invalid_login')
> if form_r.is_valid():
> form_r.save()
> info="Zarejestrowałeś się!"
> return render_to_response('ownsite/register_success.html', 
> {info:'info'})
> else:
> return HttpResponseRedirect('/')
> # tworze formularze
> args = {}
> args.update(csrf(request))
> args['form_l'] = AuthenticationForm()
> args['form_r']= UserCreationForm()
>
> return render_to_response('index.html', args)
>
>
> A bug
>
>
> MultiValueDictKeyError at / 
>>
>> "'password'"
>>
>> Request Method: POST Request URL: http://127.0.0.1:8000/ Django Version: 
>> 1.8.4 Exception Type: MultiValueDictKeyError Exception Value: 
>>
>> "'password'"
>>
>> Exception Location: 
>> C:\Python34\lib\site-packages\django\utils\datastructures.py 
>> in __getitem__, line 322 Python Executable: C:\Python34\python.exe Python 
>> Version: 3.4.3 Python Path: 
>>
>> ['C:\\Python34\\ownsite',
>>  'C:\\WINDOWS\\SYSTEM32\\python34.zip',
>>  'C:\\Python34\\DLLs',
>>  'C:\\Python34\\lib',
>>  'C:\\Python34',
>>  'C:\\Python34\\lib\\site-packages']
>>
>> Server time: Czw, 17 Gru 2015 22:07:11 +0100
>
>
>

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


Re: Problem with a view - MultiValueDictKeyError

2015-12-18 Thread Dariusz Mysior
My template looks like below but I changed someting in View and than I had 
this error

{% load staticfiles %}




{% block title %}{% endblock %}







{% block header %}
{% if user.is_authenticated %}
Jesteś  zalogowany {{ user.username }}
wyloguj
{% else %}
Login
{% csrf_token %}
{{ form_l.as_p }}


{% endif %}
{% endblock %}


{% block content %}

{% block left_content %}
{% if user.is_authenticated %}
Jesteś zalogowany
{% else %}
Zaloguj się lub zarejestruj
{% endif %}
{% endblock %}


{% block right_content %}
{% if user.is_authenticated %}
Jesteś zalogowany
{% else %}
Register
{% csrf_token %}
{{form_r.as_p}}
 
 
{% endif %}
{% endblock %}
{% endblock %}



copyright  Dariusz Mysior








W dniu czwartek, 17 grudnia 2015 22:16:33 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I have this view and I have a bug why?
>
> def index(request):
> # jezeli formularz coś wysłał
> if request.method == 'POST':
> form_r = UserCreationForm(request.POST)
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
>
> # jezeli uzytkownik istnieje
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('profile')
>
> else:
> # Return a 'disabled account' error message
> ...
> else:
> # Return an 'invalid login' error message.
> return HttpResponseRedirect('invalid_login')
> if form_r.is_valid():
> form_r.save()
> info="Zarejestrowałeś się!"
> return render_to_response('ownsite/register_success.html', 
> {info:'info'})
> else:
> return HttpResponseRedirect('/')
> # tworze formularze
> args = {}
> args.update(csrf(request))
> args['form_l'] = AuthenticationForm()
> args['form_r']= UserCreationForm()
>
> return render_to_response('index.html', args)
>
>
> A bug
>
>
> MultiValueDictKeyError at / 
>>
>> "'password'"
>>
>> Request Method: POST Request URL: http://127.0.0.1:8000/ Django Version: 
>> 1.8.4 Exception Type: MultiValueDictKeyError Exception Value: 
>>
>> "'password'"
>>
>> Exception Location: 
>> C:\Python34\lib\site-packages\django\utils\datastructures.py 
>> in __getitem__, line 322 Python Executable: C:\Python34\python.exe Python 
>> Version: 3.4.3 Python Path: 
>>
>> ['C:\\Python34\\ownsite',
>>  'C:\\WINDOWS\\SYSTEM32\\python34.zip',
>>  'C:\\Python34\\DLLs',
>>  'C:\\Python34\\lib',
>>  'C:\\Python34',
>>  'C:\\Python34\\lib\\site-packages']
>>
>> Server time: Czw, 17 Gru 2015 22:07:11 +0100
>
>
>

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


Problem with a view - MultiValueDictKeyError

2015-12-17 Thread Dariusz Mysior
I have this view and I have a bug why?

def index(request):
# jezeli formularz coś wysłał
if request.method == 'POST':
form_r = UserCreationForm(request.POST)
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)

# jezeli uzytkownik istnieje
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('profile')

else:
# Return a 'disabled account' error message
...
else:
# Return an 'invalid login' error message.
return HttpResponseRedirect('invalid_login')
if form_r.is_valid():
form_r.save()
info="Zarejestrowałeś się!"
return render_to_response('ownsite/register_success.html', 
{info:'info'})
else:
return HttpResponseRedirect('/')
# tworze formularze
args = {}
args.update(csrf(request))
args['form_l'] = AuthenticationForm()
args['form_r']= UserCreationForm()

return render_to_response('index.html', args)


A bug


MultiValueDictKeyError at / 
>
> "'password'"
>
> Request Method: POST Request URL: http://127.0.0.1:8000/ Django Version: 
> 1.8.4 Exception Type: MultiValueDictKeyError Exception Value: 
>
> "'password'"
>
> Exception Location: 
> C:\Python34\lib\site-packages\django\utils\datastructures.py 
> in __getitem__, line 322 Python Executable: C:\Python34\python.exe Python 
> Version: 3.4.3 Python Path: 
>
> ['C:\\Python34\\ownsite',
>  'C:\\WINDOWS\\SYSTEM32\\python34.zip',
>  'C:\\Python34\\DLLs',
>  'C:\\Python34\\lib',
>  'C:\\Python34',
>  'C:\\Python34\\lib\\site-packages']
>
> Server time: Czw, 17 Gru 2015 22:07:11 +0100


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


Re: Problem with login and register form

2015-11-25 Thread Dariusz Mysior
Before template access_ownsite.html I had separated on few templates like 
login, register etc .html and it work's but now when I split it, a form is 
not forward to access_ownsite.html

W dniu wtorek, 24 listopada 2015 21:34:30 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> Hi I had a problem with display a form of login and register, please look 
> on it.
>
> my template access_ownsite.html
>
> {% load staticfiles %}
>
> 
> 
> 
> {% block title %}{% endblock %}
> 
>
>
> 
> 
> {% block content %}
> 
> {% if user.is_authenticated %}
> Jesteś zalogowany {{ user.username 
> }}
> wyloguj
> {% else %}
> Login
> {% csrf_token 
> %}
> {{form.as_p}}
> 
> 
> {% endif %}
> 
> 
> 
> {% block logout_msg %}
>  {{ info }} 
> Nikt nie jest zalogowany w tym momencie.
> {% endblock %}
> 
> 
> {% if user.is_authenticated == False %}
> Register
> {% 
> csrf_token %}
> {{form.as_p}}
> 
> 
> {% endif %}
> 
> 
> 
> copyright  Dariusz Mysior
> 
> {% endblock %}
> 
> 
>
>
>
> my view.py
>
> from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
> from django.shortcuts import render_to_response, render
> from django.http import  HttpResponseRedirect
> from django.core.context_processors import csrf
> from django.contrib.auth import authenticate, login, logout
>
>
> def login_view(request):
> if request.method == 'POST':
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('/accounts/my_view')
> else:
> # Return a 'disabled account' error message
> ...
> else:
> 
>
> ...

-- 
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/777e462c-1589-489b-bb0b-f4786cc81944%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with login and register form

2015-11-25 Thread Dariusz Mysior
It's not fix a problem.

W dniu wtorek, 24 listopada 2015 21:34:30 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> Hi I had a problem with display a form of login and register, please look 
> on it.
>
> my template access_ownsite.html
>
> {% load staticfiles %}
>
> 
> 
> 
> {% block title %}{% endblock %}
> 
>
>
> 
> 
> {% block content %}
> 
> {% if user.is_authenticated %}
> Jesteś zalogowany {{ user.username 
> }}
> wyloguj
> {% else %}
> Login
> {% csrf_token 
> %}
> {{form.as_p}}
> 
> 
> {% endif %}
> 
> 
> 
> {% block logout_msg %}
>  {{ info }} 
> Nikt nie jest zalogowany w tym momencie.
> {% endblock %}
> 
> 
> {% if user.is_authenticated == False %}
> Register
> {% 
> csrf_token %}
> {{form.as_p}}
> 
> 
> {% endif %}
> 
> 
> 
> copyright  Dariusz Mysior
> 
> {% endblock %}
> 
> 
>
>
>
> my view.py
>
> from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
> from django.shortcuts import render_to_response, render
> from django.http import  HttpResponseRedirect
> from django.core.context_processors import csrf
> from django.contrib.auth import authenticate, login, logout
>
>
> def login_view(request):
> if request.method == 'POST':
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('/accounts/my_view')
> else:
> # Return a 'disabled account' error message
> ...
> else:
> 
>
> ...

-- 
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/bdff446d-0050-40af-af62-11ac4f9df446%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with login and register form

2015-11-25 Thread Dariusz Mysior
Hmm I forget about it but I change names on form_l and form_r and effect is 
the same, I had also info


C:\Python34\lib\site-packages\django\template\defaulttags.py:66: 
> UserWarning: A {% csrf_token %} was used in a template, but the context did 
> not provide the value.  This is usually cause
> d by not using RequestContext.
>   "A {% csrf_token %} was used in a template, but the context "
>
>
W dniu wtorek, 24 listopada 2015 21:34:30 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> Hi I had a problem with display a form of login and register, please look 
> on it.
>
> my template access_ownsite.html
>
> {% load staticfiles %}
>
> 
> 
> 
> {% block title %}{% endblock %}
> 
>
>
> 
> 
> {% block content %}
> 
> {% if user.is_authenticated %}
> Jesteś zalogowany {{ user.username 
> }}
> wyloguj
> {% else %}
> Login
> {% csrf_token 
> %}
> {{form.as_p}}
> 
> 
> {% endif %}
> 
> 
> 
> {% block logout_msg %}
>  {{ info }} 
> Nikt nie jest zalogowany w tym momencie.
> {% endblock %}
> 
> 
> {% if user.is_authenticated == False %}
> Register
> {% 
> csrf_token %}
> {{form.as_p}}
> 
> 
> {% endif %}
> 
> 
> 
> copyright  Dariusz Mysior
> 
> {% endblock %}
> 
> 
>
>
>
> my view.py
>
> from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
> from django.shortcuts import render_to_response, render
> from django.http import  HttpResponseRedirect
> from django.core.context_processors import csrf
> from django.contrib.auth import authenticate, login, logout
>
>
> def login_view(request):
> if request.method == 'POST':
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('/accounts/my_view')
> else:
> # Return a 'disabled account' error message
> ...
> else:
> 
>
> ...

-- 
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/6538ba58-57c6-4c5c-8ebe-686ea85c184d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with login and register form

2015-11-24 Thread Dariusz Mysior
Hi I had a problem with display a form of login and register, please look 
on it.

my template access_ownsite.html

{% load staticfiles %}




{% block title %}{% endblock %}





{% block content %}

{% if user.is_authenticated %}
Jesteś zalogowany {{ user.username 
}}
wyloguj
{% else %}
Login
{% csrf_token %}
{{form.as_p}}


{% endif %}



{% block logout_msg %}
 {{ info }} 
Nikt nie jest zalogowany w tym momencie.
{% endblock %}


{% if user.is_authenticated == False %}
Register
{% 
csrf_token %}
{{form.as_p}}


{% endif %}



copyright  Dariusz Mysior

{% endblock %}





my view.py

from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.shortcuts import render_to_response, render
from django.http import  HttpResponseRedirect
from django.core.context_processors import csrf
from django.contrib.auth import authenticate, login, logout


def login_view(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/accounts/my_view')
else:
# Return a 'disabled account' error message
...
else:
# Return an 'invalid login' error message.
...

form = AuthenticationForm()

args = {}
args.update(csrf(request))
args['form']= AuthenticationForm()

return render_to_response('ownsite/access_ownsite.html', 
args)#accounts/login.html
def my_view(request):

return render_to_response('accounts/my_view.html', {'username': 
request.user.username,'user': request.user })

def register_user(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_success')
args = {}
args.update(csrf(request))
args['form']= UserCreationForm()
return render_to_response('accounts/register_user.html', args)

def register_success(request):
return render_to_response('accounts/register_success.html')

def logout_view(request):
logout(request)
return render_to_response('accounts/logout_view.html', {'info': 'Właśnie 
się wylogowałeś.',})







-- 
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/ef8af2cd-aad4-4faa-8eec-dca903187348%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I had proglem with .css file loaded to template

2015-11-21 Thread Dariusz Mysior
Ok it's ok already, but I don't know how :/

thanks!

W dniu sobota, 21 listopada 2015 14:21:36 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
>
> I have a problem with loading the css file, after calling index.html who 
> inherits base_ownsite.html which reads css page will not show background 
> color or font color ...
>
> base_ownsite.html
>
> {% load staticfiles %}{% 
> block title %}{% endblock %}  href="{% static 'ownsite/css /style.css' %}" />   {% block 
> content %} {% endblock %}  
>
> index.html
>
> {% extends 'ownsite/base_ownsite.html' %} {% block content %} {% if 
> user.is_authenticated %} Jesteś zalogowany {{ 
> user.username }} wyloguj 
> {% else %} Strona główna  href='/accounts/login_view'>logowanie  href='/accounts/register_user'>rejestracja {% endif %} {% endblock %}
>
>
>
> style.css
>
>
>
>  body {
>  background: yellow;
> }
>
> h2 {
>  color: red;
> }
>
> p {
>  color: yellow;
>  }
>
>
> settings.py 
> STATIC_URL = '/static/'
>
>  STATICFILES_DIRS = (
>  "/ownsite/static",
> )
>
>
>

-- 
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/79091f45-81e0-4f8f-a94f-3090ab9de08b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I had proglem with .css file loaded to template

2015-11-21 Thread Dariusz Mysior
And also when I change path to app css file 

accounts - style.css

body {
background-color: green;
}

h2 {
color: blue;
}


in page details code I had

body {
background: red ;
}

h2 {
color: blue;
}


with was set a long time ago, now I set green background but page is red :/


W dniu sobota, 21 listopada 2015 14:21:36 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
>
> I have a problem with loading the css file, after calling index.html who 
> inherits base_ownsite.html which reads css page will not show background 
> color or font color ...
>
> base_ownsite.html
>
> {% load staticfiles %}{% 
> block title %}{% endblock %}  href="{% static 'ownsite/css /style.css' %}" />   {% block 
> content %} {% endblock %}  
>
> index.html
>
> {% extends 'ownsite/base_ownsite.html' %} {% block content %} {% if 
> user.is_authenticated %} Jesteś zalogowany {{ 
> user.username }} wyloguj 
> {% else %} Strona główna  href='/accounts/login_view'>logowanie  href='/accounts/register_user'>rejestracja {% endif %} {% endblock %}
>
>
>
> style.css
>
>
>
>  body {
>  background: yellow;
> }
>
> h2 {
>  color: red;
> }
>
> p {
>  color: yellow;
>  }
>
>
> settings.py 
> STATIC_URL = '/static/'
>
>  STATICFILES_DIRS = (
>  "/ownsite/static",
> )
>
>
>

-- 
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/73d57b6f-a3b7-412c-94b1-99d69e29f386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I had proglem with .css file loaded to template

2015-11-21 Thread Dariusz Mysior
 

I have a problem with loading the css file, after calling index.html who 
inherits base_ownsite.html which reads css page will not show background 
color or font color ...

base_ownsite.html

{% load staticfiles %}{% block 
title %}{% endblock %}{% block content %} {% 
endblock %}  

index.html

{% extends 'ownsite/base_ownsite.html' %} {% block content %} {% if 
user.is_authenticated %} Jesteś zalogowany {{ 
user.username }} wyloguj {% 
else %} Strona główna logowanie rejestracja {% endif %} {% endblock %}



style.css



 body {
 background: yellow;
}

h2 {
 color: red;
}

p {
 color: yellow;
 }


settings.py 
STATIC_URL = '/static/'

 STATICFILES_DIRS = (
 "/ownsite/static",
)


-- 
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/f8b7d745-5c11-40f3-841d-62c2d2da47fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with static folder

2015-11-20 Thread Dariusz Mysior
Thanks!

W dniu środa, 18 listopada 2015 22:02:26 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I had a static folder nr 1 in app accounts and my templates see it, but 
> when I create   folder static nr 2 in my project directory tempalates 
> dosn't see it. I copy this static folder nr 2 and past to accounts folder 
> next to this static folder nr 1 and it is visible. Why in project directory 
> this is not visible?
>

-- 
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/9f0f7ccf-fa4f-4b2e-9d29-4caa934108ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with static folder

2015-11-18 Thread Dariusz Mysior
I had a static folder nr 1 in app accounts and my templates see it, but 
when I create   folder static nr 2 in my project directory tempalates 
dosn't see it. I copy this static folder nr 2 and past to accounts folder 
next to this static folder nr 1 and it is visible. Why in project directory 
this is not visible?

-- 
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/6dbb6bef-d371-48e3-bc76-cfa8663f8fc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with seassion

2015-11-13 Thread Dariusz Mysior
Ok I have it! :)

views.py

def index(request):
return render_to_response('index.html', {'username': request.user.username,
 'user':request.user})


index.html

{% load staticfiles %}
 

 
{% block content %}
{% if user.is_authenticated %}
Jesteś zalogowany {{ user.username }}
{% else %}
Strona główna
logowanie
rejestracja
 
{% endif %}
 
 
{% endblock %}




W dniu piątek, 13 listopada 2015 09:59:04 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> In the application accounts have everything that regards registration and 
> login and beyond this application in the project folder I have index.html to 
> the home page where I have links to login and registration forms, I would 
> like to index.html in some way to provide request.user.username that 
> instead of these two URLs I showed the message that I'm logged in.
>
> How can I request.user.username application file accounts views.py move to 
> file views.py main project? : /
>
> I paste here all what I already have
>
> index.html from the root folder of the project
>
> {% load staticfiles %}
>  
> 
>  
> {% block content %}
> {% if user.is_authenticated %}
> Jesteś zalogowany {{ username }}
> {% else %}
> Strona główna
> logowanie
> rejestracja
> {% endif %}
>  
>  
> {% endblock %}
>
>
> views.py from the root folder of the project
>
> from django.shortcuts import render_to_response
>  
> def index(request):
> return render_to_response('index.html', {'username': 
> request.user.username})
>
>
> accounts/views.py
>
> from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
> from django.shortcuts import render_to_response
> from django.http import  HttpResponseRedirect
> from django.core.context_processors import csrf
> from django.contrib.auth import authenticate, login, logout
>  
> def login_view(request):
> if request.method == 'POST':
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('/accounts/my_view')
> else:
> # Return a 'disabled account' error message
> ...
> else:
> # Return an 'invalid login' error message.
> ...
>  
> form = AuthenticationForm()
> args = {}
> args.update(csrf(request))
> args['form']= AuthenticationForm()
> return render_to_response('accounts/login.html', args)
> def my_view(request):
>  
> return render_to_response('accounts/my_view.html', {'username': 
> request.user.username})
>  
> def register_user(request):
> if request.method == 'POST':
> form = UserCreationForm(request.POST)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect('/accounts/register_success')
> args = {}
> args.update(csrf(request))
> args['form']= UserCreationForm()
> return render_to_response('accounts/register_user.html', args)
>  
> def register_success(request):
> return render_to_response
>
> ...

-- 
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/1d6b8bd8-34b4-40d0-8462-58730888c415%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with seassion

2015-11-13 Thread Dariusz Mysior
In the application accounts have everything that regards registration and 
login and beyond this application in the project folder I have index.html to 
the home page where I have links to login and registration forms, I would 
like to index.html in some way to provide request.user.username that instead of 
these two URLs I showed the message that I'm logged in.

How can I request.user.username application file accounts views.py move to 
file views.py main project? : /

I paste here all what I already have

index.html from the root folder of the project

{% load staticfiles %}
 

 
{% block content %}
{% if user.is_authenticated %}
Jesteś zalogowany {{ username }}
{% else %}
Strona główna
logowanie
rejestracja
{% endif %}
 
 
{% endblock %}


views.py from the root folder of the project

from django.shortcuts import render_to_response
 
def index(request):
return render_to_response('index.html', {'username': request.user.username})


accounts/views.py

from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.shortcuts import render_to_response
from django.http import  HttpResponseRedirect
from django.core.context_processors import csrf
from django.contrib.auth import authenticate, login, logout
 
def login_view(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/accounts/my_view')
else:
# Return a 'disabled account' error message
...
else:
# Return an 'invalid login' error message.
...
 
form = AuthenticationForm()
args = {}
args.update(csrf(request))
args['form']= AuthenticationForm()
return render_to_response('accounts/login.html', args)
def my_view(request):
 
return render_to_response('accounts/my_view.html', {'username': 
request.user.username})
 
def register_user(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_success')
args = {}
args.update(csrf(request))
args['form']= UserCreationForm()
return render_to_response('accounts/register_user.html', args)
 
def register_success(request):
return render_to_response('accounts/register_success.html')
 
def logout(request):
pass


accounts/my_view

{% load staticfiles %}
 

 
{% block content %}
My profile
Witaj {{ username }}
{% 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cbe04e43-5e3c-40ad-a6a1-9c9a1d985ece%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get logged username in template

2015-11-12 Thread Dariusz Mysior
Thanks for both advice. I am not advanced programmer sow I use the simplest 
solution on this moment this first one Andréas Kühne. Thanks it works!

W dniu czwartek, 12 listopada 2015 08:46:06 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I am using Django 1.8 with Python 3.4 I had no idea why my template 
> doesn't show my username on template profile.html :/
>
>
> profile.py
>
>
> {% load staticfiles %}
>
> 
>
> {% block content %}
> My profile
> {{ request.user.username }}
> {% endblock %}
>
>
> views.py
>
>
> from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
> from django.shortcuts import render_to_response
> from django.http import  HttpResponseRedirect
> from django.core.context_processors import csrf
> from django.contrib.auth import authenticate, login
>
>
> def login_view(request):
>
> if request.method == 'POST':
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('/accounts/profile')
> else:
> # Return a 'disabled account' error message
> ...
> pass
> else:
> # Return an 'invalid login' error message.
> pass
> form = AuthenticationForm()
> args = {}
> args.update(csrf(request))
> args['form']= AuthenticationForm()
> return render_to_response('accounts/login.html', args)
>
> def my_view(request):
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> print(request.user)
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('/accounts/profile')
> else:
> # Return a 'disabled account' error message
> ...
> else:
> # Return an 'invalid login' error message.
> ...
> def profile(request):
> username = request.user.username
> return render_to_response('accounts/profile.html', username)
>
> def register_user(request):
> if request.method == 'POST':
> form = UserCreationForm(request.POST)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect('/accounts/register_success')
> args = {}
> args.update(csrf(request))
> args['form']= UserCreationForm()
> return render_to_response('accounts/register_user.html', args)
>
> def register_success(request):
> return render_to_response('accounts/register_success.html')
>
>
>
>

-- 
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/2b355828-bbfd-4ffd-a8c4-ab0001f42f68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to get logged username in template

2015-11-11 Thread Dariusz Mysior


I am using Django 1.8 with Python 3.4 I had no idea why my template doesn't 
show my username on template profile.html :/


profile.py


{% load staticfiles %}



{% block content %}
My profile
{{ request.user.username }}
{% endblock %}


views.py


from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.shortcuts import render_to_response
from django.http import  HttpResponseRedirect
from django.core.context_processors import csrf
from django.contrib.auth import authenticate, login


def login_view(request):

if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/accounts/profile')
else:
# Return a 'disabled account' error message
...
pass
else:
# Return an 'invalid login' error message.
pass
form = AuthenticationForm()
args = {}
args.update(csrf(request))
args['form']= AuthenticationForm()
return render_to_response('accounts/login.html', args)

def my_view(request):
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
print(request.user)
if user.is_active:
login(request, user)
return HttpResponseRedirect('/accounts/profile')
else:
# Return a 'disabled account' error message
...
else:
# Return an 'invalid login' error message.
...
def profile(request):
username = request.user.username
return render_to_response('accounts/profile.html', username)

def register_user(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_success')
args = {}
args.update(csrf(request))
args['form']= UserCreationForm()
return render_to_response('accounts/register_user.html', args)

def register_success(request):
return render_to_response('accounts/register_success.html')



-- 
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/88ec2289-59b6-41a3-a1d7-c41be3fc0b4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: coding in template

2015-11-09 Thread Dariusz Mysior
Thank's i set it in PyCharm on encoding utf-8 like You said and it's work!

W dniu sobota, 7 listopada 2015 21:44:25 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I try use polish letters in my template index.html but I had an error
>
>
> utf-8' codec can't decode byte 0xb3 in position 149: invalid start byte
>>
>>
> How can I fix it? 
>
>

-- 
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/610cf50e-be60-4b9c-9313-3c5b568b8366%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: coding in template

2015-11-07 Thread Dariusz Mysior
How can I save in other coding, I had only option "save as" and name of 
file index.html

W dniu sobota, 7 listopada 2015 21:44:25 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I try use polish letters in my template index.html but I had an error
>
>
> utf-8' codec can't decode byte 0xb3 in position 149: invalid start byte
>>
>>
> How can I fix it? 
>
>

-- 
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/cdb1e75c-4ad3-4cb4-8f70-4d7ae03a9c81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


coding in template

2015-11-07 Thread Dariusz Mysior
I try use polish letters in my template index.html but I had an error


utf-8' codec can't decode byte 0xb3 in position 149: invalid start byte
>
>
How can I fix it? 

-- 
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/bce1852e-9f2e-482d-9037-5fac55afa487%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form to login

2015-11-05 Thread Dariusz Mysior
Thank's I have it!

W dniu środa, 4 listopada 2015 06:51:02 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> I try do login view and I find it on 
>
> https://docs.djangoproject.com/en/1.8/topics/auth/default/
>
> from django.contrib.auth import authenticate, login
>
> def my_view(request):
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> if user.is_active:
> login(request, user)
> # Redirect to a success page.
> else:
> # Return a 'disabled account' error message
> ...
> else:
> # Return an 'invalid login' error message.
> ...
>
>
>
> to give request.POST username and password and username I must create my 
> own form or maybe Django have that form ready? I use Django 1.8
>

-- 
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/e8038d21-9ad5-4e52-b5af-c9fa78f44681%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Form to login

2015-11-03 Thread Dariusz Mysior
I try do login view and I find it on 

https://docs.djangoproject.com/en/1.8/topics/auth/default/

from django.contrib.auth import authenticate, login

def my_view(request):
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
# Redirect to a success page.
else:
# Return a 'disabled account' error message
...
else:
# Return an 'invalid login' error message.
...



to give request.POST username and password and username I must create my 
own form or maybe Django have that form ready? I use Django 1.8

-- 
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/96258668-1c56-45d6-adce-59cff591dd23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: install gettext tools 0.15

2015-10-31 Thread Dariusz Mysior
Maybe I download a wrong files I have win 8 x64 and from 

https://download.gnome.org/binaries/win64/dependencies/

I download files:

gettext-runtime_0.18.1.1-1_win64.zip 
<https://download.gnome.org/binaries/win64/dependencies/gettext-runtime_0.18.1.1-1_win64.zip>

gettext-tools_0.18.1.1-1_win64.zip 
<https://download.gnome.org/binaries/win64/dependencies/gettext-tools_0.18.1.1-1_win64.zip>

create folder in path C:\Program Files\gettext-utils and extract this 2 
files there. There isn't msgfmt.exe file

W dniu piątek, 30 października 2015 21:33:52 UTC+1 użytkownik Dariusz 
Mysior napisał:
>
> I use Windows 8 Python 3.4 Django 1.8 and I try
>
> I set settings and add: USE_I18N = True
>
> add to MIDDLEWARE_CLASSES django.middleware.locale.LocaleMiddleware
>
> like in describe in link below
>
>
> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#gettext-on-windows
>
> I download gettext-runtime_0.18.1.1-1_win64 and 
> gettext-tools_0.18.1.1-1_win64 extract to C:\Program Files\gettext-utils 
> add path like in link to Control Panel > System > Advanced > Environment 
> Variables and when I write to terminal C:\Python34\ownsite>manage.py 
> compilemessages I had info :( 
>
> CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15 
> or newer installed.
>
> What can I do more??? I have lost a few days 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2669aec4-ef74-4ef6-94c8-dad4d20a29fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: install gettext tools 0.15

2015-10-30 Thread Dariusz Mysior
I do this and I have msfgmt is not recognized as an internal or external 
command, operable program or a batch file.

W dniu piątek, 30 października 2015 21:33:52 UTC+1 użytkownik Dariusz 
Mysior napisał:
>
> I use Windows 8 Python 3.4 Django 1.8 and I try
>
> I set settings and add: USE_I18N = True
>
> add to MIDDLEWARE_CLASSES django.middleware.locale.LocaleMiddleware
>
> like in describe in link below
>
>
> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#gettext-on-windows
>
> I download gettext-runtime_0.18.1.1-1_win64 and 
> gettext-tools_0.18.1.1-1_win64 extract to C:\Program Files\gettext-utils 
> add path like in link to Control Panel > System > Advanced > Environment 
> Variables and when I write to terminal C:\Python34\ownsite>manage.py 
> compilemessages I had info :( 
>
> CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15 
> or newer installed.
>
> What can I do more??? I have lost a few days 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11f5728d-5ad6-4c65-9761-facf8ddcd260%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


install gettext tools 0.15

2015-10-30 Thread Dariusz Mysior


I use Windows 8 Python 3.4 Django 1.8 and I try

I set settings and add: USE_I18N = True

add to MIDDLEWARE_CLASSES django.middleware.locale.LocaleMiddleware

like in describe in link below

https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#gettext-on-windows

I download gettext-runtime_0.18.1.1-1_win64 and 
gettext-tools_0.18.1.1-1_win64 extract to C:\Program Files\gettext-utils 
add path like in link to Control Panel > System > Advanced > Environment 
Variables and when I write to terminal C:\Python34\ownsite>manage.py 
compilemessages I had info :( 

CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15 
or newer installed.

What can I do more??? I have lost a few days 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a8d67475-b471-4683-aeaf-aa43e9d547e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How extract from list with BooleanVar objects each object

2015-07-25 Thread Dariusz Mysior
In this group last posta are from 2013 year :/

W dniu sobota, 25 lipca 2015 18:04:50 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I want from list (1) with BoolenVar objects (2) extract this objects in 
> "from" loop (3)...How can I do it...
>
> def createCheckButton(self):
> y=3
> for x in range(self.lp):
> self.chooseButton=BooleanVar() #(2)
> Checkbutton(variable=self.chooseButton, 
> command=self.splitOrder()).grid(row=x+1, column=y+1)
> self.listCheckButton.append(self.chooseButton) #(1)
>
> def splitOrder(self): #(3)
> count=len(self.listCheckButton)
> for x in range(count):
> if self.chooseButton[x].get():
> print(self.chooseButton)
>
>
>
>

-- 
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/0e46f233-ad43-42aa-9491-56c227399363%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How extract from list with BooleanVar objects each object

2015-07-25 Thread Dariusz Mysior
I want from list (1) with BoolenVar objects (2) extract this objects in 
"from" loop (3)...How can I do it...

def createCheckButton(self):
y=3
for x in range(self.lp):
self.chooseButton=BooleanVar() #(2)
Checkbutton(variable=self.chooseButton, 
command=self.splitOrder()).grid(row=x+1, column=y+1)
self.listCheckButton.append(self.chooseButton) #(1)

def splitOrder(self): #(3)
count=len(self.listCheckButton)
for x in range(count):
if self.chooseButton[x].get():
print(self.chooseButton)



-- 
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/c5100bac-5fa3-472c-a103-b660cc845fc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I share attribute in other class

2015-04-18 Thread Dariusz Mysior
I have two class, and I want use in method first_distribution_cards 
self.players from first class how can I do this?

class Game(object):

 def __init__(self,name):
 self.players=[]
 self.dealer=Person("Dealer")
 self.name=name
class Deck(object):

def first_distribution_cards(self):
 for player in self.players:
 for card in range(0,5):
 self.player.hand.append(self.cards)
 print(self.player.hand[card])




-- 
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/3e3e42ea-5d8f-45c1-9a76-9388c9a5f8b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Python] Problem with arguments given

2015-03-14 Thread Dariusz Mysior
Mam jeden problem nie wiem dlaczego mam bład
I have problem with this bug :/


Traceback (most recent call last):
>   File "C:\Python31\makao.py", line 23, in 
> nr_players=Hand.ask_number("Ilu graczy ma wziąść udział w grze 
> (2-5):",low=2,high=5)
> TypeError: ask_number() takes exactly 4 non-keyword positional arguments 
> (1 given)
>

my code


class Hand(object):  
def ask_number(self,question,low,high):
response=None
while response not in range(low,high):
response=int(input(question))
return response
def ask_human_players(self,question,nr_player):
response=None
while response not in range(low,nr_player):
response=int(input(question))
return response
 
nr_players=Hand.ask_number("Ilu graczy ma wziąść udział w grze (2-5):",low=2
,high=5)
print(nr_players)
 
human_players=Hand.ask_human_players("Ile graczy to ludzie",nr_players)
print(human_players)


-- 
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/b825f565-98fb-4bf3-a136-58dfcb424dc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with for and if

2015-01-05 Thread Dariusz Mysior
I try develop this code to get a number of position this letter in word, 
and I have it but for example if i search letter "t" I get "1, 5, b", why I 
get b instead of 11???

def gen2():
count=0
count2=0
for a in zmienna:
count2+=1
if a==szukana:
count+=1
pozycja.append(count2)

return pozycja
print("3. Literka '",szukana,"' w słowie ",zmienna,
  "wystąpiła " ,gen(),"razy w kolejności")
#print(gen2())

print(", ".join(["%x" % a for a in gen2()]))



W dniu poniedziałek, 5 stycznia 2015 16:45:19 UTC+1 użytkownik Zoltán Bege 
napisał:
>
> You should use the string's count method: zmienna.count(szukana)
>
> See help("string.count")
>
> On Monday, January 5, 2015 4:32:06 PM UTC+2, Dariusz Mysior wrote:
>>
>> I want search count of szukana in zmienna but code below counting all 12 
>> letters from "traktorzysta" word 
>>
>> szukana="t" 
>> zmienna="traktorzysta" 
>>  
>>  
>> def gen(): 
>> count=int(0) 
>> for a in zmienna: 
>> if szukana in zmienna: 
>> count+=1 
>> else: 
>> continue 
>> return count 
>>  
>>  
>> print("Literka '",szukana,"' w słowie ",zmienna, 
>>   "wystąpiła ",gen()," razy") 
>>
>>

-- 
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/9576f3af-e6c5-4713-a4c7-271279a78165%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with for and if

2015-01-05 Thread Dariusz Mysior
I want search count of szukana in zmienna but code below counting all 12 
letters from "traktorzysta" word 

szukana="t" 
zmienna="traktorzysta" 
 
 
def gen(): 
count=int(0) 
for a in zmienna: 
if szukana in zmienna: 
count+=1 
else: 
continue 
return count 
 
 
print("Literka '",szukana,"' w słowie ",zmienna, 
  "wystąpiła ",gen()," razy") 

-- 
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/5a41304b-0d6b-424a-a284-cc64cfeac08c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Random row

2014-12-20 Thread Dariusz Mysior
I change it on

import csv, random

def new_name():
with open('PL_surnames.csv', newline='') as csvfile:
namesreader = csv.reader(csvfile, delimiter=' ', quotechar='|') 

random_choice=random.choice(namesreader)
return random_choice
print(new_name())



No I have this message

Traceback (most recent call last):
  File "C:/Python31/csv", line 10, in 
print(new_name())
  File "C:/Python31/csv", line 8, in new_name
random_choice=random.choice(namesreader*len(namesreader))
TypeError: object of type '_csv.reader' has no len()
>>> 



W dniu sobota, 20 grudnia 2014 22:37:23 UTC+1 użytkownik Dariusz Mysior 
napisał:
>
> Why I get only last row from my csv file, why I don't get in any time 
> ranom row :/
>
> import csv, random
>
> def new_name():
> with open('PL_surnames.csv', newline='') as csvfile:
> namesreader = csv.reader(csvfile, delimiter=' ', quotechar='|') 
> for row in namesreader:
> #print (','.join(row))
> random_choice=random.choice(row)
> return random_choice
> print(new_name())
>
>
>

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


Random row

2014-12-20 Thread Dariusz Mysior
Why I get only last row from my csv file, why I don't get in any time ranom 
row :/

import csv, random

def new_name():
with open('PL_surnames.csv', newline='') as csvfile:
namesreader = csv.reader(csvfile, delimiter=' ', quotechar='|') 
for row in namesreader:
#print (','.join(row))
random_choice=random.choice(row)
return random_choice
print(new_name())


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


Re: how add path to open()

2014-11-30 Thread Dariusz Mysior
Yes this is it :)

thanks :)

W dniu niedziela, 30 listopada 2014 20:24:44 UTC+1 użytkownik Collin 
Anderson napisał:
>
> Hi,
>
> I think you want something like this. (Just make sure a login name doesn't 
> have '..' in it :).
>
> filehandler = open('users/' + login, "wb")
>
> Collin
>
>
> On Saturday, November 29, 2014 2:35:31 PM UTC-5, Dariusz Mysior wrote:
>>
>> I join to topic with my problem
>>
>> I want to create new file with login and password in new file and I can 
>> do it with code below, but I don't know how save this new files in one 
>> folder users
>> def rejestracja(login, haslo): save=None login_tmp=login haslo_tmp=haslo 
>> save={login_tmp:haslo_tmp}
>>
>>  filehandler=open(login,"wb")
>> pickle.dump(save,filehandler)
>> filehandler.close()
>> filehandler=open(login,"rb")
>> file=pickle.load(filehandler)
>> filehandler.close()
>> print file
>> raw_input("\n\nWcisnij [ENTER]: ")
>>
>>
>>

-- 
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/73ab9242-d1f0-47eb-b05c-1a7516dd913c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how add path to open()

2014-11-29 Thread Dariusz Mysior
 

I join to topic with my problem

I want to create new file with login and password in new file and I can do 
it with code below, but I don't know how save this new files in one folder 
users
def rejestracja(login, haslo): save=None login_tmp=login haslo_tmp=haslo 
save={login_tmp:haslo_tmp}

 filehandler=open(login,"wb")
pickle.dump(save,filehandler)
filehandler.close()
filehandler=open(login,"rb")
file=pickle.load(filehandler)
filehandler.close()
print file
raw_input("\n\nWcisnij [ENTER]: ")


-- 
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/b1e9cf18-1f8c-4829-ad2f-b1aededd984f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-24 Thread Dariusz Mysior
I have in views.py

message="Password was changed"
return logout_then_login(request, login_url='/login/',extra_context={
'message': message})


And I want display this message in

login.html below

{% extends "base_site_dom.html" %}
{% block title %} - logowanie {% endblock %}
{%  block content %}

 Logowanie na stronie Managera Piłkarskiego GoalKick 

*{{ message}}*


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






{% endblock %}
{% block footer %}

Strona główna

{% endblock %}

What I do wrong, this message is not show :/

W dniu wtorek, 7 października 2014 20:37:49 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I have form to change password like below, and when I try to display it I 
> have an bug:
>
> ValueError at /password_change/
>   
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
>   
>
> 
>   
>   
> 
> 
>   
>   
> 
>
> 
>   
>   
> 
>
> 
>
>   Request Method:GETRequest URL:
> http://darmys.pythonanywhere.com/password_change/Django 
> Version:1.6.5Exception 
> Type:ValueErrorException Value:
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
> My forms.py is:
> class FormularzPasswordChange(forms.Form):
> password1 = forms.CharField(label="Hasło:",widget=forms.PasswordInput
> ())
> password2 = forms.CharField(label="Powtórz hasło:",widget=forms.
> PasswordInput())
>
> def clean_password2(self):
> password1 = self.cleaned_data['password1']
> password2 = self.cleaned_data['password2']
> if password1 == password2:
> return password2
> else:
> raise forms.ValidationError("Hasła się różnią")
>
>
>
> urls.py
>
> url(r'^password_change/$', views.password_change_dom, name=
> 'change_password')
>
> change_password.html
>
> {% extends "base_site_dom.html" %}
>
> {% block title %} - zmiana hasła {% endblock %}
>
> {% block content %}
>
> 
> Zmiana hasła na nowe.
> Wpisz nowe hasło 2 razy.
> 
> 
> 
> {% csrf_token %}
> {{ form.as_p }}
>   value="Wartoci początkowe">
> 
> 
> 
> 
> {% endblock %}
> {% block footer %}
> 
> Strona głóna
> 
> {% 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3b8f21b6-ecbb-4912-a45b-f758b73fb5c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-21 Thread Dariusz Mysior
Thank You, once again it help :)

W dniu poniedziałek, 20 października 2014 23:55:28 UTC+2 użytkownik Collin 
Anderson napisał:
>
> Hello,
>
> from django.contrib.auth import logout,login,authenticate,password_change
> I think you want:
> from django.contrib.auth import logout,login,authenticate
> from django.contrib.auth.views import change_password
>
> Collin
>
>

-- 
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/1b57667f-f4fc-4e85-9487-be337cf20c53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-20 Thread Dariusz Mysior
Now I try change this part of code in views.py

#request.user.set_password(form.cleaned_data['password2'])
#request.user.save()
#return render(request, 
'registration/change_password_success.html', {'user': request.user})

On 

from django.contrib.auth import logout,login,authenticate,*password_change*
.
.
.

password_change(request,'registration/change_password_success.html',
post_change_redirect=None,
password_change_form=FormularzPasswordChange, 
current_app=None, extra_context=None)

urls.py

This change

#url(r'^password_change/$', views.password_change_dom, 
name='change_password'),


On this

url(r'^password_change/$', 'django.contrib.auth.views.change_password'),

And I have message on first site :/


ImportError at / 
>
> cannot import name password_change
>
>  Request Method: GET  Request URL: http://darmys.pythonanywhere.com/  Django 
> Version: 1.6.5  Exception Type: ImportError  Exception Value: 
>
> cannot import name password_change
>
>  Exception Location: /home/darmys/dom/dom/views.py in , line 7




W dniu wtorek, 7 października 2014 20:37:49 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I have form to change password like below, and when I try to display it I 
> have an bug:
>
> ValueError at /password_change/
>   
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
>   
>
> 
>   
>   
> 
> 
>   
>   
> 
>
> 
>   
>   
> 
>
> 
>
>   Request Method:GETRequest URL:
> http://darmys.pythonanywhere.com/password_change/Django 
> Version:1.6.5Exception 
> Type:ValueErrorException Value:
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
> My forms.py is:
> class FormularzPasswordChange(forms.Form):
> password1 = forms.CharField(label="Hasło:",widget=forms.PasswordInput
> ())
> password2 = forms.CharField(label="Powtórz hasło:",widget=forms.
> PasswordInput())
>
> def clean_password2(self):
> password1 = self.cleaned_data['password1']
> password2 = self.cleaned_data['password2']
> if password1 == password2:
> return password2
> else:
> raise forms.ValidationError("Hasła się różnią")
>
>
>
> urls.py
>
> url(r'^password_change/$', views.password_change_dom, name=
> 'change_password')
>
> change_password.html
>
> {% extends "base_site_dom.html" %}
>
> {% block title %} - zmiana hasła {% endblock %}
>
> {% block content %}
>
> 
> Zmiana hasła na nowe.
> Wpisz nowe hasło 2 razy.
> 
> 
> 
> {% csrf_token %}
> {{ form.as_p }}
>   value="Wartoci początkowe">
> 
> 
> 
> 
> {% endblock %}
> {% block footer %}
> 
> Strona głóna
> 
> {% 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e0eb0d5e-151b-492c-b9d8-07096e2a5dc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
It work's! :)

Thank You!!

 now I have:

def password_change_dom(request):
if request.method == 'POST':
form = FormularzPasswordChange(request.POST)
if form.is_valid():
request.user.set_password(form.cleaned_data['password2'])
request.user.save()
template = loader.get_template(
"registration/change_password.html")
variables = RequestContext(request,{'user':request.user})
output = template.render(variables)
return HttpResponseRedirect("/")
else:
form = FormularzPasswordChange()
return render(request, 'registration/change_password.html', 
{'form': form})



W dniu wtorek, 7 października 2014 20:37:49 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I have form to change password like below, and when I try to display it I 
> have an bug:
>
> ValueError at /password_change/
>   
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
>   
>
> 
>   
>   
> 
> 
>   
>   
> 
>
> 
>   
>   
> 
>
> 
>
>   Request Method:GETRequest URL:
> http://darmys.pythonanywhere.com/password_change/Django 
> Version:1.6.5Exception 
> Type:ValueErrorException Value:
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
> My forms.py is:
> class FormularzPasswordChange(forms.Form):
> password1 = forms.CharField(label="Hasło:",widget=forms.PasswordInput
> ())
> password2 = forms.CharField(label="Powtórz hasło:",widget=forms.
> PasswordInput())
>
> def clean_password2(self):
> password1 = self.cleaned_data['password1']
> password2 = self.cleaned_data['password2']
> if password1 == password2:
> return password2
> else:
> raise forms.ValidationError("Hasła się różnią")
>
>
>
> urls.py
>
> url(r'^password_change/$', views.password_change_dom, name=
> 'change_password')
>
> change_password.html
>
> {% extends "base_site_dom.html" %}
>
> {% block title %} - zmiana hasła {% endblock %}
>
> {% block content %}
>
> 
> Zmiana hasła na nowe.
> Wpisz nowe hasło 2 razy.
> 
> 
> 
> {% csrf_token %}
> {{ form.as_p }}
>   value="Wartoci początkowe">
> 
> 
> 
> 
> {% endblock %}
> {% block footer %}
> 
> Strona głóna
> 
> {% 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/596fb0ed-e644-4911-afdb-9f42a9061e47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
It was like You said, now I see form and when I write password and submit I 
have 

KeyError at /password_change/
  

'username'


  


  
  


  
  



  
  



  
  




  
  




  
  Request Method:POSTRequest URL:http:
//darmys.pythonanywhere.com/password_change/Django Version:1.6.5Exception 
Type:KeyErrorException Value:

'username'

Exception Location:/home/darmys/dom/dom/views.py in password_change_dom, 
line 55



W dniu wtorek, 7 października 2014 21:21:16 UTC+2 użytkownik Collin 
Anderson napisał:
>
> also, I highly recommend the render() shortcut:
>
> def password_change_dom(request):
> if request.method == 'POST':
> form = FormularzPasswordChange(request.POST)
> if form.is_valid():
> user = authenticate(username=form.cleaned_data['username'])
> user.set_password(form.cleaned_data['password2'])
> user.save()
> login(request, user)
> return HttpResponseRedirect("/")
> else:
> form = FormularzPasswordChange()
> return render(request, 'registration/change_password.html', {'form': 
> form})
>
>

-- 
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/7a5e519f-61f2-49c3-83e8-fdc2a3c663dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
It's :

ef password_change_dom(request):
if request.method == 'POST':
form = FormularzPasswordChange(request.POST)
if form.is_valid():
user = authenticate(username=form.cleaned_data['username'])
 #user = User.objects.get(username='username')
user.set_password(form.cleaned_data['password2']),
user.save()
login(request,user)
template = loader.get_template(
"registration/change_password.html")
variables = RequestContext(request,{'user':user})
output = template.render(variables)
return HttpResponseRedirect("/")
else:
form = FormularzPasswordChange()
template = loader.get_template(
'registration/change_password.html')
variables = RequestContext(request,{'form':form})
output = template.render(variables)
return HttpResponse(output)



W dniu wtorek, 7 października 2014 21:07:35 UTC+2 użytkownik Collin 
Anderson napisał:
>
> What does your password_change_dom view look like?
>

-- 
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/12b78cb0-7c22-41bf-97ef-eac2bbf82fd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
I have form to change password like below, and when I try to display it I 
have an bug:

ValueError at /password_change/
  

The view dom.views.password_change_dom didn't return an HttpResponse object.


  


  
  


  
  



  
  



   
  Request Method:GETRequest URL:
http://darmys.pythonanywhere.com/password_change/Django Version:1.6.5Exception 
Type:ValueErrorException Value:

The view dom.views.password_change_dom didn't return an HttpResponse object.


My forms.py is:
class FormularzPasswordChange(forms.Form):
password1 = forms.CharField(label="Hasło:",widget=forms.PasswordInput())
password2 = forms.CharField(label="Powtórz hasło:",widget=forms.
PasswordInput())

def clean_password2(self):
password1 = self.cleaned_data['password1']
password2 = self.cleaned_data['password2']
if password1 == password2:
return password2
else:
raise forms.ValidationError("Hasła się różnią")



urls.py

url(r'^password_change/$', views.password_change_dom, name='change_password'
)

change_password.html

{% extends "base_site_dom.html" %}

{% block title %} - zmiana hasła {% endblock %}

{% block content %}


Zmiana hasła na nowe.
Wpisz nowe hasło 2 razy.



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




{% endblock %}
{% block footer %}

Strona głóna

{% 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5535160a-444c-4ab9-a3bf-1898bf76f188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: static files

2014-09-04 Thread Dariusz Mysior
Ok I set it :)

W dniu środa, 3 września 2014 20:01:26 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I have my path like below:
>
> home <https://www.pythonanywhere.com/user/darmys/files/home> > darmys 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys> > dom 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom> > 
> player 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player> 
> > templates 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player/templates>
>  
> > access 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player/templates/access>
>  
> > index.html
>
> and code
>
> div>{% load staticfiles %} %}" alt="Piłka"/>
>
> path to image is 
>
>
> home <https://www.pythonanywhere.com/user/darmys/files/home> > darmys 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys> > dom 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom> > 
> player 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player> 
> > static 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player/static>
>  
> > images
>
> In my site I see not image but only alt text why? :/
>

-- 
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/358528c0-fe8f-47e7-a33b-6e9182e608c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: static files

2014-09-04 Thread Dariusz Mysior
I dont't understand

Now I have like You said and it's not work. I try with app name and without.

W dniu środa, 3 września 2014 20:01:26 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I have my path like below:
>
> home <https://www.pythonanywhere.com/user/darmys/files/home> > darmys 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys> > dom 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom> > 
> player 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player> 
> > templates 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player/templates>
>  
> > access 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player/templates/access>
>  
> > index.html
>
> and code
>
> div>{% load staticfiles %} %}" alt="Piłka"/>
>
> path to image is 
>
>
> home <https://www.pythonanywhere.com/user/darmys/files/home> > darmys 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys> > dom 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom> > 
> player 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player> 
> > static 
> <https://www.pythonanywhere.com/user/darmys/files/home/darmys/dom/player/static>
>  
> > images
>
> In my site I see not image but only alt text why? :/
>

-- 
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/c7646691-1b41-4581-b949-831e0fda445e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


static files

2014-09-03 Thread Dariusz Mysior
I have my path like below:

home  > darmys 
 > dom 
 > player 
 > 
templates 

 
> access 

 
> index.html

and code

div>{% load staticfiles %}

path to image is 


home  > darmys 
 > dom 
 > player 
 > 
static 

 
> images

In my site I see not image but only alt text why? :/

-- 
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/cf3c5459-ce4e-4e98-ad9d-bbf40163ee9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: where is base_site.html

2014-06-30 Thread Dariusz Mysior
Yes I have it!

Thank You Andreas!!!

W dniu poniedziałek, 30 czerwca 2014 18:10:07 UTC+2 użytkownik Dariusz 
Mysior napisał:
>
> I use virtualenv with Django 1.6 Python 2.7 and I am use tutorial 
> https://docs.djangoproject.com/en/1.6/intro/tutorial02/ and I had a 
> problem becouse I don't know where I can find  file base_site.html from 
> django/contrib/admin/templates where I can't find this place :/
>

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


where is base_site.html

2014-06-30 Thread Dariusz Mysior
I use virtualenv with Django 1.6 Python 2.7 and I am use tutorial 
https://docs.djangoproject.com/en/1.6/intro/tutorial02/ and I had a problem 
becouse I don't know where I can find  file base_site.html from 
django/contrib/admin/templates where I can't find this place :/

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


Re: Upgrade Mysql

2014-06-20 Thread Dariusz Mysior
But in mysite-mysite-settings.py in DATABASES I dont't have CONN_MAX_AGE 
and in don't have in my general directory file my.cnf :/ 

W dniu piątek, 20 czerwca 2014 17:31:10 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use pythonanywhere.com Django 1.6 and Python 2.7 I 
>
> and when I write p.save() I had error like below. 
>
> It says something about updating mysql to fix it, but I don't know what 
> code or shell commands I need to write.
>
> Can you help me? One person post that he upgrade MySQL to 5.0.27 but I 
> don't know what is a commend for do this :/.
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 545, in save
> force_update=force_update, update_fields=update_fields)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 570, in save_base
> with transaction.commit_on_success_unless_managed(using=using, 
> savepoint=False):
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py",
>  line 280, in __enter__
> connection.set_autocommit(False)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py",
>  line 340, in set_autocommit
> self._set_autocommit(autocommit)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  line 461, in _set_autocommit
> self.connection.autocommit(autocommit)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py",
>  line 99, in __exit__
> six.reraise(dj_exc_type, dj_exc_value, traceback)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  line 461, in _set_autocommit
> self.connection.autocommit(autocommit)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py",
>  line 243, in autocommit
> _mysql.connection.autocommit(self, on)
> OperationalError: (2006, 'MySQL server has gone away')
>
>
>

-- 
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/ac07e598-aa07-4319-b12a-b354b118e61c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Upgrade Mysql

2014-06-20 Thread Dariusz Mysior
I use pythonanywhere.com Django 1.6 and Python 2.7 I 

and when I write p.save() I had error like below. 

It says something about updating mysql to fix it, but I don't know what 
code or shell commands I need to write.

Can you help me? One person post that he upgrade MySQL to 5.0.27 but I 
don't know what is a commend for do this :/.

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
 line 545, in save
force_update=force_update, update_fields=update_fields)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
 line 570, in save_base
with transaction.commit_on_success_unless_managed(using=using, 
savepoint=False):
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py",
 line 280, in __enter__
connection.set_autocommit(False)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py",
 line 340, in set_autocommit
self._set_autocommit(autocommit)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
 line 461, in _set_autocommit
self.connection.autocommit(autocommit)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py",
 line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
 line 461, in _set_autocommit
self.connection.autocommit(autocommit)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py",
 line 243, in autocommit
_mysql.connection.autocommit(self, on)
OperationalError: (2006, 'MySQL server has gone away')


-- 
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/0dc3a793-2fd0-4884-87f3-b14724bdd1ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with runserver

2014-06-18 Thread Dariusz Mysior
Ok I now now

Start the development server Remember, don't use runserver and 
*localhost:8000* on PythonAnywhere 
<https://www.pythonanywhere.com/wiki/PythonAnywhere>. Instead, go back to 
your *Web* tab, and hit reload on your web app. You will then be able to go 
to *your-username.pythonanywhere.com/admin* and see the admin site up and 
running... 



W dniu środa, 18 czerwca 2014 12:43:38 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use pythonanywhere.com and now I install Python 2.7 and Django 1.6 with 
> virtualenv
>
> My settings.py is
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'NAME': 'daro822$db1',
> 'USER':   'daro822',
> 'PASSWORD': '*',
> 'HOST':'mysql.server',
> 'PORT':'',
>
> I start project mysite and I have a problem in Bash with command 
>
> python manage.py runserver
>   
>
>   
> I have a comment like this
>
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 399, in execute_from_command_line
> utility.execute()
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/base.py",
>  line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/base.py",
>  line 280, in execute
> translation.activate('en-us')
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
>  line 130, in activate
> return _trans.activate(language)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  line 188, in activate
> _active.value = translation(language)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  line 159, in _fetch
> app = import_module(appname)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/importlib.py",
>  line 40, in import_module
> __import__(name)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
>  line 6, in 
> from django.contrib.admin.sites import AdminSite, site
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/sites.py",
>  line 4, in 
> from django.contrib.admin.forms import AdminAuthenticationForm
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/forms.py",
>  line 6, in 
> from django.contrib.auth.forms import AuthenticationForm
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/auth/forms.py",
>  line 17, in 
> from django.contrib.auth.models import User
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
>  line 48, in 
> class Permission(models.Model):
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 96, in __new__
> new_class.add_to_class('_meta', Options(meta, **kwargs))
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 264, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/options.py",
>  line 124, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "/home/daro822/.virtualenvs/django16/loca

Re: Problem with runserver

2014-06-18 Thread Dariusz Mysior
It,s work but another message with port :/

Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Error: That port is already in use.



W dniu środa, 18 czerwca 2014 12:43:38 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use pythonanywhere.com and now I install Python 2.7 and Django 1.6 with 
> virtualenv
>
> My settings.py is
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'NAME': 'daro822$db1',
> 'USER':   'daro822',
> 'PASSWORD': '*',
> 'HOST':'mysql.server',
> 'PORT':'',
>
> I start project mysite and I have a problem in Bash with command 
>
> python manage.py runserver
>   
>
>   
> I have a comment like this
>
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 399, in execute_from_command_line
> utility.execute()
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/base.py",
>  line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/base.py",
>  line 280, in execute
> translation.activate('en-us')
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
>  line 130, in activate
> return _trans.activate(language)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  line 188, in activate
> _active.value = translation(language)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
>  line 159, in _fetch
> app = import_module(appname)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/importlib.py",
>  line 40, in import_module
> __import__(name)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
>  line 6, in 
> from django.contrib.admin.sites import AdminSite, site
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/sites.py",
>  line 4, in 
> from django.contrib.admin.forms import AdminAuthenticationForm
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/forms.py",
>  line 6, in 
> from django.contrib.auth.forms import AuthenticationForm
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/auth/forms.py",
>  line 17, in 
> from django.contrib.auth.models import User
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
>  line 48, in 
> class Permission(models.Model):
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 96, in __new__
> new_class.add_to_class('_meta', Options(meta, **kwargs))
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 264, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/options.py",
>  line 124, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/__init__.py",
>  line 34, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File 
> "/home/daro822/.virtua

Problem with runserver

2014-06-18 Thread Dariusz Mysior
I use pythonanywhere.com and now I install Python 2.7 and Django 1.6 with 
virtualenv

My settings.py is

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'daro822$db1',
'USER':   'daro822',
'PASSWORD': '*',
'HOST':'mysql.server',
'PORT':'',

I start project mysite and I have a problem in Bash with command 

python manage.py runserver  


  
I have a comment like this

Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 399, in execute_from_command_line
utility.execute()
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/base.py",
 line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/core/management/base.py",
 line 280, in execute
translation.activate('en-us')
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
 line 130, in activate
return _trans.activate(language)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 line 188, in activate
_active.value = translation(language)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 line 159, in _fetch
app = import_module(appname)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/importlib.py",
 line 40, in import_module
__import__(name)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
 line 6, in 
from django.contrib.admin.sites import AdminSite, site
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/sites.py",
 line 4, in 
from django.contrib.admin.forms import AdminAuthenticationForm
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/admin/forms.py",
 line 6, in 
from django.contrib.auth.forms import AuthenticationForm
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/auth/forms.py",
 line 17, in 
from django.contrib.auth.models import User
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
 line 48, in 
class Permission(models.Model):
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
 line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
 line 264, in add_to_class
value.contribute_to_class(cls, name)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/options.py",
 line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/__init__.py",
 line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py",
 line 198, in __getitem__
backend = load_backend(db['ENGINE'])
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py",
 line 113, in load_backend
return import_module('%s.base' % backend_name)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/utils/importlib.py",
 line 40, in import_module
__import__(name)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
 line 17, in 
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No 
module named MySQLdb


-- 
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