Re: Reg: Django signal not working

2020-04-23 Thread sahil khan
https://youtu.be/lHQI9ydQlSU

Here is the Link for your Problem.

if you like the solutions please like share and subscribe errormania. in
your groups and join our telegram channel: @errormania
And share in your groups and with other developer friends


thank you

On Wed, 22 Apr 2020, 8:30 pm Jorge Gimeno,  wrote:

>
>
> On Wed, Apr 22, 2020 at 4:55 AM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
>> Hello Sahil,
>>
>> Thank you for the youtube link. The video has done the exactly same thing
>> that I am doing. However, I understand that the user registration is
>> created through default "User" model, and UserCreationForm. However, I am
>> adding a custom field "*city*", and its not working for me.
>>
>> Except the *city*, all other default is saved into the
>> database.(Username, first_name, last_name, email, password)
>>
>> I have already shared the code snippet here in my previous emails. If
>> possible go through it and let me know .
>>
>> Regards,
>> Amitesh
>>
>>
>> On Tuesday, 21 April, 2020, 06:33:42 pm IST, sahil khan <
>> parmarsahilkha...@gmail.com> wrote:
>>
>>
>> Hello i am from google group plz see this video chennel and solve
>> your problem
>> https://youtu.be/QDk3rI_H3ks like comment and subscribe and share so
>> that another people get help this channel
>>
>> On Mon, 20 Apr 2020, 4:28 pm Aditya Singh, 
>> wrote:
>>
>> What's the original issue please, seems like you picked things up with
>> someone till this email.
>> Regards,
>> Aditya
>>
>> On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users <
>> django-users@googlegroups.com> wrote:
>>
>> -+c Hello Jorge,
>>
>> After doing some research, I realized that the signal which is saving the
>> user profile should have
>>
>> "instance.signup.save()" , as the name of the custom model is signup.
>> This time I still got the error .However,  I could create the new user and
>> login to the website. However, when I look into the admin panel, I still
>> could't see the "contact" field getting saved after the user is registered
>> successfully.
>>
>> Therefore the main purpose of creating the custom User model still
>> failing.
>>
>> Below are the code snippet, and screenshot from my admin panel.
>>
>> Models.py
>> -
>>
>> from django.db import models
>> from django.contrib.auth.models import User
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>>
>>
>> class SignUp(models.Model):
>> user = models.OneToOneField(User, on_delete=models.CASCADE)
>> Contact = models.CharField(max_length=500, blank=True)
>>
>> @receiver(post_save, sender=User)
>> def create_user_profile(sender, instance, created, **kwargs):
>> if created:
>> SignUp.objects.create(user=instance)
>>
>> @receiver(post_save, sender=User)
>> def save_user_profile(sender, instance, **kwargs):
>> save2 = instance.signup.save()
>> print(save2)
>>
>>
>> To debug the issue, I used the print statement to see the output of
>> "instance.signup.save()". So, after submitting the form, I checked the
>> "runserver" console. The output was "None". So, something doesn't seems to
>> be right.
>>
>> forms.py
>> --
>>
>> from django.contrib.auth.forms import UserCreationForm
>> from django.contrib.auth.models import User
>> from django import forms
>> from .models import SignUp
>>
>>
>> class SignUpForm(UserCreationForm):
>> email = forms.EmailField()
>> first_name = forms.CharField(max_length=100)
>> last_name = forms.CharField(max_length=100)
>>
>> class Meta:
>> model = User
>> fields = ('username', 'first_name', 'last_name', 'email', 
>> 'password1', 'password2')
>>
>>
>> class CustomSignUpPage(forms.ModelForm):
>> Contact = forms.CharField(max_length=10)
>>
>> class Meta:
>> model = SignUp
>> fields = ('Contact', )
>>
>>
>> views.py
>> -
>>
>> def register_user(request):
>> if request.method == "POST":
>> form = SignUpForm(request.POST)
>> cus_form = CustomSignUpPage(request.POST)
>> if form.is_valid() and cus_form.is_valid():
>> save1 = form.save()
>> save1.refresh_from_db()
>> cus_form = CustomSignUpPage(request.POST, 
>> instance=request.save1.signup.contact)
>> cus_form.full_clean()
>> cus_form.save()
>> username = form.cleaned_data['username']
>> password = form.cleaned_data['password1']
>> user = authenticate(request, username=username, 
>> password=password)
>> login(request, user)
>> messages.success(request, f'Registration successful')
>> return redirect('home')
>> else:
>> messages.error(request, f'Please correct the error below.')
>> else:
>> form = SignUpForm()
>> cus_form = CustomSignUpPage()
>>
>> return render(request, 'authenticate\\register.html', 

Re: Reg: Django signal not working

2020-04-22 Thread Jorge Gimeno
On Wed, Apr 22, 2020 at 4:55 AM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> Hello Sahil,
>
> Thank you for the youtube link. The video has done the exactly same thing
> that I am doing. However, I understand that the user registration is
> created through default "User" model, and UserCreationForm. However, I am
> adding a custom field "*city*", and its not working for me.
>
> Except the *city*, all other default is saved into the
> database.(Username, first_name, last_name, email, password)
>
> I have already shared the code snippet here in my previous emails. If
> possible go through it and let me know .
>
> Regards,
> Amitesh
>
>
> On Tuesday, 21 April, 2020, 06:33:42 pm IST, sahil khan <
> parmarsahilkha...@gmail.com> wrote:
>
>
> Hello i am from google group plz see this video chennel and solve
> your problem
> https://youtu.be/QDk3rI_H3ks like comment and subscribe and share so that
> another people get help this channel
>
> On Mon, 20 Apr 2020, 4:28 pm Aditya Singh, 
> wrote:
>
> What's the original issue please, seems like you picked things up with
> someone till this email.
> Regards,
> Aditya
>
> On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
> -+c Hello Jorge,
>
> After doing some research, I realized that the signal which is saving the
> user profile should have
>
> "instance.signup.save()" , as the name of the custom model is signup. This
> time I still got the error .However,  I could create the new user and login
> to the website. However, when I look into the admin panel, I still could't
> see the "contact" field getting saved after the user is registered
> successfully.
>
> Therefore the main purpose of creating the custom User model still
> failing.
>
> Below are the code snippet, and screenshot from my admin panel.
>
> Models.py
> -
>
> from django.db import models
> from django.contrib.auth.models import User
> from django.db.models.signals import post_save
> from django.dispatch import receiver
>
>
> class SignUp(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> Contact = models.CharField(max_length=500, blank=True)
>
> @receiver(post_save, sender=User)
> def create_user_profile(sender, instance, created, **kwargs):
> if created:
> SignUp.objects.create(user=instance)
>
> @receiver(post_save, sender=User)
> def save_user_profile(sender, instance, **kwargs):
> save2 = instance.signup.save()
> print(save2)
>
>
> To debug the issue, I used the print statement to see the output of
> "instance.signup.save()". So, after submitting the form, I checked the
> "runserver" console. The output was "None". So, something doesn't seems to
> be right.
>
> forms.py
> --
>
> from django.contrib.auth.forms import UserCreationForm
> from django.contrib.auth.models import User
> from django import forms
> from .models import SignUp
>
>
> class SignUpForm(UserCreationForm):
> email = forms.EmailField()
> first_name = forms.CharField(max_length=100)
> last_name = forms.CharField(max_length=100)
>
> class Meta:
> model = User
> fields = ('username', 'first_name', 'last_name', 'email', 
> 'password1', 'password2')
>
>
> class CustomSignUpPage(forms.ModelForm):
> Contact = forms.CharField(max_length=10)
>
> class Meta:
> model = SignUp
> fields = ('Contact', )
>
>
> views.py
> -
>
> def register_user(request):
> if request.method == "POST":
> form = SignUpForm(request.POST)
> cus_form = CustomSignUpPage(request.POST)
> if form.is_valid() and cus_form.is_valid():
> save1 = form.save()
> save1.refresh_from_db()
> cus_form = CustomSignUpPage(request.POST, 
> instance=request.save1.signup.contact)
> cus_form.full_clean()
> cus_form.save()
> username = form.cleaned_data['username']
> password = form.cleaned_data['password1']
> user = authenticate(request, username=username, password=password)
> login(request, user)
> messages.success(request, f'Registration successful')
> return redirect('home')
> else:
> messages.error(request, f'Please correct the error below.')
> else:
> form = SignUpForm()
> cus_form = CustomSignUpPage()
>
> return render(request, 'authenticate\\register.html', context={'form': 
> form, 'cus_form': cus_form})
>
> Screenshot from the admin panel:
>
> [image: Inline image]
> Please suggest. If you are comfortable we can go on a web meeting where I
> can share my screen and we can work on it.
>
> Regards,
> Amitesh
>
> Sent from Yahoo Mail on Android
> 
>
> On Sun, 19 Apr 

Re: Reg: Django signal not working

2020-04-22 Thread 'Amitesh Sahay' via Django users
Hello Sahil,
Thank you for the youtube link. The video has done the exactly same thing that 
I am doing. However, I understand that the user registration is created through 
default "User" model, and UserCreationForm. However, I am adding a custom field 
"city", and its not working for me. 
Except the city, all other default is saved into the database.(Username, 
first_name, last_name, email, password)
I have already shared the code snippet here in my previous emails. If possible 
go through it and let me know .


Regards,
Amitesh 

On Tuesday, 21 April, 2020, 06:33:42 pm IST, sahil khan 
 wrote:  
 
 Hello i am from google group plz see this video chennel and solve your 
problemhttps://youtu.be/QDk3rI_H3ks like comment and subscribe and share so 
that another people get help this channel 

On Mon, 20 Apr 2020, 4:28 pm Aditya Singh,  wrote:

What's the original issue please, seems like you picked things up with someone 
till this email.Regards,Aditya
On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users 
 wrote:

-+c Hello Jorge, 
After doing some research, I realized that the signal which is saving the user 
profile should have 
"instance.signup.save()" , as the name of the custom model is signup. This time 
I still got the error .However,  I could create the new user and login to the 
website. However, when I look into the admin panel, I still could't see the 
"contact" field getting saved after the user is registered successfully. 
Therefore the main purpose of creating the custom User model still failing. 
Below are the code snippet, and screenshot from my admin panel.
Models.py-from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver


class SignUp(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Contact = models.CharField(max_length=500, blank=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
SignUp.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
save2 = instance.signup.save()
print(save2)
To debug the issue, I used the print statement to see the output of 
"instance.signup.save()". So, after submitting the form, I checked the 
"runserver" console. The output was "None". So, something doesn't seems to be 
right.
forms.py--from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from .models import SignUp


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class CustomSignUpPage(forms.ModelForm):
Contact = forms.CharField(max_length=10)

class Meta:
model = SignUp
fields = ('Contact', )
views.py-def register_user(request):
if request.method == "POST":
form = SignUpForm(request.POST)
cus_form = CustomSignUpPage(request.POST)
if form.is_valid() and cus_form.is_valid():
save1 = form.save()
save1.refresh_from_db()
cus_form = CustomSignUpPage(request.POST, 
instance=request.save1.signup.contact)
cus_form.full_clean()
cus_form.save()
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
user = authenticate(request, username=username, password=password)
login(request, user)
messages.success(request, f'Registration successful')
return redirect('home')
else:
messages.error(request, f'Please correct the error below.')
else:
form = SignUpForm()
cus_form = CustomSignUpPage()

return render(request, 'authenticate\\register.html', context={'form': 
form, 'cus_form': cus_form})Screenshot from the admin panel:
Please suggest. If you are comfortable we can go on a web meeting where I can 
share my screen and we can work on it.
Regards,Amitesh

Sent from Yahoo Mail on Android 
 
  On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno wrote:   
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> However, the signal that I have written seems not to be working.
>> Whenever, I am filling the form, I am getting below error:
>>
>> AttributeError at /auth/register/
>> 'User' 

Re: Reg: Django signal not working

2020-04-21 Thread sahil khan
Hello i am from google group plz see this video chennel and solve
your problem
https://youtu.be/QDk3rI_H3ks like comment and subscribe and share so that
another people get help this channel

On Mon, 20 Apr 2020, 4:28 pm Aditya Singh, 
wrote:

> What's the original issue please, seems like you picked things up with
> someone till this email.
> Regards,
> Aditya
>
> On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
>> -+c Hello Jorge,
>>
>> After doing some research, I realized that the signal which is saving the
>> user profile should have
>>
>> "instance.signup.save()" , as the name of the custom model is signup.
>> This time I still got the error .However,  I could create the new user and
>> login to the website. However, when I look into the admin panel, I still
>> could't see the "contact" field getting saved after the user is registered
>> successfully.
>>
>> Therefore the main purpose of creating the custom User model still
>> failing.
>>
>> Below are the code snippet, and screenshot from my admin panel.
>>
>> Models.py
>> -
>>
>> from django.db import models
>> from django.contrib.auth.models import User
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>>
>>
>> class SignUp(models.Model):
>> user = models.OneToOneField(User, on_delete=models.CASCADE)
>> Contact = models.CharField(max_length=500, blank=True)
>>
>> @receiver(post_save, sender=User)
>> def create_user_profile(sender, instance, created, **kwargs):
>> if created:
>> SignUp.objects.create(user=instance)
>>
>> @receiver(post_save, sender=User)
>> def save_user_profile(sender, instance, **kwargs):
>> save2 = instance.signup.save()
>> print(save2)
>>
>>
>> To debug the issue, I used the print statement to see the output of
>> "instance.signup.save()". So, after submitting the form, I checked the
>> "runserver" console. The output was "None". So, something doesn't seems to
>> be right.
>>
>> forms.py
>> --
>>
>> from django.contrib.auth.forms import UserCreationForm
>> from django.contrib.auth.models import User
>> from django import forms
>> from .models import SignUp
>>
>>
>> class SignUpForm(UserCreationForm):
>> email = forms.EmailField()
>> first_name = forms.CharField(max_length=100)
>> last_name = forms.CharField(max_length=100)
>>
>> class Meta:
>> model = User
>> fields = ('username', 'first_name', 'last_name', 'email', 
>> 'password1', 'password2')
>>
>>
>> class CustomSignUpPage(forms.ModelForm):
>> Contact = forms.CharField(max_length=10)
>>
>> class Meta:
>> model = SignUp
>> fields = ('Contact', )
>>
>>
>> views.py
>> -
>>
>> def register_user(request):
>> if request.method == "POST":
>> form = SignUpForm(request.POST)
>> cus_form = CustomSignUpPage(request.POST)
>> if form.is_valid() and cus_form.is_valid():
>> save1 = form.save()
>> save1.refresh_from_db()
>> cus_form = CustomSignUpPage(request.POST, 
>> instance=request.save1.signup.contact)
>> cus_form.full_clean()
>> cus_form.save()
>> username = form.cleaned_data['username']
>> password = form.cleaned_data['password1']
>> user = authenticate(request, username=username, 
>> password=password)
>> login(request, user)
>> messages.success(request, f'Registration successful')
>> return redirect('home')
>> else:
>> messages.error(request, f'Please correct the error below.')
>> else:
>> form = SignUpForm()
>> cus_form = CustomSignUpPage()
>>
>> return render(request, 'authenticate\\register.html', context={'form': 
>> form, 'cus_form': cus_form})
>>
>> Screenshot from the admin panel:
>>
>> [image: Inline image]
>> Please suggest. If you are comfortable we can go on a web meeting where I
>> can share my screen and we can work on it.
>>
>> Regards,
>> Amitesh
>>
>> Sent from Yahoo Mail on Android
>> 
>>
>> On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno
>>  wrote:
>> Amitesh,
>>
>> Where is User.profile defined?
>>
>> -Jorge
>>
>> On 4/18/20, Saurabh Ranjan Singh  wrote:
>> > I am having the same issue. Please fix it.
>> >
>> > On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>> >>
>> >> Hi,
>> >>
>> >> I am creating a Django signup form through "User" model and
>> >> "UserCreationForm" and customized the User model to accommodate single
>> >> user
>> >> defined field "contact".
>> >>
>> >> However, the signal that I have written seems not to be working.
>> >> Whenever, I am filling the form, I am getting below error:
>> >>
>> >> AttributeError at /auth/register/
>> >> 

Re: Reg: Django signal not working

2020-04-21 Thread Anonymous Patel
https://youtu.be/QDk3rI_H3ks
Checkout this video from errormania
They explained about signal.
If that doesn't help leave comment there they provide you with a video in a
day

Raj Patel

On Tue, 21 Apr, 2020, 9:34 am 'Amitesh Sahay' via Django users, <
django-users@googlegroups.com> wrote:

> Hello Aditya,
>
> I am using Django's "User" and "UserCreationForm" to create registration
> and login page and it's backend logic. So far so good. I could add the
> default fields to my registration page and it's working as per required.
>
> However, I want to add a custom field "contact" as it does not come
> in-built. But no matter what I am not able to do it.
>
> I have already shared the code in my previous email. Please go through it
> and let me know if you can help me somehow.
>
> Thank you
>
> Amitesh
>
> Sent from Yahoo Mail on Android
> 
>
> On Mon, 20 Apr 2020 at 16:28, Aditya Singh
>  wrote:
> What's the original issue please, seems like you picked things up with
> someone till this email.
> Regards,
> Aditya
>
> On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
> -+c Hello Jorge,
>
> After doing some research, I realized that the signal which is saving the
> user profile should have
>
> "instance.signup.save()" , as the name of the custom model is signup. This
> time I still got the error .However,  I could create the new user and login
> to the website. However, when I look into the admin panel, I still could't
> see the "contact" field getting saved after the user is registered
> successfully.
>
> Therefore the main purpose of creating the custom User model still
> failing.
>
> Below are the code snippet, and screenshot from my admin panel.
>
> Models.py
> -
>
> from django.db import models
> from django.contrib.auth.models import User
> from django.db.models.signals import post_save
> from django.dispatch import receiver
>
>
> class SignUp(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> Contact = models.CharField(max_length=500, blank=True)
>
> @receiver(post_save, sender=User)
> def create_user_profile(sender, instance, created, **kwargs):
> if created:
> SignUp.objects.create(user=instance)
>
> @receiver(post_save, sender=User)
> def save_user_profile(sender, instance, **kwargs):
> save2 = instance.signup.save()
> print(save2)
>
>
> To debug the issue, I used the print statement to see the output of
> "instance.signup.save()". So, after submitting the form, I checked the
> "runserver" console. The output was "None". So, something doesn't seems to
> be right.
>
> forms.py
> --
>
> from django.contrib.auth.forms import UserCreationForm
> from django.contrib.auth.models import User
> from django import forms
> from .models import SignUp
>
>
> class SignUpForm(UserCreationForm):
> email = forms.EmailField()
> first_name = forms.CharField(max_length=100)
> last_name = forms.CharField(max_length=100)
>
> class Meta:
> model = User
> fields = ('username', 'first_name', 'last_name', 'email', 
> 'password1', 'password2')
>
>
> class CustomSignUpPage(forms.ModelForm):
> Contact = forms.CharField(max_length=10)
>
> class Meta:
> model = SignUp
> fields = ('Contact', )
>
>
> views.py
> -
>
> def register_user(request):
> if request.method == "POST":
> form = SignUpForm(request.POST)
> cus_form = CustomSignUpPage(request.POST)
> if form.is_valid() and cus_form.is_valid():
> save1 = form.save()
> save1.refresh_from_db()
> cus_form = CustomSignUpPage(request.POST, 
> instance=request.save1.signup.contact)
> cus_form.full_clean()
> cus_form.save()
> username = form.cleaned_data['username']
> password = form.cleaned_data['password1']
> user = authenticate(request, username=username, password=password)
> login(request, user)
> messages.success(request, f'Registration successful')
> return redirect('home')
> else:
> messages.error(request, f'Please correct the error below.')
> else:
> form = SignUpForm()
> cus_form = CustomSignUpPage()
>
> return render(request, 'authenticate\\register.html', context={'form': 
> form, 'cus_form': cus_form})
>
> Screenshot from the admin panel:
>
> [image: Inline image]
> Please suggest. If you are comfortable we can go on a web meeting where I
> can share my screen and we can work on it.
>
> Regards,
> Amitesh
>
> Sent from Yahoo Mail on Android
> 

Re: Reg: Django signal not working

2020-04-20 Thread 'Amitesh Sahay' via Django users
Hello Aditya,
I am using Django's "User" and "UserCreationForm" to create registration and 
login page and it's backend logic. So far so good. I could add the default 
fields to my registration page and it's working as per required.
However, I want to add a custom field "contact" as it does not come in-built. 
But no matter what I am not able to do it.
I have already shared the code in my previous email. Please go through it and 
let me know if you can help me somehow.
Thank you
Amitesh

Sent from Yahoo Mail on Android 
 
  On Mon, 20 Apr 2020 at 16:28, Aditya Singh 
wrote:   What's the original issue please, seems like you picked things up with 
someone till this email.Regards,Aditya
On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users 
 wrote:

-+c Hello Jorge, 
After doing some research, I realized that the signal which is saving the user 
profile should have 
"instance.signup.save()" , as the name of the custom model is signup. This time 
I still got the error .However,  I could create the new user and login to the 
website. However, when I look into the admin panel, I still could't see the 
"contact" field getting saved after the user is registered successfully. 
Therefore the main purpose of creating the custom User model still failing. 
Below are the code snippet, and screenshot from my admin panel.
Models.py-from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver


class SignUp(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Contact = models.CharField(max_length=500, blank=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
SignUp.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
save2 = instance.signup.save()
print(save2)
To debug the issue, I used the print statement to see the output of 
"instance.signup.save()". So, after submitting the form, I checked the 
"runserver" console. The output was "None". So, something doesn't seems to be 
right.
forms.py--from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from .models import SignUp


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class CustomSignUpPage(forms.ModelForm):
Contact = forms.CharField(max_length=10)

class Meta:
model = SignUp
fields = ('Contact', )
views.py-def register_user(request):
if request.method == "POST":
form = SignUpForm(request.POST)
cus_form = CustomSignUpPage(request.POST)
if form.is_valid() and cus_form.is_valid():
save1 = form.save()
save1.refresh_from_db()
cus_form = CustomSignUpPage(request.POST, 
instance=request.save1.signup.contact)
cus_form.full_clean()
cus_form.save()
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
user = authenticate(request, username=username, password=password)
login(request, user)
messages.success(request, f'Registration successful')
return redirect('home')
else:
messages.error(request, f'Please correct the error below.')
else:
form = SignUpForm()
cus_form = CustomSignUpPage()

return render(request, 'authenticate\\register.html', context={'form': 
form, 'cus_form': cus_form})Screenshot from the admin panel:
Please suggest. If you are comfortable we can go on a web meeting where I can 
share my screen and we can work on it.
Regards,Amitesh

Sent from Yahoo Mail on Android 
 
  On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno wrote:   
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> However, the signal that I have written seems not to be working.
>> Whenever, I am filling the form, I am getting below error:
>>
>> AttributeError at /auth/register/
>> 'User' object has no attribute 'profile'
>>
>> *Full traceback log as below:*
>>
>> Installed Applications:
>> ['django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  

Re: Reg: Django signal not working

2020-04-20 Thread Aditya Singh
What's the original issue please, seems like you picked things up with
someone till this email.
Regards,
Aditya

On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> -+c Hello Jorge,
>
> After doing some research, I realized that the signal which is saving the
> user profile should have
>
> "instance.signup.save()" , as the name of the custom model is signup. This
> time I still got the error .However,  I could create the new user and login
> to the website. However, when I look into the admin panel, I still could't
> see the "contact" field getting saved after the user is registered
> successfully.
>
> Therefore the main purpose of creating the custom User model still
> failing.
>
> Below are the code snippet, and screenshot from my admin panel.
>
> Models.py
> -
>
> from django.db import models
> from django.contrib.auth.models import User
> from django.db.models.signals import post_save
> from django.dispatch import receiver
>
>
> class SignUp(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> Contact = models.CharField(max_length=500, blank=True)
>
> @receiver(post_save, sender=User)
> def create_user_profile(sender, instance, created, **kwargs):
> if created:
> SignUp.objects.create(user=instance)
>
> @receiver(post_save, sender=User)
> def save_user_profile(sender, instance, **kwargs):
> save2 = instance.signup.save()
> print(save2)
>
>
> To debug the issue, I used the print statement to see the output of
> "instance.signup.save()". So, after submitting the form, I checked the
> "runserver" console. The output was "None". So, something doesn't seems to
> be right.
>
> forms.py
> --
>
> from django.contrib.auth.forms import UserCreationForm
> from django.contrib.auth.models import User
> from django import forms
> from .models import SignUp
>
>
> class SignUpForm(UserCreationForm):
> email = forms.EmailField()
> first_name = forms.CharField(max_length=100)
> last_name = forms.CharField(max_length=100)
>
> class Meta:
> model = User
> fields = ('username', 'first_name', 'last_name', 'email', 
> 'password1', 'password2')
>
>
> class CustomSignUpPage(forms.ModelForm):
> Contact = forms.CharField(max_length=10)
>
> class Meta:
> model = SignUp
> fields = ('Contact', )
>
>
> views.py
> -
>
> def register_user(request):
> if request.method == "POST":
> form = SignUpForm(request.POST)
> cus_form = CustomSignUpPage(request.POST)
> if form.is_valid() and cus_form.is_valid():
> save1 = form.save()
> save1.refresh_from_db()
> cus_form = CustomSignUpPage(request.POST, 
> instance=request.save1.signup.contact)
> cus_form.full_clean()
> cus_form.save()
> username = form.cleaned_data['username']
> password = form.cleaned_data['password1']
> user = authenticate(request, username=username, password=password)
> login(request, user)
> messages.success(request, f'Registration successful')
> return redirect('home')
> else:
> messages.error(request, f'Please correct the error below.')
> else:
> form = SignUpForm()
> cus_form = CustomSignUpPage()
>
> return render(request, 'authenticate\\register.html', context={'form': 
> form, 'cus_form': cus_form})
>
> Screenshot from the admin panel:
>
> [image: Inline image]
> Please suggest. If you are comfortable we can go on a web meeting where I
> can share my screen and we can work on it.
>
> Regards,
> Amitesh
>
> Sent from Yahoo Mail on Android
> 
>
> On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno
>  wrote:
> Amitesh,
>
> Where is User.profile defined?
>
> -Jorge
>
> On 4/18/20, Saurabh Ranjan Singh  wrote:
> > I am having the same issue. Please fix it.
> >
> > On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
> >>
> >> Hi,
> >>
> >> I am creating a Django signup form through "User" model and
> >> "UserCreationForm" and customized the User model to accommodate single
> >> user
> >> defined field "contact".
> >>
> >> However, the signal that I have written seems not to be working.
> >> Whenever, I am filling the form, I am getting below error:
> >>
> >> AttributeError at /auth/register/
> >> 'User' object has no attribute 'profile'
> >>
> >> *Full traceback log as below:*
> >>
> >> Installed Applications:
> >> ['django.contrib.admin',
> >>  'django.contrib.auth',
> >>  'django.contrib.contenttypes',
> >>  'django.contrib.sessions',
> >>  'django.contrib.messages',
> >>  'django.contrib.staticfiles',
> >>  'phone_field',
> >>  'AUTHENTICATION']
> >> Installed Middleware:
> >> 

Re: Reg: Django signal not working

2020-04-20 Thread 'Amitesh Sahay' via Django users
-+c Hello Jorge, 
After doing some research, I realized that the signal which is saving the user 
profile should have 
"instance.signup.save()" , as the name of the custom model is signup. This time 
I still got the error .However,  I could create the new user and login to the 
website. However, when I look into the admin panel, I still could't see the 
"contact" field getting saved after the user is registered successfully. 
Therefore the main purpose of creating the custom User model still failing. 
Below are the code snippet, and screenshot from my admin panel.
Models.py-from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver


class SignUp(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Contact = models.CharField(max_length=500, blank=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
SignUp.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
save2 = instance.signup.save()
print(save2)
To debug the issue, I used the print statement to see the output of 
"instance.signup.save()". So, after submitting the form, I checked the 
"runserver" console. The output was "None". So, something doesn't seems to be 
right.
forms.py--from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from .models import SignUp


class SignUpForm(UserCreationForm):
email = forms.EmailField()
first_name = forms.CharField(max_length=100)
last_name = forms.CharField(max_length=100)

class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 
'password2')


class CustomSignUpPage(forms.ModelForm):
Contact = forms.CharField(max_length=10)

class Meta:
model = SignUp
fields = ('Contact', )
views.py-def register_user(request):
if request.method == "POST":
form = SignUpForm(request.POST)
cus_form = CustomSignUpPage(request.POST)
if form.is_valid() and cus_form.is_valid():
save1 = form.save()
save1.refresh_from_db()
cus_form = CustomSignUpPage(request.POST, 
instance=request.save1.signup.contact)
cus_form.full_clean()
cus_form.save()
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
user = authenticate(request, username=username, password=password)
login(request, user)
messages.success(request, f'Registration successful')
return redirect('home')
else:
messages.error(request, f'Please correct the error below.')
else:
form = SignUpForm()
cus_form = CustomSignUpPage()

return render(request, 'authenticate\\register.html', context={'form': 
form, 'cus_form': cus_form})Screenshot from the admin panel:
Please suggest. If you are comfortable we can go on a web meeting where I can 
share my screen and we can work on it.
Regards,Amitesh

Sent from Yahoo Mail on Android 
 
  On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno wrote:   
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> However, the signal that I have written seems not to be working.
>> Whenever, I am filling the form, I am getting below error:
>>
>> AttributeError at /auth/register/
>> 'User' object has no attribute 'profile'
>>
>> *Full traceback log as below:*
>>
>> Installed Applications:
>> ['django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'phone_field',
>>  'AUTHENTICATION']
>> Installed Middleware:
>> ['django.middleware.security.SecurityMiddleware',
>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>>
>>
>>
>> Traceback (most recent call last):
>>  File "C:\Python38\lib\site-packages\django\core\handlers\exception.py",
>>
>> line 34, in inner
>>    response = get_response(request)
>>  File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
>>
>> 115, in _get_response
>>    

Re: Reg: Django signal not working

2020-04-19 Thread Jorge Gimeno
Amitesh,

Where is User.profile defined?

-Jorge

On 4/18/20, Saurabh Ranjan Singh  wrote:
> I am having the same issue. Please fix it.
>
> On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>>
>> Hi,
>>
>> I am creating a Django signup form through "User" model and
>> "UserCreationForm" and customized the User model to accommodate single
>> user
>> defined field "contact".
>>
>> However, the signal that I have written seems not to be working.
>> Whenever, I am filling the form, I am getting below error:
>>
>> AttributeError at /auth/register/
>> 'User' object has no attribute 'profile'
>>
>> *Full traceback log as below:*
>>
>> Installed Applications:
>> ['django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'phone_field',
>>  'AUTHENTICATION']
>> Installed Middleware:
>> ['django.middleware.security.SecurityMiddleware',
>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>>
>>
>>
>> Traceback (most recent call last):
>>   File "C:\Python38\lib\site-packages\django\core\handlers\exception.py",
>>
>> line 34, in inner
>> response = get_response(request)
>>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
>>
>> 115, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
>>
>> 113, in _get_response
>> response = wrapped_callback(request, *callback_args,
>> **callback_kwargs)
>>   File "C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\views.py",
>>
>> line 50, in register_user
>> save1 = form.save()
>>   File "C:\Python38\lib\site-packages\django\contrib\auth\forms.py", line
>>
>> 137, in save
>> user.save()
>>   File "C:\Python38\lib\site-packages\django\contrib\auth\base_user.py",
>> line 66, in save
>> super().save(*args, **kwargs)
>>   File "C:\Python38\lib\site-packages\django\db\models\base.py", line 745,
>>
>> in save
>> self.save_base(using=using, force_insert=force_insert,
>>   File "C:\Python38\lib\site-packages\django\db\models\base.py", line 793,
>>
>> in save_base
>> post_save.send(
>>   File "C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line
>>
>> 173, in send
>> return [
>>   File "C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line
>>
>> 174, in 
>> (receiver, receiver(signal=self, sender=sender, **named))
>>   File "C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\models.py",
>>
>> line 17, in save_user_profile
>> instance.profile.save()
>>
>> Exception Type: AttributeError at /auth/register/
>> Exception Value: 'User' object has no attribute 'profile'
>>
>> I have uploaded the project in google drive with below location link, just
>>
>> in case if somebody wishes to test it.
>>
>>
>> https://drive.google.com/file/d/1COB3BBoRb95a85cLi9k1PdIYD3bmlnc0/view?usp=sharing
>>
>> My environment:
>>
>> Django==3.0.5 python 3.8.2
>>
>> Not sure what is the mistake. Please help.
>>
>> *models.py*
>>
>> from django.db import models
>> from django.contrib.auth.models import User
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>>
>> class SignUp(models.Model):
>> user = models.OneToOneField(User, on_delete=models.CASCADE)
>> Contact = models.TextField(max_length=500, blank=True)
>>
>> @receiver(post_save, sender=User)
>> def create_user_profile(sender, instance, created, **kwargs):
>> if created:
>> SignUp.objects.create(user=instance)
>>
>> @receiver(post_save, sender=User)
>> def save_user_profile(sender, instance, **kwargs):
>> *instance.profile.save()*
>>
>> *forms.py*
>>
>> from django.contrib.auth.forms import UserCreationForm
>> from django.contrib.auth.models import User
>> from django import forms
>> from  .models import SignUp
>>
>> class SignUpForm(UserCreationForm):
>> email = forms.EmailField()
>> first_name = forms.CharField(max_length=100)
>> last_name = forms.CharField(max_length=100)
>> #phone = format()
>>
>> class Meta:
>> model = User
>> fields = ('username', 'first_name', 'last_name', 'email',
>> 'password1', 'password2')
>>
>>
>> class CustomSignUpPage(forms.ModelForm):
>> Contact = forms.CharField(max_length=10)
>> class Meta:
>> model = SignUp
>> fields = ('Contact', )
>>
>> *views.py*
>>
>> from django.shortcuts import render, redirect
>> from django.contrib.auth import authenticate, login, logout
>> from django.contrib import messages
>> #from django.contrib.auth.forms import UserCreationForm
>> from .forms import 

Re: Reg: Django signal not working

2020-04-18 Thread Saurabh Ranjan Singh
I am having the same issue. Please fix it.

On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>
> Hi,
>
> I am creating a Django signup form through "User" model and 
> "UserCreationForm" and customized the User model to accommodate single user 
> defined field "contact".
>
> However, the signal that I have written seems not to be working.
> Whenever, I am filling the form, I am getting below error:
>
> AttributeError at /auth/register/
> 'User' object has no attribute 'profile'
>
> *Full traceback log as below:*
>
> Installed Applications:
> ['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'phone_field',
>  'AUTHENTICATION']
> Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>
>
>
> Traceback (most recent call last):
>   File "C:\Python38\lib\site-packages\django\core\handlers\exception.py", 
> line 34, in inner
> response = get_response(request)
>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 
> 115, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 
> 113, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\views.py", 
> line 50, in register_user
> save1 = form.save()
>   File "C:\Python38\lib\site-packages\django\contrib\auth\forms.py", line 
> 137, in save
> user.save()
>   File "C:\Python38\lib\site-packages\django\contrib\auth\base_user.py", 
> line 66, in save
> super().save(*args, **kwargs)
>   File "C:\Python38\lib\site-packages\django\db\models\base.py", line 745, 
> in save
> self.save_base(using=using, force_insert=force_insert,
>   File "C:\Python38\lib\site-packages\django\db\models\base.py", line 793, 
> in save_base
> post_save.send(
>   File "C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line 
> 173, in send
> return [
>   File "C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line 
> 174, in 
> (receiver, receiver(signal=self, sender=sender, **named))
>   File "C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\models.py", 
> line 17, in save_user_profile
> instance.profile.save()
>
> Exception Type: AttributeError at /auth/register/
> Exception Value: 'User' object has no attribute 'profile'
>
> I have uploaded the project in google drive with below location link, just 
> in case if somebody wishes to test it.
>
>
> https://drive.google.com/file/d/1COB3BBoRb95a85cLi9k1PdIYD3bmlnc0/view?usp=sharing
>
> My environment:
>
> Django==3.0.5 python 3.8.2
>
> Not sure what is the mistake. Please help.
>
> *models.py*
>
> from django.db import models
> from django.contrib.auth.models import User
> from django.db.models.signals import post_save
> from django.dispatch import receiver
>
> class SignUp(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> Contact = models.TextField(max_length=500, blank=True)
>
> @receiver(post_save, sender=User)
> def create_user_profile(sender, instance, created, **kwargs):
> if created:
> SignUp.objects.create(user=instance)
>
> @receiver(post_save, sender=User)
> def save_user_profile(sender, instance, **kwargs):
> *instance.profile.save()*
>
> *forms.py*
>
> from django.contrib.auth.forms import UserCreationForm
> from django.contrib.auth.models import User
> from django import forms
> from  .models import SignUp
>
> class SignUpForm(UserCreationForm):
> email = forms.EmailField()
> first_name = forms.CharField(max_length=100)
> last_name = forms.CharField(max_length=100)
> #phone = format()
>
> class Meta:
> model = User
> fields = ('username', 'first_name', 'last_name', 'email', 
> 'password1', 'password2')
>
>
> class CustomSignUpPage(forms.ModelForm):
> Contact = forms.CharField(max_length=10)
> class Meta:
> model = SignUp
> fields = ('Contact', )
>
> *views.py*
>
> from django.shortcuts import render, redirect
> from django.contrib.auth import authenticate, login, logout
> from django.contrib import messages
> #from django.contrib.auth.forms import UserCreationForm
> from .forms import SignUpForm, CustomSignUpPage
>
> def home(request):
>return render(request, 'authenticate\home.html', {})
>
> def login_user(request):
>if request.method == 'POST':
>   username = request.POST['username']
>   password = 

Reg: Django signal not working

2020-04-17 Thread 'Amitesh Sahay' via Django users
Hi,
I am creating a Django signup form through "User" model and "UserCreationForm" 
and customized the User model to accommodate single user defined field 
"contact".

However, the signal that I have written seems not to be working.
Whenever, I am filling the form, I am getting below error:
AttributeError at /auth/register/'User' object has no attribute 'profile'
Full traceback log as below:
Installed Applications:['django.contrib.admin', 'django.contrib.auth', 
'django.contrib.contenttypes', 'django.contrib.sessions', 
'django.contrib.messages', 'django.contrib.staticfiles', 'phone_field', 
'AUTHENTICATION']Installed 
Middleware:['django.middleware.security.SecurityMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.common.CommonMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware', 
'django.middleware.clickjacking.XFrameOptionsMiddleware']


Traceback (most recent call last):  File 
"C:\Python38\lib\site-packages\django\core\handlers\exception.py", line 34, in 
inner    response = get_response(request)  File 
"C:\Python38\lib\site-packages\django\core\handlers\base.py", line 115, in 
_get_response    response = self.process_exception_by_middleware(e, request)  
File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line 113, in 
_get_response    response = wrapped_callback(request, *callback_args, 
**callback_kwargs)  File 
"C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\views.py", line 50, in 
register_user    save1 = form.save()  File 
"C:\Python38\lib\site-packages\django\contrib\auth\forms.py", line 137, in save 
   user.save()  File 
"C:\Python38\lib\site-packages\django\contrib\auth\base_user.py", line 66, in 
save    super().save(*args, **kwargs)  File 
"C:\Python38\lib\site-packages\django\db\models\base.py", line 745, in save    
self.save_base(using=using, force_insert=force_insert,  File 
"C:\Python38\lib\site-packages\django\db\models\base.py", line 793, in 
save_base    post_save.send(  File 
"C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line 173, in 
send    return [  File 
"C:\Python38\lib\site-packages\django\dispatch\dispatcher.py", line 174, in 
    (receiver, receiver(signal=self, sender=sender, **named))  File 
"C:\Users\anshu\djago-project\SkoolSkill\AUTHENTICATION\models.py", line 17, in 
save_user_profile    instance.profile.save()
Exception Type: AttributeError at /auth/register/Exception Value: 'User' object 
has no attribute 'profile'
I have uploaded the project in google drive with below location link, just in 
case if somebody wishes to test it.
https://drive.google.com/file/d/1COB3BBoRb95a85cLi9k1PdIYD3bmlnc0/view?usp=sharing
My environment:
Django==3.0.5 python 3.8.2
Not sure what is the mistake. Please help.
models.py
from django.db import modelsfrom django.contrib.auth.models import Userfrom 
django.db.models.signals import post_savefrom django.dispatch import receiver
class SignUp(models.Model):    user = models.OneToOneField(User, 
on_delete=models.CASCADE)    Contact = models.TextField(max_length=500, 
blank=True)
@receiver(post_save, sender=User)def create_user_profile(sender, instance, 
created, **kwargs):    if created:        SignUp.objects.create(user=instance)
@receiver(post_save, sender=User)def save_user_profile(sender, instance, 
**kwargs):    instance.profile.save()
forms.py
from django.contrib.auth.forms import UserCreationFormfrom 
django.contrib.auth.models import Userfrom django import formsfrom  .models 
import SignUp
class SignUpForm(UserCreationForm):    email = forms.EmailField()    first_name 
= forms.CharField(max_length=100)    last_name = 
forms.CharField(max_length=100)#    phone = format()
    class Meta:        model = User        fields = ('username', 'first_name', 
'last_name', 'email', 'password1', 'password2')

class CustomSignUpPage(forms.ModelForm):    Contact = 
forms.CharField(max_length=10)    class Meta:        model = SignUp        
fields = ('Contact', )
views.py
from django.shortcuts import render, redirectfrom django.contrib.auth import 
authenticate, login, logoutfrom django.contrib import messages#from 
django.contrib.auth.forms import UserCreationFormfrom .forms import SignUpForm, 
CustomSignUpPage
def home(request):   return render(request, 'authenticate\home.html', {})
def login_user(request):   if request.method == 'POST':      username = 
request.POST['username']      password = request.POST['password']      user = 
authenticate(request, username=username, password=password)      if user is not 
None:         login(request, user)         messages.success(request, ('login 
success'))         return redirect('home')      else:         
messages.success(request, ('error while login, please try again'))         
return redirect('login')   else:      return render(request, 
'authenticate\login.html', {})
def logout_user(request):   

Re: angular setup for django (routes not working)

2019-12-30 Thread Andréas Kühne
Hi,

You can't have the routes for the frontend and the backend. For example:

/clients/1/ in urls.py and in the angular routes. Then it all goes back to
who gets the route first.

For this example the frontend should have:
/clients/:id/

and the backend should:
/api/clients/id/

Regards,

Andréas


Den sön 29 dec. 2019 kl 14:39 skrev nitish kumar :

> we have a web app which is hosted in apache mod_wsgi.
>
> I am trying to update some of the app functionality/UI with angular 8.
>
> everything works of but angular routes are not working , which is
> important for single-page app
>
>
>
>
> On Friday, 27 December 2019 20:50:42 UTC+5:30, lemme smash wrote:
>>
>> you doing something strange.
>> usually, when you want to setup angluar with django, you just using `ng
>> serve` to handle all the interface, and just use django for data and api.
>> it's not a good idea to render angular app with django
>>
>> On Thursday, December 26, 2019 at 4:05:14 PM UTC+3, nitish kumar wrote:
>>>
>>> Hi
>>>
>>>
>>> I am trying to integrate angular8 with Django (2.2.4).
>>>
>>>
>>> *Django side*:
>>>
>>> URL and view will load angular 'index.html'
>>>
>>> *angular:*
>>>
>>> some router-links.
>>> based on URL pattern page is getting loaded.
>>>
>>>
>>> *problem statement:*
>>>
>>> *if host only angular code using 'ng serve' router-link only load's
>>> particular component instead of loading all links in the index.html file*
>>> *but when I host in Django router-link is loading the entire page again
>>> (i can see this in developers tools network tab)*
>>>
>>> *can some please help..*
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/37f1e12f-c6fd-4f83-bb3e-086e05e7a801%40googlegroups.com
> 
> .
>

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


Re: angular setup for django (routes not working)

2019-12-29 Thread nitish kumar
we have a web app which is hosted in apache mod_wsgi.

I am trying to update some of the app functionality/UI with angular 8.

everything works of but angular routes are not working , which is important 
for single-page app




On Friday, 27 December 2019 20:50:42 UTC+5:30, lemme smash wrote:
>
> you doing something strange.
> usually, when you want to setup angluar with django, you just using `ng 
> serve` to handle all the interface, and just use django for data and api. 
> it's not a good idea to render angular app with django
>
> On Thursday, December 26, 2019 at 4:05:14 PM UTC+3, nitish kumar wrote:
>>
>> Hi 
>>
>>
>> I am trying to integrate angular8 with Django (2.2.4).
>>
>>
>> *Django side*:
>>
>> URL and view will load angular 'index.html'
>>
>> *angular:*
>>
>> some router-links.
>> based on URL pattern page is getting loaded.
>>
>>
>> *problem statement:*
>>
>> *if host only angular code using 'ng serve' router-link only load's 
>> particular component instead of loading all links in the index.html file*
>> *but when I host in Django router-link is loading the entire page again 
>> (i can see this in developers tools network tab)*
>>
>> *can some please help..*
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/37f1e12f-c6fd-4f83-bb3e-086e05e7a801%40googlegroups.com.


Re: angular setup for django (routes not working)

2019-12-27 Thread lemme smash
you doing something strange.
usually, when you want to setup angluar with django, you just using `ng 
serve` to handle all the interface, and just use django for data and api. 
it's not a good idea to render angular app with django

On Thursday, December 26, 2019 at 4:05:14 PM UTC+3, nitish kumar wrote:
>
> Hi 
>
>
> I am trying to integrate angular8 with Django (2.2.4).
>
>
> *Django side*:
>
> URL and view will load angular 'index.html'
>
> *angular:*
>
> some router-links.
> based on URL pattern page is getting loaded.
>
>
> *problem statement:*
>
> *if host only angular code using 'ng serve' router-link only load's 
> particular component instead of loading all links in the index.html file*
> *but when I host in Django router-link is loading the entire page again (i 
> can see this in developers tools network tab)*
>
> *can some please help..*
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b312fb36-f64b-4047-ba12-8f34867e369d%40googlegroups.com.


angular setup for django (routes not working)

2019-12-26 Thread nitish kumar
Hi 


I am trying to integrate angular8 with Django (2.2.4).


*Django side*:

URL and view will load angular 'index.html'

*angular:*

some router-links.
based on URL pattern page is getting loaded.


*problem statement:*

*if host only angular code using 'ng serve' router-link only load's 
particular component instead of loading all links in the index.html file*
*but when I host in Django router-link is loading the entire page again (i 
can see this in developers tools network tab)*

*can some please help..*

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a6616a4c-88a2-4211-a23f-a2fb14db37c3%40googlegroups.com.


Re: Generic Views in Django Tutorial Not Working

2019-11-01 Thread Nijo Joseph


class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_question_list'

def get_queryset(self):
"""Return the last five published questions."""
return Question.objects.order_by('-pub_date')[:5]


the def get_queryset(self): function is missing. check the indendation as well. 
always produce the code snippet.


On Friday, November 1, 2019 at 5:19:29 PM UTC+5:30, Mike Starr wrote:
>
> Hi! There's a lot of error message to copy and paste so please request 
> what you would like to see specifically. I am at 
> https://docs.djangoproject.com/en/2.2/intro/tutorial04/#use-generic-views-less-code-is-better
>  in 
> the Django tutorial and it seems replacing HTTPRequests with GenericViews 
> broke the web server. I followed the instructions and now have this:
>
> ImproperlyConfigured at /polls/
>
> IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, 
> or override IndexView.get_queryset().
>
> Request Method: GET
> Request URL: http://localhost:8000/polls/
> Django Version: 2.2.4
> Exception Type: ImproperlyConfigured
> Exception Value: 
>
> IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, 
> or override IndexView.get_queryset().
>
> Exception Location: E:\computer 
> stuff\python\lib\site-packages\django\views\generic\list.py in 
> get_queryset, line 39
> Python Executable: E:\computer stuff\python\python.exe
> Python Version: 3.7.3
> Python Path: 
>
> ['E:\\computer stuff\\python\\Django\\mysite',
>  'E:\\computer stuff\\python',
>  'E:\\computer stuff\\python\\Lib',
>  'E:\\computer stuff\\python\\Django\\mysite',
>  'E:\\computer stuff\\python\\python37.zip',
>  'E:\\computer stuff\\python\\DLLs',
>  'E:\\computer stuff\\python\\lib\\site-packages',
>  'E:\\computer stuff\\python\\lib\\site-packages\\scrapy-1.5.0-py3.7.egg',
>  'E:\\computer '
>  'stuff\\python\\lib\\site-packages\\service_identity-18.1.0-py3.7.egg',
>  'E:\\computer 
> stuff\\python\\lib\\site-packages\\pydispatcher-2.0.5-py3.7.egg',
>  'E:\\computer stuff\\python\\lib\\site-packages\\parsel-1.5.1-py3.7.egg',
>  'E:\\computer stuff\\python\\lib\\site-packages\\six-1.12.0-py3.7.egg',
>  'E:\\computer stuff\\python\\lib\\site-packages\\cssselect-1.0.3-py3.7.egg',
>  'E:\\computer stuff\\python\\lib\\site-packages\\pyopenssl-19.0.0-py3.7.egg',
>  'E:\\computer '
>  'stuff\\python\\lib\\site-packages\\lxml-4.3.4-py3.7-win-amd64.egg',
>  'E:\\computer stuff\\python\\lib\\site-packages\\queuelib-1.5.0-py3.7.egg',
>  'E:\\computer stuff\\python\\lib\\site-packages\\w3lib-1.20.0-py3.7.egg',
>  'E:\\computer '
>  'stuff\\python\\lib\\site-packages\\pyasn1_modules-0.2.5-py3.7.egg',
>  'E:\\computer stuff\\python\\lib\\site-packages\\win32',
>  'E:\\computer stuff\\python\\lib\\site-packages\\win32\\lib',
>  'E:\\computer stuff\\python\\lib\\site-packages\\Pythonwin']
>
> Server time: Fri, 1 Nov 2019 01:03:42 -0700
> Traceback Switch to copy-and-paste view 
>
>- E:\computer 
>stuff\python\lib\site-packages\django\core\handlers\exception.py in 
>inner
>1. 
>   
>   response = get_response(request)
>   
>   …
>▶ Local vars 
>- E:\computer 
>stuff\python\lib\site-packages\django\core\handlers\base.py in 
>_get_response
>1. 
>   
>   response = self.process_exception_by_middleware(e, 
> request)
>   
>   …
>▶ Local vars 
>- E:\computer 
>stuff\python\lib\site-packages\django\core\handlers\base.py in 
>_get_response
>1. 
>   
>   response = wrapped_callback(request, *callback_args, 
> **callback_kwargs)
>   
>   …
>▶ Local vars 
>- E:\computer 
>stuff\python\lib\site-packages\django\views\generic\base.py in view
>1. 
>   
>   return self.dispatch(request, *args, **kwargs)
>   
>   …
>▶ Local vars 
>- E:\computer 
>stuff\python\lib\site-packages\django\views\generic\base.py in dispatch
>1. 
>   
>   return handler(request, *args, **kwargs)
>   
>   …
>▶ Local vars 
>- E:\computer 
>stuff\python\lib\site-packages\django\views\generic\list.py in get
>1. 
>   
>   self.object_list = self.get_queryset()
>   
>   …
>▶ Local vars 
>- E:\computer 
>stuff\python\lib\site-packages\django\views\generic\list.py in 
>get_queryset
>1. 
>   
>   'cls': self.__class__.__name__
>   
>   …
>▶ Local vars 
>
> Request informationUSER
>
> admin
> GET
>
> No GET data
> POST
>
> No POST data
>
>
>
>
>
>
> for http://localhost:8000/polls/
>
>
>
>
>
>
>
>
>
>
>
>
>
> but polls.1 works:

Re: Generic Views in Django Tutorial Not Working

2019-11-01 Thread Kasper Laudrup

Hi Mike,

On 01/11/2019 09.14, Mike Starr wrote:
Hi! There's a lot of error message to copy and paste so please request 
what you would like to see specifically. I am at 
https://docs.djangoproject.com/en/2.2/intro/tutorial04/#use-generic-views-less-code-is-better in 
the Django tutorial and it seems replacing HTTPRequests with 
GenericViews broke the web server. I followed the instructions and now 
have this:


Have you tried doing as the error message suggests:



IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, or 
override IndexView.get_queryset().



?

Kind regards,

Kasper Laudrup

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f49b74ab-3b63-ebdc-edbf-990a07ef37c4%40stacktrace.dk.


Generic Views in Django Tutorial Not Working

2019-11-01 Thread Mike Starr
Hi! There's a lot of error message to copy and paste so please request what 
you would like to see specifically. I am at 
https://docs.djangoproject.com/en/2.2/intro/tutorial04/#use-generic-views-less-code-is-better
 in 
the Django tutorial and it seems replacing HTTPRequests with GenericViews 
broke the web server. I followed the instructions and now have this:

ImproperlyConfigured at /polls/

IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, or 
override IndexView.get_queryset().

Request Method: GET
Request URL: http://localhost:8000/polls/
Django Version: 2.2.4
Exception Type: ImproperlyConfigured
Exception Value: 

IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, or 
override IndexView.get_queryset().

Exception Location: E:\computer 
stuff\python\lib\site-packages\django\views\generic\list.py in 
get_queryset, line 39
Python Executable: E:\computer stuff\python\python.exe
Python Version: 3.7.3
Python Path: 

['E:\\computer stuff\\python\\Django\\mysite',
 'E:\\computer stuff\\python',
 'E:\\computer stuff\\python\\Lib',
 'E:\\computer stuff\\python\\Django\\mysite',
 'E:\\computer stuff\\python\\python37.zip',
 'E:\\computer stuff\\python\\DLLs',
 'E:\\computer stuff\\python\\lib\\site-packages',
 'E:\\computer stuff\\python\\lib\\site-packages\\scrapy-1.5.0-py3.7.egg',
 'E:\\computer '
 'stuff\\python\\lib\\site-packages\\service_identity-18.1.0-py3.7.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\pydispatcher-2.0.5-py3.7.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\parsel-1.5.1-py3.7.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\six-1.12.0-py3.7.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\cssselect-1.0.3-py3.7.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\pyopenssl-19.0.0-py3.7.egg',
 'E:\\computer '
 'stuff\\python\\lib\\site-packages\\lxml-4.3.4-py3.7-win-amd64.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\queuelib-1.5.0-py3.7.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\w3lib-1.20.0-py3.7.egg',
 'E:\\computer '
 'stuff\\python\\lib\\site-packages\\pyasn1_modules-0.2.5-py3.7.egg',
 'E:\\computer stuff\\python\\lib\\site-packages\\win32',
 'E:\\computer stuff\\python\\lib\\site-packages\\win32\\lib',
 'E:\\computer stuff\\python\\lib\\site-packages\\Pythonwin']

Server time: Fri, 1 Nov 2019 01:03:42 -0700
Traceback Switch to copy-and-paste view 

   - E:\computer 
   stuff\python\lib\site-packages\django\core\handlers\exception.py in inner
   1. 
  
  response = get_response(request)
  
  …
   ▶ Local vars 
   - E:\computer stuff\python\lib\site-packages\django\core\handlers\base.py
in _get_response
   1. 
  
  response = self.process_exception_by_middleware(e, 
request)
  
  …
   ▶ Local vars 
   - E:\computer stuff\python\lib\site-packages\django\core\handlers\base.py
in _get_response
   1. 
  
  response = wrapped_callback(request, *callback_args, 
**callback_kwargs)
  
  …
   ▶ Local vars 
   - E:\computer stuff\python\lib\site-packages\django\views\generic\base.py
in view
   1. 
  
  return self.dispatch(request, *args, **kwargs)
  
  …
   ▶ Local vars 
   - E:\computer stuff\python\lib\site-packages\django\views\generic\base.py
in dispatch
   1. 
  
  return handler(request, *args, **kwargs)
  
  …
   ▶ Local vars 
   - E:\computer stuff\python\lib\site-packages\django\views\generic\list.py
in get
   1. 
  
  self.object_list = self.get_queryset()
  
  …
   ▶ Local vars 
   - E:\computer stuff\python\lib\site-packages\django\views\generic\list.py
in get_queryset
   1. 
  
  'cls': self.__class__.__name__
  
  …
   ▶ Local vars 
   
Request informationUSER

admin
GET

No GET data
POST

No POST data






for http://localhost:8000/polls/













but polls.1 works:


What's new? Not much
 Nothing
 I don't know
 The best






but voting yields


ValueError at /polls/1/vote/

The view polls.views.vote didn't return an HttpResponse object. It returned 
None instead.

Request Method: POST
Request URL: http://localhost:8000/polls/1/vote/
Django Version: 2.2.4
Exception Type: ValueError
Exception Value: 

The view polls.views.vote didn't return an HttpResponse object. It returned 
None instead.

Exception Location: E:\computer 
stuff\python\lib\site-packages\django\core\handlers\base.py in 
_get_response, line 126
Python Executable: E:\computer stuff\python\python.exe
Python Version: 3.7.3
Python Path: 

['E:\\computer stuff\\python\\Django\\mysite',
 'E:\\computer stuff\\python',
 'E:\\computer 

Re: Django URL not working on my windows 10

2019-10-18 Thread kishor kumar Bharti
use following code  in project urls.py

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

urlpatterns = [
url(r'^$',views.index, name='index'),
url(r'^second_app/',include('second_app.urls')),
url(r'^admin/', admin.site.urls),
]


and use following code in urls.py in app
from django.contrib import admin
from second_app import views
from django.conf.urls import url,include

urlpatterns = [
url(r'^$',views.index,name='index'),
]

On Thu, Oct 17, 2019 at 8:23 PM Muhamed Bešić 
wrote:

> wtf i have done wrong, i'm getting bored, URL mapping not working anyway,
> anyone please, review the files and give a solution
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/478ca311-9b23-4a36-a6e2-018aef44d99d%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMe8XT3qoiuxD6DHe2x_-CeS5JFEG-%3D4NcMg1EGTCpsriJgt%2Bw%40mail.gmail.com.


Re: Django URL not working on my windows 10

2019-10-17 Thread vineet daniel
Scrernshot5 there should.be a comma before name.


On Thu, 17 Oct 2019, 20:26 vineet daniel,  wrote:

> Typo in include in urls.py file instead of incliude it should be include.
> Thats something that i could see immediately.
>
> On Thu, 17 Oct 2019, 20:22 Muhamed Bešić, 
> wrote:
>
>> wtf i have done wrong, i'm getting bored, URL mapping not working anyway,
>> anyone please, review the files and give a solution
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/478ca311-9b23-4a36-a6e2-018aef44d99d%40googlegroups.com
>> 
>> .
>>
>

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


Re: Django URL not working on my windows 10

2019-10-17 Thread vineet daniel
Typo in include in urls.py file instead of incliude it should be include.
Thats something that i could see immediately.

On Thu, 17 Oct 2019, 20:22 Muhamed Bešić, 
wrote:

> wtf i have done wrong, i'm getting bored, URL mapping not working anyway,
> anyone please, review the files and give a solution
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/478ca311-9b23-4a36-a6e2-018aef44d99d%40googlegroups.com
> 
> .
>

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


Re: Django server not working on my windows pc

2019-10-17 Thread Integr@te System
Try to check PATH/enviroment variable and permission of project folders

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3ccb3c59-9f5f-4ea4-a9fd-0cd699ec9ca6%40googlegroups.com.


Re: Django server not working on my windows pc

2019-10-16 Thread Parvez Khan Pathan
send your url mapping snippet code to figure out your silly mistake. It
happens!

On Thu, 17 Oct 2019, 1:56 am Edwin Cooper Van Dyke <
mibnbwsafiei...@gmail.com wrote:

> I do exactly same as tutorial but when I map url, it get either server not
> connected or circular import error, no sr import Error
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fa3a8cd0-fa0e-484b-9403-ddd9211796a3%40googlegroups.com
> .
>

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


Django server not working on my windows pc

2019-10-16 Thread Edwin Cooper Van Dyke
I do exactly same as tutorial but when I map url, it get either server not 
connected or circular import error, no sr import Error

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fa3a8cd0-fa0e-484b-9403-ddd9211796a3%40googlegroups.com.


Django translate_url not working with optional parameters

2019-09-26 Thread NKSM
I am using django 1.11.

My url is:
url(r'^apply(?:/(?P[\d-]+)/(?P[\w-]+))?.html$', applyview, name=
'applyview'),


Line to tranlate url:

translate_url('/nl/job/apply.html', "fr")


Django internal function:

def translate_url(url, lang_code):
"""
Given a URL (absolute or relative), try to get its translated version in
the `lang_code` language (either by i18n_patterns or by translated 
regex).
Return the original URL if no translated version is found.
"""
parsed = urlsplit(url)
try:
match = resolve(parsed.path)
except Resolver404:
pass
else:
to_be_reversed = "%s:%s" % (match.namespace, match.url_name) if 
match.namespace else match.url_name
with override(lang_code):
try:
url = reverse(to_be_reversed, args=match.args, kwargs=match.
kwargs)
except NoReverseMatch:
pass
else:
url = urlunsplit((parsed.scheme, parsed.netloc, url, parsed.
query, parsed.fragment))
return url


Django can not tranlate url  get an error NoReverseMatch because kwargs are 
None. ({'pk': None, 'slug': None}).
By my parameters are optional. 


*Does anyone have an idea, how can that be solved?*


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b2b7fbd8-8ecb-42a3-8fa7-059c5572cbf1%40googlegroups.com.


Django translate_url not working with optional parameters

2019-09-26 Thread NKSM
I am using django 1.11.

My url is:
url(r'^apply(?:/(?P[\d-]+)/(?P[\w-]+))?.html$', applyview, name=
'applyview'),


Line to tranlate url:

translate_url('/nl/job/apply.html', "fr")


Django internal function:

def translate_url(url, lang_code):
"""
Given a URL (absolute or relative), try to get its translated version in
the `lang_code` language (either by i18n_patterns or by translated 
regex).
Return the original URL if no translated version is found.
"""
parsed = urlsplit(url)
try:
match = resolve(parsed.path)
except Resolver404:
pass
else:
to_be_reversed = "%s:%s" % (match.namespace, match.url_name) if 
match.namespace else match.url_name
with override(lang_code):
try:
url = reverse(to_be_reversed, args=match.args, kwargs=match.
kwargs)
except NoReverseMatch:
pass
else:
url = urlunsplit((parsed.scheme, parsed.netloc, url, parsed.
query, parsed.fragment))
return url


Django can not tranlate url  get an error NoReverseMatch because kwargs are 
None. ({'pk': None, 'slug': None}).
By my parameters are optional. 


*Does anyone have an idea, how can that be solved?*


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92288a98-3083-4d3c-a52d-78aa90696557%40googlegroups.com.


Re: Django Redirect Not Working

2019-08-24 Thread Aldian Fazrihady
If that API is accessed via AJAX, then your JS code needs translate status
302 and Location header to JS code that sets "location.href"

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Sat, 24 Aug 2019, 17:49 göktürk sığırtmaç,  wrote:

> Hello, my UserCreate class is create user via CreateAPIView. I want to
> check. if user is auth, auth user directly to 'profile' URI.
>
> class UserCreate(generics.CreateAPIView):
>
> serializer_class = UserCreateSerializer
> permission_classes = (~IsAuthenticated,)
> queryset = User.objects.all()
>
> def __init__(self):
> if IsAuthenticated:
> print("hello")
> redirect("profile/")
>
>
> code above is working print method but not working redirect method.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d9369cce-3734-4bff-ac53-ce785918362b%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAZfY%2B%3D9_Qk%2BGC2vmCaAj_STxRqM4Hf832cEWEySi6WN0w%40mail.gmail.com.


Django Redirect Not Working

2019-08-24 Thread göktürk sığırtmaç
Hello, my UserCreate class is create user via CreateAPIView. I want to 
check. if user is auth, auth user directly to 'profile' URI. 

class UserCreate(generics.CreateAPIView):

serializer_class = UserCreateSerializer
permission_classes = (~IsAuthenticated,)
queryset = User.objects.all()

def __init__(self):
if IsAuthenticated:
print("hello")
redirect("profile/")


code above is working print method but not working redirect method.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d9369cce-3734-4bff-ac53-ce785918362b%40googlegroups.com.


Re: Django is not working

2019-08-22 Thread Mike Dewhirst
Looking at the error below, I would recommend the following:

1. Upgrade pip

2. pip uninstall django

3. Reinstall the previous working version of Django and prove it is working

4. Restart the machine

5. Re-install Django 1.11.22

The traceback says it cannot find the contrib module which possibly means 
the upgrade to 1.11.22 didn't complete correctly the first time. 

Good luck

Mike

On Friday, August 23, 2019 at 7:45:00 AM UTC+10, Tom Gertin wrote:
>
> Hello, I have successfully install Django 1.11.22. However, I believe 
> something is wrong because I cannot get the command that lists its version 
> to work, in addition the manage.py help command also produces the same 
> error. Here is the error.
>
> $ pip install Django==1.11.22
> DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 
> 2020. Please upgrade your Python as Python 2.7 won't be maintained after 
> that date. A future version of pip will drop support for Python 2.7.
> Collecting Django==1.11.22
>   Using cached 
> https://files.pythonhosted.org/packages/70/22/237da71dc112f2bba335c18380bc403fba430c44cc4da088824e77652738/Django-1.11.22-py2.py3-none-any.whl
> Requirement already satisfied: pytz in 
> /home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages (from 
> Django==1.11.22) (2019.1)
> Installing collected packages: Django
>   Found existing installation: Django 1.11.21
> Uninstalling Django-1.11.21:
>   Successfully uninstalled Django-1.11.21
> Successfully installed Django-1.11.22
> WARNING: You are using pip version 19.1.1, however version 19.2.2 is 
> available.
> You should consider upgrading via the 'pip install --upgrade pip' command.
> $ python -m django --version
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
> "__main__", fname, loader, pkg_name)
>   File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
> exec code in run_globals
>   File 
> "/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages/django/__main__.py",
>  
> line 9, in 
> management.execute_from_command_line()
>   File 
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 364, in execute_from_command_line
> utility.execute()
>   File 
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 338, in execute
> django.setup()
>   File 
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/__init__.py",
>  
> line 27, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/registry.py",
>  
> line 85, in populate
> app_config = AppConfig.create(entry)
>   File 
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/config.py",
>  
> line 120, in create
> mod = import_module(mod_path)
>   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in 
> import_module
> __import__(name)
> ImportError: No module named contrib
>
> Help would be appreciated. Also, what is odd is that if I enter the python 
> console, I can import django and print out the version.
>
> Thanks,
>
> Tom
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/860ed78d-c46b-4350-8889-cb92cc18d211%40googlegroups.com.


Re: Django is not working

2019-08-22 Thread 'Akash Sinha' via Django users
You are using python 2.7 with Django , I will suggest you should use python 3.6 
or above.

Sent from Yahoo Mail on Android 
 
  On Fri, Aug 23, 2019 at 3:14 AM, Tom Gertin wrote:   
Hello, I have successfully install Django 1.11.22. However, I believe something 
is wrong because I cannot get the command that lists its version to work, in 
addition the manage.py help command also produces the same error. Here is the 
error.
$ pip install Django==1.11.22DEPRECATION: Python 2.7 will reach the end of its 
life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be 
maintained after that date. A future version of pip will drop support for 
Python 2.7.Collecting Django==1.11.22  Using cached 
https://files.pythonhosted.org/packages/70/22/237da71dc112f2bba335c18380bc403fba430c44cc4da088824e77652738/Django-1.11.22-py2.py3-none-any.whlRequirement
 already satisfied: pytz in 
/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages (from 
Django==1.11.22) (2019.1)Installing collected packages: Django  Found existing 
installation: Django 1.11.21    Uninstalling Django-1.11.21:      Successfully 
uninstalled Django-1.11.21Successfully installed Django-1.11.22WARNING: You are 
using pip version 19.1.1, however version 19.2.2 is available.You should 
consider upgrading via the 'pip install --upgrade pip' command.$ python -m 
django --versionTraceback (most recent call last):  File 
"/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main    "__main__", 
fname, loader, pkg_name)  File "/usr/lib/python2.7/runpy.py", line 72, in 
_run_code    exec code in run_globals  File 
"/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages/django/__main__.py", 
line 9, in     management.execute_from_command_line()  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 364, in execute_from_command_line    utility.execute()  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 338, in execute    django.setup()  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/__init__.py",
 line 27, in setup    apps.populate(settings.INSTALLED_APPS)  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/registry.py",
 line 85, in populate    app_config = AppConfig.create(entry)  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/config.py",
 line 120, in create    mod = import_module(mod_path)  File 
"/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module    
__import__(name)ImportError: No module named contrib
Help would be appreciated. Also, what is odd is that if I enter the python 
console, I can import django and print out the version.
Thanks,
Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/471a2ef7-8032-420f-8fd2-027f005d1d55%40googlegroups.com.
  

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


Re: Django is not working

2019-08-22 Thread Gerardo Palazuelos Guerrero
hi Tom,
Not sure what exactly configuration you have, but text you sent says you
have python 2.7 and somehow a virtual environment (venv) is mentioned in
the stacktrace.
I don't use python 2.7, so my following suggestions considers a recent
version.

May i suggest you to check djangogirls for proper installation.
Also:
https://www.obeythetestinggoat.com/book/pre-requisite-installations.html
https://djangoforbeginners.com/initial-setup/

good luck.
--
Gerardo Palazuelos Guerrero



On Thu, Aug 22, 2019 at 3:44 PM Tom Gertin  wrote:

> Hello, I have successfully install Django 1.11.22. However, I believe
> something is wrong because I cannot get the command that lists its version
> to work, in addition the manage.py help command also produces the same
> error. Here is the error.
>
> $ pip install Django==1.11.22
> DEPRECATION: Python 2.7 will reach the end of its life on January 1st,
> 2020. Please upgrade your Python as Python 2.7 won't be maintained after
> that date. A future version of pip will drop support for Python 2.7.
> Collecting Django==1.11.22
>   Using cached
> https://files.pythonhosted.org/packages/70/22/237da71dc112f2bba335c18380bc403fba430c44cc4da088824e77652738/Django-1.11.22-py2.py3-none-any.whl
> Requirement already satisfied: pytz in
> /home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages (from
> Django==1.11.22) (2019.1)
> Installing collected packages: Django
>   Found existing installation: Django 1.11.21
> Uninstalling Django-1.11.21:
>   Successfully uninstalled Django-1.11.21
> Successfully installed Django-1.11.22
> WARNING: You are using pip version 19.1.1, however version 19.2.2 is
> available.
> You should consider upgrading via the 'pip install --upgrade pip' command.
> $ python -m django --version
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
> "__main__", fname, loader, pkg_name)
>   File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
> exec code in run_globals
>   File
> "/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages/django/__main__.py",
> line 9, in 
> management.execute_from_command_line()
>   File
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 364, in execute_from_command_line
> utility.execute()
>   File
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 338, in execute
> django.setup()
>   File
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/__init__.py",
> line 27, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/registry.py",
> line 85, in populate
> app_config = AppConfig.create(entry)
>   File
> "/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/config.py",
> line 120, in create
> mod = import_module(mod_path)
>   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
> import_module
> __import__(name)
> ImportError: No module named contrib
>
> Help would be appreciated. Also, what is odd is that if I enter the python
> console, I can import django and print out the version.
>
> Thanks,
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/471a2ef7-8032-420f-8fd2-027f005d1d55%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJ8iCyMQbzs5n7g-eE%3D-WP475qQDVqcDzhSQRfzbJieb9iS2rQ%40mail.gmail.com.


Django is not working

2019-08-22 Thread Tom Gertin
Hello, I have successfully install Django 1.11.22. However, I believe 
something is wrong because I cannot get the command that lists its version 
to work, in addition the manage.py help command also produces the same 
error. Here is the error.

$ pip install Django==1.11.22
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 
2020. Please upgrade your Python as Python 2.7 won't be maintained after 
that date. A future version of pip will drop support for Python 2.7.
Collecting Django==1.11.22
  Using cached 
https://files.pythonhosted.org/packages/70/22/237da71dc112f2bba335c18380bc403fba430c44cc4da088824e77652738/Django-1.11.22-py2.py3-none-any.whl
Requirement already satisfied: pytz in 
/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages (from 
Django==1.11.22) (2019.1)
Installing collected packages: Django
  Found existing installation: Django 1.11.21
Uninstalling Django-1.11.21:
  Successfully uninstalled Django-1.11.21
Successfully installed Django-1.11.22
WARNING: You are using pip version 19.1.1, however version 19.2.2 is 
available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ python -m django --version
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
  File 
"/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages/django/__main__.py", 
line 9, in 
management.execute_from_command_line()
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 364, in execute_from_command_line
utility.execute()
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 338, in execute
django.setup()
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/__init__.py",
 
line 27, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/registry.py",
 
line 85, in populate
app_config = AppConfig.create(entry)
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/config.py",
 
line 120, in create
mod = import_module(mod_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named contrib

Help would be appreciated. Also, what is odd is that if I enter the python 
console, I can import django and print out the version.

Thanks,

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/471a2ef7-8032-420f-8fd2-027f005d1d55%40googlegroups.com.


Re: django makemigrations not working

2018-05-06 Thread Bernard Letourmy
Hello,
If you've got "No changes detected" on makemigrations, it means it did it 
job already (in previous run probably)
can you list and post the content of you migrations folders ?

then if you have errors on makemigrations it would help helping you if you 
would  post the actual error logs.
Those errors can be related to something else, like an issue with you 
configuration or  python environment.
Any conf. changes / pip install before you start having issues with you 
migrations ?

Also what was the reason for you to recreate your migrations files ?
How did you do before that / were your migrations ok ?

/Bernard



On Saturday, 5 May 2018 15:23:47 UTC+2, Gerald Brown wrote:
>
> Yes. I dropped it and then recreated it. 
>
> Then ran "makemigrations" & "migrate". Migrate is now giving me a lot of 
> errors. 
>
> Funny that all of the errors that show up are in lines that contain 
> "**/site-packages/django/**", NOT in any lines of MY code. 
>
>
> On Saturday, 05 May, 2018 09:17 PM, Hervé Edorh wrote: 
> > Do you create another database? 
> > 
>
>

-- 
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/62162729-8c76-4f66-80ef-d001f8e4011e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django makemigrations not working

2018-05-05 Thread Gerald Brown
I tried that too but it kept giving an error about Key constraints. That 
is why I dropped the whole database and then recreated it.  Will just 
have to look in to it more.


Thanks for your reply.

/Who knows what evil lurks in the heart and mind of the computer? *The 
Shadow knows...*/



On Saturday, 05 May, 2018 08:49 PM, Zhenning Lang wrote:
Maybe the contents of table “django_migrations" in you database should 
also be removed. I am not quite sure about it



在 2018年5月5日,下午6:34,Gerald Brown > 写道:


I have dropped my database, deleted all migrations directories and 
when I run ./manage.py makemigrations I get the message "No changes 
detected".


I am using Django 2.04 with Python 3.5.

Any ideas why this is happening?

Thanks.

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, 
send an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/242350cd-a497-4b24-9a0a-728a9b0ae142%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/485B5D48-F693-47EC-A29B-4635ACCBCF46%40sensedeal.ai 
.

For more options, visit https://groups.google.com/d/optout.


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


Re: django makemigrations not working

2018-05-05 Thread Ruhia gr
hello everyone m new to django and am starting my ecommerce project in
djnago .please anyone suggest which is best for ecommerce project(online
shopping)django or django cms



On Sat, May 5, 2018 at 6:19 PM, Zhenning Lang  wrote:

> Maybe the contents of table “django_migrations" in you database should
> also be removed. I am not quite sure about it
>
>
>
> 在 2018年5月5日,下午6:34,Gerald Brown  写道:
>
> I have dropped my database, deleted all migrations directories and when I
> run ./manage.py makemigrations I get the message "No changes detected".
>
> I am using Django 2.04 with Python 3.5.
>
> Any ideas why this is happening?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/242350cd-a497-4b24-9a0a-728a9b0ae142%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/485B5D48-F693-47EC-A29B-4635ACCBCF46%40sensedeal.ai
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: django makemigrations not working

2018-05-05 Thread Zhenning Lang
Maybe the contents of table “django_migrations" in you database should also be 
removed. I am not quite sure about it


> 在 2018年5月5日,下午6:34,Gerald Brown  写道:
> 
> I have dropped my database, deleted all migrations directories and when I run 
> ./manage.py makemigrations I get the message "No changes detected".
> 
> I am using Django 2.04 with Python 3.5.
> 
> Any ideas why this is happening?
> 
> Thanks.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-users@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/242350cd-a497-4b24-9a0a-728a9b0ae142%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

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


Re: django makemigrations not working

2018-05-05 Thread Gerald Brown

Yes. I dropped it and then recreated it.

Then ran "makemigrations" & "migrate". Migrate is now giving me a lot of 
errors.


Funny that all of the errors that show up are in lines that contain 
"**/site-packages/django/**", NOT in any lines of MY code.



On Saturday, 05 May, 2018 09:17 PM, Hervé Edorh wrote:

Do you create another database?



--
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/ef21c56d-4eb3-bc76-2769-d832c9a5a11c%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


django makemigrations not working

2018-05-05 Thread Hervé Edorh
Do you create another database?

-- 
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/034f89e1-8679-46cf-b132-1453ebff6e63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django makemigrations not working

2018-05-05 Thread Gerald Brown
I have dropped my database, deleted all migrations directories and when I 
run ./manage.py makemigrations I get the message "No changes detected".

I am using Django 2.04 with Python 3.5.

Any ideas why this is happening?

Thanks.

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


Re: Django CORS not working.

2018-04-03 Thread Elorm Koku
Which browsers are you using.. it could probably be that cors is disabled
in your browser. Try switching on cors in your browser ...if you don't have
it as an extension just add it up


On Tue, 3 Apr 2018, 11:08 ,  wrote:

> Response in Console:-
>
> Cross-Origin Request Blocked: The Same Origin Policy disallows reading the
> remote resource at
> https://blissedmaths.sgp1.digitaloceanspaces.com/media/topics/4276769703/4276769703.svg.
> (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
>
> I have user django-cors-headers, a Django App that adds CORS (Cross-Origin
> Resource Sharing) headers to responses.
>
> My setting.py file is
>
>
>
>  CORS_ORIGIN_ALLOW_ALL = True
> CORS_ALLOW_CREDENTIALS = True
> CORS_ALLOW_METHODS = (
> 'DELETE',
> 'GET',
> 'OPTIONS',
> 'PATCH',
> 'POST',
> 'PUT',
> )
> CORS_ALLOW_HEADERS = (
> 'accept',
> 'accept-encoding',
> 'authorization',
> 'content-type',
> 'dnt',
> 'origin',
> 'user-agent',
> 'x-csrftoken',
> 'x-requested-with',
> )
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
>
> 'corsheaders.middleware.CorsMiddleware',
> 'django.middleware.common.CommonMiddleware',]
>
>
>
> The image that is giving me error coming from Digital ocean space is
>
>
>
> 
> function fetchXML(url, callback)
> { var xhr = new XMLHttpRequest();
> xhr.open('GET', url, true);
> xhr.withCredentials = true;
> xhr.setRequestHeader('Access-Control-Allow-Origin' , '*');
> console.log(xhr.getAllResponseHeaders)
> xhr.onreadystatechange = function (evt)
> { //Do not explicitly handle errors, those should be //visible via
> console output in the browser.
> if (xhr.readyState === 4) {
> callback(xhr.responseXML); } };
> xhr.send(null); };
>
> fetchXML("{{a.image.url}}",function(newSVGDoc)
> { //import it into the current DOM
> var n = document.importNode(newSVGDoc.documentElement,true);
> document.querySelector('.{{a.topic|slugify}}-image').appendChild(n); });
>
> 
>
> This page is live at https://blissedmaths.com/myclassroom/polynomial/
>
> I have added everything needed in setting.py by still header is not
> coming. I tries Jquery and AJAX also. But no use.
>
> How to fix this. *Is it requires some javascript also or only this
> backend is enough?*
>
> *I tried to add header via Nginx conf also. But didn't worked.* How can I
> solve this, by python code or by Jquery/JS or by server configuration
> files. No method worked for me actually. But image is coming from source. 
> *Please
> provide a fix for this.*
>
>
>
>
> --
> 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/a25fa6f4-4fe4-4abf-8f76-c766b23da74d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Django CORS not working.

2018-04-03 Thread contact
 

Response in Console:- 

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at 
https://blissedmaths.sgp1.digitaloceanspaces.com/media/topics/4276769703/4276769703.svg.
 
(Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I have user django-cors-headers, a Django App that adds CORS (Cross-Origin 
Resource Sharing) headers to responses.

My setting.py file is 



 CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_METHODS = (
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
)
CORS_ALLOW_HEADERS = (
'accept',
'accept-encoding',
'authorization',
'content-type',
'dnt',
'origin',
'user-agent',
'x-csrftoken',
'x-requested-with',
)

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',

'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',]



The image that is giving me error coming from Digital ocean space is 



 
function fetchXML(url, callback) 
{ var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.withCredentials = true;
xhr.setRequestHeader('Access-Control-Allow-Origin' , '*'); 
console.log(xhr.getAllResponseHeaders)
xhr.onreadystatechange = function (evt) 
{ //Do not explicitly handle errors, those should be //visible via console 
output in the browser.
if (xhr.readyState === 4) {
callback(xhr.responseXML); } };
xhr.send(null); }; 

fetchXML("{{a.image.url}}",function(newSVGDoc)
{ //import it into the current DOM 
var n = document.importNode(newSVGDoc.documentElement,true); 
document.querySelector('.{{a.topic|slugify}}-image').appendChild(n); }); 



This page is live at https://blissedmaths.com/myclassroom/polynomial/

I have added everything needed in setting.py by still header is not coming. 
I tries Jquery and AJAX also. But no use.

How to fix this. *Is it requires some javascript also or only this backend 
is enough?*

*I tried to add header via Nginx conf also. But didn't worked.* How can I 
solve this, by python code or by Jquery/JS or by server configuration 
files. No method worked for me actually. But image is coming from source. 
*Please 
provide a fix for this.*




-- 
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/a25fa6f4-4fe4-4abf-8f76-c766b23da74d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to Django, Tutiorial01 not working,

2018-03-29 Thread Marcin Bacławski
u probably run http://localhost:8000/  ,u should  
run http://localhost:8000/polls

-- 
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/794119ab-da2d-4288-96db-12160ab97360%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to Django, Tutiorial01 not working,

2018-03-29 Thread prince gosavi
You need to use the following url *http://localhost:8000/polls/* as you 
have mentioned that you want to go under the "polls/" django parses through 
the urls to find "/polls/"
and if it does not exists it will surely give an error as you are 
requesting things that it does not have.

On Friday, March 30, 2018 at 12:21:03 AM UTC+5:30, Bryan Zimmer wrote:
>
> Hello all,
>
> I managed to get Django and mod_wsgi installed OK. I then followed through 
> with tutorial01, but even though I tried it twice, on two different 
> machines, I have come up blank.
>
> This is the output I am getting for the first cut of Tutorial 01.
>
> I am using Django 2.0.3 with python3.6 and mod_wsgi. 4.6.3:
>
> Page not found (404) 
> Request Method: GET 
> Request URL: http://localhost:8000/ 
>
> Using the URLconf defined in pollapp.urls, Django tried these URL 
> patterns, in this order: 
>
>1. polls/ 
>2. admin/ 
>
> The empty path didn't match any of these. 
>
> You're seeing this error because you have DEBUG = True in your Django 
> settings file. Change that to False, and Django will display a standard 
> 404 page. 
>
>
> Here is my pollap.urls:
>
>
> --
>
> $ cat urls.py
>
>
> """pollapp URL Configuration
>
> The `urlpatterns` list routes URLs to views. For more information please 
> see:
> https://docs.djangoproject.com/en/2.0/topics/http/urls/
> Examples:
> Function views
> 1. Add an import:  from my_app import views
> 2. Add a URL to urlpatterns:  path('', views.home, name='home')
> Class-based views
> 1. Add an import:  from other_app.views import Home
> 2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
> Including another URLconf
> 1. Import the include() function: from django.urls import include, path
> 2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
> """
> from django.contrib import admin
> from django.urls import include, path
>
> urlpatterns = [
> path('polls/',include('polls.urls')),
> path('admin/', admin.site.urls),
> ]
>
> ---
> The other relevant files, which I edited myself, following along with 
> Tutorial01 are included as attachments.
>
>
> I have scoped and squinted, and it still looks to me as though I didn't 
> make any mistakes in editing the source code. 
>
> If I missed something, I'll be embarrassed, but I think I followed the 
> instructions entirely the way they were written.
>
>
>

-- 
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/d6f29157-6ca2-47cc-bef0-9f007f436bff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


New to Django, Tutiorial01 not working,

2018-03-29 Thread Bryan Zimmer
Hello all,

I managed to get Django and mod_wsgi installed OK. I then followed through 
with tutorial01, but even though I tried it twice, on two different 
machines, I have come up blank.

This is the output I am getting for the first cut of Tutorial 01.

I am using Django 2.0.3 with python3.6 and mod_wsgi. 4.6.3:

Page not found (404) 
Request Method: GET 
Request URL: http://localhost:8000/ 

Using the URLconf defined in pollapp.urls, Django tried these URL patterns, 
in this order: 

   1. polls/ 
   2. admin/ 

The empty path didn't match any of these. 

You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page. 


Here is my pollap.urls:

--

$ cat urls.py


"""pollapp URL Configuration

The `urlpatterns` list routes URLs to views. For more information please 
see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import:  from my_app import views
2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
1. Add an import:  from other_app.views import Home
2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('polls/',include('polls.urls')),
path('admin/', admin.site.urls),
]
---
The other relevant files, which I edited myself, following along with 
Tutorial01 are included as attachments.


I have scoped and squinted, and it still looks to me as though I didn't 
make any mistakes in editing the source code. 

If I missed something, I'll be embarrassed, but I think I followed the 
instructions entirely the way they were written.


-- 
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/2bf99879-93ea-41cd-ae3a-d7b894fcd9d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from django.urls import path
from . import views


urlpatterns = [
path('', views.index, name='index')
]

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.


def index(request):
return HttpResponse("Hello, world. You're at the polls index.")



Re: Django view not working for practice project

2018-01-16 Thread Matemática A3K
views.py

>   def index(request):
> latest_comic = Comic.objects.order_by('-comic_pub_date')[:2]
>
> This has an implicit .all(), it's the same than doing

Comic.objects.all().order_by('-comic_pub_date')[:2]

Then you are slicing it for the first 2 records, that's why you see 2
records. Use .first() instead the slicing to get only one record (or
slice 1, [:1] or [0]). Your template code also support several
elements, you should check it


> context = {'latest_comic': latest_comic}
> return HttpResponse(context)
> # return render(request, 'futureFleet/index.html', context) This sends to 
> the template but doesn’t work at the moment
>
>

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


Re: Django view not working for practice project

2018-01-16 Thread Jani Tiainen
Hi.

Could you show your template also?

17.1.2018 6.03 "NorDe"  kirjoitti:

> Context:
>
> I am creating a website to house some webcomics I made as a project to
> practice Django. I am adapting Django's tutorial to create the site (
> https://docs.djangoproject.com/en/2.0/intro/tutorial03/ About halfway
> down the page under "Write views that actually do something"). I am having
> some difficulty getting part of my view to work as expected.
> Expectation:
>
> What I see when I go to http://127.0.0.1:8000/futureFleet/ : latest_comic
>
> What I want to see: A dictionary of my 2 comics.
> Question:
>
> I think I am doing something wrong at this line
>
> context = {'latest_comic': latest_comic}. I am adapting this line from the
> tutorial. I think the line needs to be run to connect to the template. What
> do I do? What am I missing?
> Models.py
>
> class Comic(models.Model):
> #title
> comic_title_text = models.CharField(max_length=200)
> #date
> comic_pub_date = models.DateTimeField('comic date published')
> #image
> comic_location = models.CharField(max_length=200)
> #explanation
> comic_explanation_text = models.CharField(max_length=400, blank=True)
>
> def __str__(self):
> return self.comic_title_text
>
> def was_published_recently(self):
> return self.comic_pub_date >= timezone.now() - 
> datetime.timedelta(days=1)
>
> views.py
>
>   def index(request):
> latest_comic = Comic.objects.order_by('-comic_pub_date')[:2]
> context = {'latest_comic': latest_comic}
> return HttpResponse(context)
> # return render(request, 'futureFleet/index.html', context) This sends to 
> the template but doesn’t work at the moment
>
> Database
>
> "Welcome Aboard" "2018-01-15 21:02:54" "/home/user/Desktop/django/
> djangoFutureFleet/mysite/futureFleet/static/futureFleet/images/1.JPG"
> "this is the first comic"
>
> "Space Vaccine" "2018-01-15 23:02:22" "/home/user/Desktop/django/
> djangoFutureFleet/mysite/futureFleet/static/futureFleet/images/2.JPG"
> "This is comic 2"
>
> --
> 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/31674ff4-a2ab-4f2d-b6cb-9fc7ca9cf9cc%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Django view not working for practice project

2018-01-16 Thread NorDe
Context:

I am creating a website to house some webcomics I made as a project to 
practice Django. I am adapting Django's tutorial to create the site (
https://docs.djangoproject.com/en/2.0/intro/tutorial03/ About halfway down 
the page under "Write views that actually do something"). I am having some 
difficulty getting part of my view to work as expected.
Expectation:

What I see when I go to http://127.0.0.1:8000/futureFleet/ : latest_comic

What I want to see: A dictionary of my 2 comics.
Question:

I think I am doing something wrong at this line

context = {'latest_comic': latest_comic}. I am adapting this line from the 
tutorial. I think the line needs to be run to connect to the template. What 
do I do? What am I missing?
Models.py

class Comic(models.Model):
#title
comic_title_text = models.CharField(max_length=200)
#date
comic_pub_date = models.DateTimeField('comic date published')
#image
comic_location = models.CharField(max_length=200)
#explanation
comic_explanation_text = models.CharField(max_length=400, blank=True)

def __str__(self):
return self.comic_title_text

def was_published_recently(self):
return self.comic_pub_date >= timezone.now() - 
datetime.timedelta(days=1)

views.py

  def index(request):
latest_comic = Comic.objects.order_by('-comic_pub_date')[:2]
context = {'latest_comic': latest_comic}
return HttpResponse(context)
# return render(request, 'futureFleet/index.html', context) This sends to 
the template but doesn’t work at the moment

Database

"Welcome Aboard" "2018-01-15 21:02:54" 
"/home/user/Desktop/django/djangoFutureFleet/mysite/futureFleet/static/futureFleet/images/1.JPG"
 
"this is the first comic"

"Space Vaccine" "2018-01-15 23:02:22" 
"/home/user/Desktop/django/djangoFutureFleet/mysite/futureFleet/static/futureFleet/images/2.JPG"
 
"This is comic 2"

-- 
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/31674ff4-a2ab-4f2d-b6cb-9fc7ca9cf9cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: figuring out bug with django cookies: not working on server

2017-10-02 Thread Samuel Muiruri
@login_required
def edit_service(request, service_id, template_name="edit-service.html"):
context = RequestContext(request)

context['service_id'] = request.COOKIES.get('service_id', None)

...

response = render_to_response(template_name, context)
response.set_cookie('service_id', service_id)

return response

On Tue, Oct 3, 2017 at 1:05 AM, ADEWALE ADISA 
wrote:

> can you show the code where you set the cookie before retrieving it
> On Oct 2, 2017 6:35 PM, "Samuel Muiruri"  wrote:
>
>> I have a site that relies on checking if a cookie exists for service_id and
>> if it does checks if you can upload files for service... this works nicely
>> offline but on pushing changes to server it created a bug where even though
>> the cookie can be seen (on the dev console)
>>
>> [image: enter image description here]
>> 
>>
>> and I assign the cookie to a context variable which ends up saying None even
>> though I can see the cookie from the dev console.
>>
>> class PictureCreateView(CreateView):
>> model = Picture
>> fields = "__all__"
>> template_name = 'accounts/upload-file.html'
>>
>> def get_context_data(self, **kwargs):
>>
>> context = super(PictureCreateView, self).get_context_data(**kwargs)
>> context['service_id'] = self.request.COOKIES.get('service_id', None)
>>
>> return context
>>
>> on the template
>>
>> {% if service_id %}
>> #display form{% else %}
>> Sorry it seems you're missing some vital data needed before ...
>> {% endif %}
>>
>> any ideas?
>>
>> here's a screen record (local & live): https://youtu.be/aud59Avp1aI
>>
>> --
>> 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/ms
>> gid/django-users/fd1f686b-dded-4aaa-8f6b-274419afa0a1%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/mSWmg0HVxz0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAMGzuy-N_znhTLZqD0zc4ED78pFNAgCH3ns17eY
> R3ZR0xOrcyQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Best Regards,

Samuel Muiruri.

Web Designer | +254 738 940064

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


Re: figuring out bug with django cookies: not working on server

2017-10-02 Thread ADEWALE ADISA
can you show the code where you set the cookie before retrieving it
On Oct 2, 2017 6:35 PM, "Samuel Muiruri"  wrote:

> I have a site that relies on checking if a cookie exists for service_id and
> if it does checks if you can upload files for service... this works nicely
> offline but on pushing changes to server it created a bug where even though
> the cookie can be seen (on the dev console)
>
> [image: enter image description here]
> 
>
> and I assign the cookie to a context variable which ends up saying None even
> though I can see the cookie from the dev console.
>
> class PictureCreateView(CreateView):
> model = Picture
> fields = "__all__"
> template_name = 'accounts/upload-file.html'
>
> def get_context_data(self, **kwargs):
>
> context = super(PictureCreateView, self).get_context_data(**kwargs)
> context['service_id'] = self.request.COOKIES.get('service_id', None)
>
> return context
>
> on the template
>
> {% if service_id %}
> #display form{% else %}
> Sorry it seems you're missing some vital data needed before ...
> {% endif %}
>
> any ideas?
>
> here's a screen record (local & live): https://youtu.be/aud59Avp1aI
>
> --
> 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/fd1f686b-dded-4aaa-8f6b-274419afa0a1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


figuring out bug with django cookies: not working on server

2017-10-02 Thread Samuel Muiruri


I have a site that relies on checking if a cookie exists for service_id and 
if it does checks if you can upload files for service... this works nicely 
offline but on pushing changes to server it created a bug where even though 
the cookie can be seen (on the dev console)

[image: enter image description here] 

and I assign the cookie to a context variable which ends up saying None even 
though I can see the cookie from the dev console.

class PictureCreateView(CreateView):
model = Picture
fields = "__all__"
template_name = 'accounts/upload-file.html'

def get_context_data(self, **kwargs):

context = super(PictureCreateView, self).get_context_data(**kwargs)
context['service_id'] = self.request.COOKIES.get('service_id', None)

return context

on the template

{% if service_id %}
#display form{% else %}
Sorry it seems you're missing some vital data needed before ...
{% endif %}

any ideas?

here's a screen record (local & live): https://youtu.be/aud59Avp1aI

-- 
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/fd1f686b-dded-4aaa-8f6b-274419afa0a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver not working after installing redis for django channels

2017-09-12 Thread Robin Lery
Yes, i think just running `sudo apt-get install redis-server` installs the
old version of redis, instead of the latest one.

On Mon, Sep 11, 2017 at 6:40 PM, Artem Malyshev 
wrote:

> Hi,
>
> Please check your redis installation. It should be at least minimum
> required version by redis-py.
>
> Regards, Artem.
>
> --
> 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/beab5ba8-b6db-44f6-b211-bce721259e90%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Django runserver not working after installing redis for django channels

2017-09-11 Thread Artem Malyshev
Hi,

Please check your redis installation. It should be at least minimum required 
version by redis-py.

Regards, Artem.

-- 
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/beab5ba8-b6db-44f6-b211-bce721259e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django runserver not working after installing redis for django channels

2017-09-11 Thread Robin Lery
I am learning the Django-channels
 concepts and I am
stuck when after install the asgi_redis and the redis server
.
If I have the CHANNEL_LAYERS configured for the *in-memory backend*. The
server runs okay, and the web page is displayed.However, if I run the
server after configuring the CHANNEL_LAYERS for the *redis backed*, the web
page is not displayed, and I get an error in the terminal:

Channel layer default (asgi_redis.core.RedisChannelLayer)
Quit the server with CONTROL-C.
2017-09-11 12:34:07,259 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,260 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,261 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,263 - INFO - server - HTTP/2 support not enabled
(install the http2 and tls Twisted extras)
2017-09-11 12:34:07,263 - INFO - server - Using busy-loop synchronous mode
on channel layer
2017-09-11 12:34:07,265 - INFO - server - Listening on endpoint
tcp:port=8000:interface=127.0.0.1
2017-09-11 12:34:07,267 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:07,268 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:12,270 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:17,272 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'

I have installed the asgi_redis in my virtualenv, and also installed Redis
server. What am I doing wrong here?

Here are the useful versions that I am using:

   - channels==1.1.6
   - asgi-redis==1.4.2
   - daphne==1.3.0
   - Django==1.11.5


Sincerely

Robin

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


Re: Drop Down Menu in Django Forms not working.

2017-08-07 Thread Arun S
class EvalState(models.Model,AtlasBaseHelper):
"""
Represents Eval State:
ACTIVE
INACTIVE
DELETE
NA
"""
name = models.CharField(max_length=32, unique=True)
friendly_name = models.CharField(max_length=32, unique=True)
description = models.CharField(max_length=255, blank=True, null=True)

class Meta:
verbose_name = "Eval States"

def __unicode__(self):
return self.name

class Bundle(AtlasAuditModel, AtlasBaseHelper):^M
"""^M
Represents the bundle purchased by the customer. The bundle^M
contains a reference identifier which remains the same if the^M
the bundle is either upgraded or entended.^M
A bundle can have 0 or more features.^M
"""^M
bundle_id = models.CharField(verbose_name="Bundle ID",^M
 max_length=32,^M
 unique=True)^M
customer = models.ForeignKey(Customer)^M
description = models.CharField(max_length=255, blank=True, null=True)^M
state = models.ForeignKey(BundleState)^M
extended_state = models.ForeignKey(BundleExtendedState)^M
type = models.ForeignKey(BundleType)^M
quantity = models.FloatField(blank=False)^M
start_date = models.DateField(verbose_name="Start Date")^M
end_date = models.DateField(verbose_name="End Date")^M
stage = models.CharField(max_length=32, blank=True, null=True)^M
*stage_state = models.ForeignKey(EvalState, verbose_name="Eval State", 
null=True)*

The Below is the Migration Script written to add the States in to EvalState:
def forwards(apps, schema_editor):
DcPropertyType = apps.get_model("atlas", "evalstate")
db_alias = schema_editor.connection.alias

DcPropertyType.objects.using(db_alias).bulk_create([
DcPropertyType(name="ACTIVE", friendly_name="EVAL Active", 
description="Bundle EVAL State is ACTIVE"),
DcPropertyType(name="INACTIVE", friendly_name="EVAL 
InActive",description="Bundle EVAL state is INACTIVE"),
DcPropertyType(name="DELETE", friendly_name="EVAL Delete", 
description="Bundle EVAL state is DELETE"),
DcPropertyType(name="NA", friendly_name="EVAL NotApplicable", 
description="Bundle EVAL state is not applicable")
])

def backwards(apps, schema_editor):
DcPropertyType = apps.get_model("atlas", "evalstate")
db_alias = schema_editor.connection.alias

DcPropertyType.objects.using(db_alias).filter(name="ACTIVE", 
description="Bundle EVAL State is ACTIVE").delete()
DcPropertyType.objects.using(db_alias).filter(name="INACTIVE", 
description="Bundle EVAL state is INACTIVE").delete()
DcPropertyType.objects.using(db_alias).filter(name="DELETE", 
description="Bundle EVAL state is DELETE").delete()
DcPropertyType.objects.using(db_alias).filter(name="NA", 
description="Bundle EVAL state is not applicable").delete()


class Migration(migrations.Migration):

dependencies = [
('atlas', '0012_add_eval_states'),
]

operations = [
migrations.RunPython(forwards, backwards),
]

Does this make sense for the model structure. I do not have any Models 
Diagram for the same. 

---
Arun

On Monday, August 7, 2017 at 4:13:33 PM UTC+5:30, lemme smash wrote:
>
> you didn't show me a model structure, you just showed another model, so I 
> can't give you example without picture of what's going on there
>
> On Monday, August 7, 2017 at 1:39:49 PM UTC+3, Arun S wrote:
>>
>> Can you just give an Example for this taking a Query.
>>
>>
>>
>> On Monday, August 7, 2017 at 3:37:04 PM UTC+5:30, lemme smash wrote:
>>>
>>> i meant EvalState model
>>> if name attribute on it is a ForeignKey you should get corresponding 
>>> queryset of model it links to
>>> if it's charfield, you should use text choices 
>>>
>>> On Monday, August 7, 2017 at 6:22:50 AM UTC+3, Arun S wrote:

 The Models Look like this :

 stage_state = models.ForeignKey(EvalState, verbose_name="Eval State")
 class Bundle(AtlasAuditModel, AtlasBaseHelper):^M
 """^M
 Represents the bundle purchased by the customer. The bundle^M
 contains a reference identifier which remains the same if the^M
 the bundle is either upgraded or entended.^M
 A bundle can have 0 or more features.^M
 """^M
 bundle_id = models.CharField(verbose_name="Bundle ID",^M
  max_length=32,^M
  unique=True)^M
 
 
 
 stage_state = models.ForeignKey(*EvalState*, verbose_name="Eval 
 State")


 atlas_bundle;
 atlas_bundle | CREATE TABLE `atlas_bundle` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
  ...
 
 ...
   *`stage_state_id` int(11) NOT NULL,*
   PRIMARY KEY (`id`),
   *KEY `atlas_bundle_36c1765e` (`stage_state_id`)*
 ) ENGINE=InnoDB AUTO_INCREMENT=1408 DEFAULT CHARSET=latin1 
 ROW_FORMAT=DYNAMIC |
 19 rows in set (0.01 sec)

 desc 

Re: Drop Down Menu in Django Forms not working.

2017-08-07 Thread lemme smash
you didn't show me a model structure, you just showed another model, so I 
can't give you example without picture of what's going on there

On Monday, August 7, 2017 at 1:39:49 PM UTC+3, Arun S wrote:
>
> Can you just give an Example for this taking a Query.
>
>
>
> On Monday, August 7, 2017 at 3:37:04 PM UTC+5:30, lemme smash wrote:
>>
>> i meant EvalState model
>> if name attribute on it is a ForeignKey you should get corresponding 
>> queryset of model it links to
>> if it's charfield, you should use text choices 
>>
>> On Monday, August 7, 2017 at 6:22:50 AM UTC+3, Arun S wrote:
>>>
>>> The Models Look like this :
>>>
>>> stage_state = models.ForeignKey(EvalState, verbose_name="Eval State")
>>> class Bundle(AtlasAuditModel, AtlasBaseHelper):^M
>>> """^M
>>> Represents the bundle purchased by the customer. The bundle^M
>>> contains a reference identifier which remains the same if the^M
>>> the bundle is either upgraded or entended.^M
>>> A bundle can have 0 or more features.^M
>>> """^M
>>> bundle_id = models.CharField(verbose_name="Bundle ID",^M
>>>  max_length=32,^M
>>>  unique=True)^M
>>> 
>>> 
>>> 
>>> stage_state = models.ForeignKey(*EvalState*, verbose_name="Eval 
>>> State")
>>>
>>>
>>> atlas_bundle;
>>> atlas_bundle | CREATE TABLE `atlas_bundle` (
>>>   `id` int(11) NOT NULL AUTO_INCREMENT,
>>>  ...
>>> 
>>> ...
>>>   *`stage_state_id` int(11) NOT NULL,*
>>>   PRIMARY KEY (`id`),
>>>   *KEY `atlas_bundle_36c1765e` (`stage_state_id`)*
>>> ) ENGINE=InnoDB AUTO_INCREMENT=1408 DEFAULT CHARSET=latin1 
>>> ROW_FORMAT=DYNAMIC |
>>> 19 rows in set (0.01 sec)
>>>
>>> desc *evalstate*;
>>> +---+--+--+-+-++
>>> | Field | Type | Null | Key | Default | Extra  |
>>> +---+--+--+-+-++
>>> | id| int(11)  | NO   | PRI | NULL| auto_increment |
>>> | name  | varchar(32)  | NO   | UNI | NULL||
>>> | friendly_name | varchar(32)  | NO   | UNI | NULL||
>>> | description   | varchar(255) | YES  | | NULL||
>>> +---+--+--+-+-++
>>> 4 rows in set (0.00 sec)
>>>
>>> Whats the Difference in having qs when there is a foriegn Key value? 
>>>
>>> Arun
>>>
>>> On Sunday, August 6, 2017 at 7:48:11 PM UTC+5:30, lemme smash wrote:

 so, you can maybe show you models structure here?
 also, if it is a ForeignKey, why you trying to filter qs by string 
 values? I mean Q(name = 'ACTIVE')
 it's shouldn't work


 On Sunday, August 6, 2017 at 5:22:21 AM UTC+3, Arun S wrote:
>
> Yes, name is a foreign key here.



-- 
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/f0016136-3478-4af3-8509-28b964397090%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop Down Menu in Django Forms not working.

2017-08-07 Thread Arun S
Can you just give an Example for this taking a Query.



On Monday, August 7, 2017 at 3:37:04 PM UTC+5:30, lemme smash wrote:
>
> i meant EvalState model
> if name attribute on it is a ForeignKey you should get corresponding 
> queryset of model it links to
> if it's charfield, you should use text choices 
>
> On Monday, August 7, 2017 at 6:22:50 AM UTC+3, Arun S wrote:
>>
>> The Models Look like this :
>>
>> stage_state = models.ForeignKey(EvalState, verbose_name="Eval State")
>> class Bundle(AtlasAuditModel, AtlasBaseHelper):^M
>> """^M
>> Represents the bundle purchased by the customer. The bundle^M
>> contains a reference identifier which remains the same if the^M
>> the bundle is either upgraded or entended.^M
>> A bundle can have 0 or more features.^M
>> """^M
>> bundle_id = models.CharField(verbose_name="Bundle ID",^M
>>  max_length=32,^M
>>  unique=True)^M
>> 
>> 
>> 
>> stage_state = models.ForeignKey(*EvalState*, verbose_name="Eval 
>> State")
>>
>>
>> atlas_bundle;
>> atlas_bundle | CREATE TABLE `atlas_bundle` (
>>   `id` int(11) NOT NULL AUTO_INCREMENT,
>>  ...
>> 
>> ...
>>   *`stage_state_id` int(11) NOT NULL,*
>>   PRIMARY KEY (`id`),
>>   *KEY `atlas_bundle_36c1765e` (`stage_state_id`)*
>> ) ENGINE=InnoDB AUTO_INCREMENT=1408 DEFAULT CHARSET=latin1 
>> ROW_FORMAT=DYNAMIC |
>> 19 rows in set (0.01 sec)
>>
>> desc *evalstate*;
>> +---+--+--+-+-++
>> | Field | Type | Null | Key | Default | Extra  |
>> +---+--+--+-+-++
>> | id| int(11)  | NO   | PRI | NULL| auto_increment |
>> | name  | varchar(32)  | NO   | UNI | NULL||
>> | friendly_name | varchar(32)  | NO   | UNI | NULL||
>> | description   | varchar(255) | YES  | | NULL||
>> +---+--+--+-+-++
>> 4 rows in set (0.00 sec)
>>
>> Whats the Difference in having qs when there is a foriegn Key value? 
>>
>> Arun
>>
>> On Sunday, August 6, 2017 at 7:48:11 PM UTC+5:30, lemme smash wrote:
>>>
>>> so, you can maybe show you models structure here?
>>> also, if it is a ForeignKey, why you trying to filter qs by string 
>>> values? I mean Q(name = 'ACTIVE')
>>> it's shouldn't work
>>>
>>>
>>> On Sunday, August 6, 2017 at 5:22:21 AM UTC+3, Arun S wrote:

 Yes, name is a foreign key here.
>>>
>>>

-- 
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/f2c6ca98-9393-4e80-a303-ede320feddd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop Down Menu in Django Forms not working.

2017-08-07 Thread lemme smash
i meant EvalState model
if name attribute on it is a ForeignKey you should get corresponding 
queryset of model it links to
if it's charfield, you should use text choices 

On Monday, August 7, 2017 at 6:22:50 AM UTC+3, Arun S wrote:
>
> The Models Look like this :
>
> stage_state = models.ForeignKey(EvalState, verbose_name="Eval State")
> class Bundle(AtlasAuditModel, AtlasBaseHelper):^M
> """^M
> Represents the bundle purchased by the customer. The bundle^M
> contains a reference identifier which remains the same if the^M
> the bundle is either upgraded or entended.^M
> A bundle can have 0 or more features.^M
> """^M
> bundle_id = models.CharField(verbose_name="Bundle ID",^M
>  max_length=32,^M
>  unique=True)^M
> 
> 
> 
> stage_state = models.ForeignKey(*EvalState*, verbose_name="Eval 
> State")
>
>
> atlas_bundle;
> atlas_bundle | CREATE TABLE `atlas_bundle` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>  ...
> 
> ...
>   *`stage_state_id` int(11) NOT NULL,*
>   PRIMARY KEY (`id`),
>   *KEY `atlas_bundle_36c1765e` (`stage_state_id`)*
> ) ENGINE=InnoDB AUTO_INCREMENT=1408 DEFAULT CHARSET=latin1 
> ROW_FORMAT=DYNAMIC |
> 19 rows in set (0.01 sec)
>
> desc *evalstate*;
> +---+--+--+-+-++
> | Field | Type | Null | Key | Default | Extra  |
> +---+--+--+-+-++
> | id| int(11)  | NO   | PRI | NULL| auto_increment |
> | name  | varchar(32)  | NO   | UNI | NULL||
> | friendly_name | varchar(32)  | NO   | UNI | NULL||
> | description   | varchar(255) | YES  | | NULL||
> +---+--+--+-+-++
> 4 rows in set (0.00 sec)
>
> Whats the Difference in having qs when there is a foriegn Key value? 
>
> Arun
>
> On Sunday, August 6, 2017 at 7:48:11 PM UTC+5:30, lemme smash wrote:
>>
>> so, you can maybe show you models structure here?
>> also, if it is a ForeignKey, why you trying to filter qs by string 
>> values? I mean Q(name = 'ACTIVE')
>> it's shouldn't work
>>
>>
>> On Sunday, August 6, 2017 at 5:22:21 AM UTC+3, Arun S wrote:
>>>
>>> Yes, name is a foreign key here.
>>
>>

-- 
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/acdd7ce3-0b42-4808-a6de-f6023ca3275f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop Down Menu in Django Forms not working.

2017-08-06 Thread Arun S
The Models Look like this :

stage_state = models.ForeignKey(EvalState, verbose_name="Eval State")
class Bundle(AtlasAuditModel, AtlasBaseHelper):^M
"""^M
Represents the bundle purchased by the customer. The bundle^M
contains a reference identifier which remains the same if the^M
the bundle is either upgraded or entended.^M
A bundle can have 0 or more features.^M
"""^M
bundle_id = models.CharField(verbose_name="Bundle ID",^M
 max_length=32,^M
 unique=True)^M



stage_state = models.ForeignKey(*EvalState*, verbose_name="Eval State")


atlas_bundle;
atlas_bundle | CREATE TABLE `atlas_bundle` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
 ...

...
  *`stage_state_id` int(11) NOT NULL,*
  PRIMARY KEY (`id`),
  *KEY `atlas_bundle_36c1765e` (`stage_state_id`)*
) ENGINE=InnoDB AUTO_INCREMENT=1408 DEFAULT CHARSET=latin1 
ROW_FORMAT=DYNAMIC |
19 rows in set (0.01 sec)

desc *evalstate*;
+---+--+--+-+-++
| Field | Type | Null | Key | Default | Extra  |
+---+--+--+-+-++
| id| int(11)  | NO   | PRI | NULL| auto_increment |
| name  | varchar(32)  | NO   | UNI | NULL||
| friendly_name | varchar(32)  | NO   | UNI | NULL||
| description   | varchar(255) | YES  | | NULL||
+---+--+--+-+-++
4 rows in set (0.00 sec)

Whats the Difference in having qs when there is a foriegn Key value? 

Arun

On Sunday, August 6, 2017 at 7:48:11 PM UTC+5:30, lemme smash wrote:
>
> so, you can maybe show you models structure here?
> also, if it is a ForeignKey, why you trying to filter qs by string values? 
> I mean Q(name = 'ACTIVE')
> it's shouldn't work
>
>
> On Sunday, August 6, 2017 at 5:22:21 AM UTC+3, Arun S wrote:
>>
>> Yes, name is a foreign key here.
>
>

-- 
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/6a5277c8-a8f0-450f-b214-8cc251cab305%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop Down Menu in Django Forms not working.

2017-08-06 Thread lemme smash
so, you can maybe show you models structure here?
also, if it is a ForeignKey, why you trying to filter qs by string values? 
I mean Q(name = 'ACTIVE')
it's shouldn't work


On Sunday, August 6, 2017 at 5:22:21 AM UTC+3, Arun S wrote:
>
> Yes, name is a foreign key here.

-- 
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/34570842-a7f9-4043-8bfc-a1a893a71020%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop Down Menu in Django Forms not working.

2017-08-05 Thread Arun S
Yes, name is a foreign key here.

-- 
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/4015cb08-4413-4a6d-90b6-219bc1b71d2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop Down Menu in Django Forms not working.

2017-08-05 Thread lemme smash
name is a ForeignKey field? If not, you shouldn't use queryset attribute 
there. Use choices instead.
If you want to render all available choices from db, you can get it like 
Model.objects.filter(...).values_list('name', flat=True)

On Friday, August 4, 2017 at 8:07:24 PM UTC+3, Arun S wrote:
>
> Hi,
>
> I am trying to have a drop down menu for a field in my form but seems like 
> its not working as required.
>
> This is my form: forms.py
>
> eval_states = [
> ('ACTIVE',EvalState.objects.filter(name='ACTIVE')),
> ('INACTIVE',EvalState.objects.filter(name='INACTIVE')),
> ('DELETE',EvalState.objects.filter(name='DELETE')),
> ]
>
> class EvalForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
> super(EvalForm, self).__init__(*args, **kwargs)
> self.fields['name'].queryset = EvalState.objects.filter(
> Q(name = 'ACTIVE') | Q(name = 'INACTIVE') | Q(name = 
> 'DELETE'))
>
> class Meta:
> model = EvalState
> fields = ('name',)
>
> my html : abc.html
>
> {% csrf_token %}
> 
> 
> Eval State:
> 
> {{ eval_form.name }}
> 
> 
> 
> 
> 
>
> view.py
> eval_form = None
> eval_form = atlas_forms.EvalForm(request.POST, EvalState)
> if eval_form.is_valid():
> print eval_form.errors
> eval_form.save()
> else:
> print eval_form.errors
>
>
> What am i missing?
> Basically requirement is that, i would need a drop down in the HTML and 
> whenever the Value is set and saved, I want it to be updated in the DB.
> But i am not able to get through the first step of getting the options in 
> the HTML.
>
> Any Help on this would be great.
>
> Thanks
> cheers
> Arun.
>
>

-- 
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/569250aa-3644-47b6-a952-e857247e966b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Drop Down Menu in Django Forms not working.

2017-08-04 Thread Arun S
Hi,

I am trying to have a drop down menu for a field in my form but seems like 
its not working as required.

This is my form: forms.py

eval_states = [
('ACTIVE',EvalState.objects.filter(name='ACTIVE')),
('INACTIVE',EvalState.objects.filter(name='INACTIVE')),
('DELETE',EvalState.objects.filter(name='DELETE')),
]

class EvalForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EvalForm, self).__init__(*args, **kwargs)
self.fields['name'].queryset = EvalState.objects.filter(
Q(name = 'ACTIVE') | Q(name = 'INACTIVE') | Q(name = 
'DELETE'))

class Meta:
model = EvalState
fields = ('name',)

my html : abc.html

{% csrf_token %}


Eval State:

{{ eval_form.name }}






view.py
eval_form = None
eval_form = atlas_forms.EvalForm(request.POST, EvalState)
if eval_form.is_valid():
print eval_form.errors
eval_form.save()
else:
print eval_form.errors


What am i missing?
Basically requirement is that, i would need a drop down in the HTML and 
whenever the Value is set and saved, I want it to be updated in the DB.
But i am not able to get through the first step of getting the options in 
the HTML.

Any Help on this would be great.

Thanks
cheers
Arun.

-- 
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/9b7492df-5f0f-44fd-b0ec-030e6619c7d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Having problem with django runserver not working in windows 7

2017-04-29 Thread ludovic coues
Do you mind sharing the full error you got ?

2017-04-29 5:46 GMT+02:00 Andrew James :
> Hi I'm new to django and I'm having a problem with getting django runserver
> to work. I'm new to django framework and I'm using windows 7. This is what
> I've tried so far that I've installed django. I've installed that django in
> my p drive. and I've tried the path in cmd  like p:/python/mysite/manage.py
> runserver and I got error. I'm been frustrated with getting the django
> framework to work even though its already install. i did my best to follow
> the documentation direction. If there is a video instruction it would be
> nice.
>
> --
> 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/00435878-58e1-46d9-b068-9ed562a4038b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Ludovic Coues
+33 6 14 87 43 42

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


Having problem with django runserver not working in windows 7

2017-04-29 Thread Andrew James
Hi I'm new to django and I'm having a problem with getting django runserver 
to work. I'm new to django framework and I'm using windows 7. This is what 
I've tried so far that I've installed django. I've installed that django in 
my p drive. and I've tried the path in cmd  like p:/python/mysite/manage.py 
runserver and I got error. I'm been frustrated with getting the django 
framework to work even though its already install. i did my best to follow 
the documentation direction. If there is a video instruction it would be 
nice.

-- 
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/00435878-58e1-46d9-b068-9ed562a4038b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django-drip not working

2016-08-20 Thread M Hashmi
Yeah I know that but I thought it would be easy to get it ported manually
but after reading code twice I guess I can wait till owner of repo do so.
Thanks for help.

Regards,
Mudassar

On Sat, Aug 20, 2016 at 9:15 AM, Simon Charette 
wrote:

> It looks like django-drip has not been ported to Django 1.8 yet.
>
>
> Le samedi 20 août 2016 09:41:06 UTC-4, M Hashmi a écrit :
>
>> Now I am getting another error:
>>
>> Traceback:
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>> in get_response
>>
>>   132. response = wrapped_callback(request,
>> *callback_args, **callback_kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>> in wrapper
>>
>>   616. return self.admin_site.admin_view(view)(*args,
>> **kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
>> in _wrapped_view
>>
>>   110. response = view_func(request, *args, **kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
>> in _wrapped_view_func
>>
>>   57. response = view_func(request, *args, **kwargs)
>>
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
>> in inner
>>
>>   233. return view(request, *args, **kwargs)
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> add_view
>>
>>   83. request, extra_context=self.build_extra
>> _context(extra_context))
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> build_extra_context
>>
>>   78. extra_context['field_data'] = json.dumps(get_simple_fields(U
>> ser))
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_simple_fields
>>
>>   118. return [[f[0], f[3].__name__] for f in get_fields(Model,
>> **kwargs)]
>>
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_fields
>>
>>   95. RelModel = field.related.parent_model
>>
>>
>> Exception Type: AttributeError at /admin/drip/drip/add/
>>
>> Exception Value: 'ManyToManyRel' object has no attribute 'parent_model'
>>
>> However at line 95 "RelModel = field.related.*parent_model*" is
>> referencing to following:
>>
>> patent_model{InlineModelAdmin in}
>> patent_model{InlineModelAdmin in django.contrib.admin.options}
>> patent_model{InlineModelAdmin in django_common.admin}
>>
>> Regards,
>> Mudassar
>>
>> On Sat, Aug 20, 2016 at 5:52 AM, Tim Graham  wrote:
>>
>>> Looks like it could be a bug in django-drip because:
>>>
>>> Model._meta.fields + Model._meta.many_to_many +
>>> Model._meta.get_all_related_objects()
>>> (tuple) + (tuple) + (list)
>>>
>>> A possible fix could be: ... + tuple(Model._meta.get_all_rela
>>> ted_objects())
>>>
>>>
>>> On Saturday, August 20, 2016 at 7:56:46 AM UTC-4, M Hashmi wrote:

 Hi Guys,

 I am having trouble with Django-drip and couldn't search a solution and
 hard to figure out. The error pops up when I try to add a Drip. My
 settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've
 added django-drip and migrated for django==1.8.13 it worked fine but now
 stuck at "get_fields" error.

 Following is the traceback:

 Traceback:
 File 
 "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
 in get_response
   132. response = wrapped_callback(request,
 *callback_args, **callback_kwargs)
 File 
 "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
 in wrapper
   616. return self.admin_site.admin_view(view)(*args,
 **kwargs)
 File 
 "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
 in _wrapped_view
   110. response = view_func(request, *args,
 **kwargs)
 File 
 "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
 in _wrapped_view_func
   57. response = view_func(request, *args, **kwargs)
 File 
 "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
 in inner
   233. return view(request, *args, **kwargs)
 File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py"
 in add_view
   83. request, extra_context=self.build_extra
 _context(extra_context))
 File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py"
 in build_extra_context
   78. extra_context['field_data'] =
 json.dumps(get_simple_fields(User))
 File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py"
 in get_simple_fields
   118. return [[f[0], f[3].__name__] for f in get_fields(Model,
 

Re: Django-drip not working

2016-08-20 Thread Simon Charette
It looks like django-drip has not been ported to Django 1.8 yet.

Le samedi 20 août 2016 09:41:06 UTC-4, M Hashmi a écrit :
>
> Now I am getting another error:
>
> Traceback:
>
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>  
> in get_response
>
>   132. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
>
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>  
> in wrapper
>
>   616. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
>
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py" 
> in _wrapped_view
>
>   110. response = view_func(request, *args, **kwargs)
>
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
>  
> in _wrapped_view_func
>
>   57. response = view_func(request, *args, **kwargs)
>
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
>  
> in inner
>
>   233. return view(request, *args, **kwargs)
>
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in 
> add_view
>
>   83. request, 
> extra_context=self.build_extra_context(extra_context))
>
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in 
> build_extra_context
>
>   78. extra_context['field_data'] = 
> json.dumps(get_simple_fields(User))
>
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in 
> get_simple_fields
>
>   118. return [[f[0], f[3].__name__] for f in get_fields(Model, 
> **kwargs)]
>
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in 
> get_fields
>
>   95. RelModel = field.related.parent_model
>
>
> Exception Type: AttributeError at /admin/drip/drip/add/
>
> Exception Value: 'ManyToManyRel' object has no attribute 'parent_model'
>
> However at line 95 "RelModel = field.related.*parent_model*" is 
> referencing to following:
>
> patent_model{InlineModelAdmin in}
> patent_model{InlineModelAdmin in django.contrib.admin.options}
> patent_model{InlineModelAdmin in django_common.admin}
>
> Regards,
> Mudassar
>
> On Sat, Aug 20, 2016 at 5:52 AM, Tim Graham  > wrote:
>
>> Looks like it could be a bug in django-drip because:
>>
>> Model._meta.fields + Model._meta.many_to_many + 
>> Model._meta.get_all_related_objects()
>> (tuple) + (tuple) + (list)
>>
>> A possible fix could be: ... + 
>> tuple(Model._meta.get_all_related_objects())
>>
>>
>> On Saturday, August 20, 2016 at 7:56:46 AM UTC-4, M Hashmi wrote:
>>>
>>> Hi Guys,
>>>
>>> I am having trouble with Django-drip and couldn't search a solution and 
>>> hard to figure out. The error pops up when I try to add a Drip. My 
>>> settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've 
>>> added django-drip and migrated for django==1.8.13 it worked fine but now 
>>> stuck at "get_fields" error.
>>>
>>> Following is the traceback:
>>>
>>> Traceback:
>>> File 
>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>>>  
>>> in get_response
>>>   132. response = wrapped_callback(request, 
>>> *callback_args, **callback_kwargs)
>>> File 
>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>>>  
>>> in wrapper
>>>   616. return self.admin_site.admin_view(view)(*args, 
>>> **kwargs)
>>> File 
>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
>>>  
>>> in _wrapped_view
>>>   110. response = view_func(request, *args, **kwargs)
>>> File 
>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
>>>  
>>> in _wrapped_view_func
>>>   57. response = view_func(request, *args, **kwargs)
>>> File 
>>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
>>>  
>>> in inner
>>>   233. return view(request, *args, **kwargs)
>>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in 
>>> add_view
>>>   83. request, 
>>> extra_context=self.build_extra_context(extra_context))
>>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in 
>>> build_extra_context
>>>   78. extra_context['field_data'] = 
>>> json.dumps(get_simple_fields(User))
>>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in 
>>> get_simple_fields
>>>   118. return [[f[0], f[3].__name__] for f in get_fields(Model, 
>>> **kwargs)]
>>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in 
>>> get_fields
>>>   48. fields = Model._meta.fields + Model._meta.many_to_many + 
>>> Model._meta.get_all_related_objects()
>>>
>>> Exception Type: TypeError at /admin/drip/drip/add/
>>> Exception Value: can only concatenate tuple (not "list") to tuple

Re: Django-drip not working

2016-08-20 Thread M Hashmi
Now I am getting another error:

Traceback:

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
in get_response

  132. response = wrapped_callback(request,
*callback_args, **callback_kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
in wrapper

  616. return self.admin_site.admin_view(view)(*args,
**kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
in _wrapped_view

  110. response = view_func(request, *args, **kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func

  57. response = view_func(request, *args, **kwargs)

File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
in inner

  233. return view(request, *args, **kwargs)

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
add_view

  83. request,
extra_context=self.build_extra_context(extra_context))

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
build_extra_context

  78. extra_context['field_data'] =
json.dumps(get_simple_fields(User))

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_simple_fields

  118. return [[f[0], f[3].__name__] for f in get_fields(Model,
**kwargs)]

File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_fields

  95. RelModel = field.related.parent_model


Exception Type: AttributeError at /admin/drip/drip/add/

Exception Value: 'ManyToManyRel' object has no attribute 'parent_model'

However at line 95 "RelModel = field.related.*parent_model*" is referencing
to following:

patent_model{InlineModelAdmin in}
patent_model{InlineModelAdmin in django.contrib.admin.options}
patent_model{InlineModelAdmin in django_common.admin}

Regards,
Mudassar

On Sat, Aug 20, 2016 at 5:52 AM, Tim Graham  wrote:

> Looks like it could be a bug in django-drip because:
>
> Model._meta.fields + Model._meta.many_to_many +
> Model._meta.get_all_related_objects()
> (tuple) + (tuple) + (list)
>
> A possible fix could be: ... + tuple(Model._meta.get_all_
> related_objects())
>
>
> On Saturday, August 20, 2016 at 7:56:46 AM UTC-4, M Hashmi wrote:
>>
>> Hi Guys,
>>
>> I am having trouble with Django-drip and couldn't search a solution and
>> hard to figure out. The error pops up when I try to add a Drip. My
>> settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've
>> added django-drip and migrated for django==1.8.13 it worked fine but now
>> stuck at "get_fields" error.
>>
>> Following is the traceback:
>>
>> Traceback:
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>> in get_response
>>   132. response = wrapped_callback(request,
>> *callback_args, **callback_kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>> in wrapper
>>   616. return self.admin_site.admin_view(view)(*args,
>> **kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
>> in _wrapped_view
>>   110. response = view_func(request, *args, **kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
>> in _wrapped_view_func
>>   57. response = view_func(request, *args, **kwargs)
>> File 
>> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
>> in inner
>>   233. return view(request, *args, **kwargs)
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> add_view
>>   83. request, extra_context=self.build_extra
>> _context(extra_context))
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
>> build_extra_context
>>   78. extra_context['field_data'] = json.dumps(get_simple_fields(U
>> ser))
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_simple_fields
>>   118. return [[f[0], f[3].__name__] for f in get_fields(Model,
>> **kwargs)]
>> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
>> get_fields
>>   48. fields = Model._meta.fields + Model._meta.many_to_many +
>> Model._meta.get_all_related_objects()
>>
>> Exception Type: TypeError at /admin/drip/drip/add/
>> Exception Value: can only concatenate tuple (not "list") to tuple
>>
>> I've also searched issues opened in past with "
>> https://github.com/zapier/django-drip/issues; and was able to solve few
>> problems but can't solve this one.Please advise.
>>
>> --
> 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 

Re: Django-drip not working

2016-08-20 Thread Tim Graham
Looks like it could be a bug in django-drip because:

Model._meta.fields + Model._meta.many_to_many + 
Model._meta.get_all_related_objects()
(tuple) + (tuple) + (list)

A possible fix could be: ... + tuple(Model._meta.get_all_related_objects())

On Saturday, August 20, 2016 at 7:56:46 AM UTC-4, M Hashmi wrote:
>
> Hi Guys,
>
> I am having trouble with Django-drip and couldn't search a solution and 
> hard to figure out. The error pops up when I try to add a Drip. My 
> settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've 
> added django-drip and migrated for django==1.8.13 it worked fine but now 
> stuck at "get_fields" error.
>
> Following is the traceback:
>
> Traceback:
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
>  
> in get_response
>   132. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
>  
> in wrapper
>   616. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py" 
> in _wrapped_view
>   110. response = view_func(request, *args, **kwargs)
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
>  
> in _wrapped_view_func
>   57. response = view_func(request, *args, **kwargs)
> File 
> "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
>  
> in inner
>   233. return view(request, *args, **kwargs)
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in 
> add_view
>   83. request, 
> extra_context=self.build_extra_context(extra_context))
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in 
> build_extra_context
>   78. extra_context['field_data'] = 
> json.dumps(get_simple_fields(User))
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in 
> get_simple_fields
>   118. return [[f[0], f[3].__name__] for f in get_fields(Model, 
> **kwargs)]
> File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in 
> get_fields
>   48. fields = Model._meta.fields + Model._meta.many_to_many + 
> Model._meta.get_all_related_objects()
>
> Exception Type: TypeError at /admin/drip/drip/add/
> Exception Value: can only concatenate tuple (not "list") to tuple
>
> I've also searched issues opened in past with "
> https://github.com/zapier/django-drip/issues; and was able to solve few 
> problems but can't solve this one.Please advise.
>
>

-- 
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/012f3841-5585-4cbe-95f0-18903c7fd319%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django-drip not working

2016-08-20 Thread M Hashmi
Hi Guys,

I am having trouble with Django-drip and couldn't search a solution and
hard to figure out. The error pops up when I try to add a Drip. My
settings.py has "DRIP_FROM_MAIL" field and EMAIL_HOST field both. I've
added django-drip and migrated for django==1.8.13 it worked fine but now
stuck at "get_fields" error.

Following is the traceback:

Traceback:
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py"
in get_response
  132. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\options.py"
in wrapper
  616. return self.admin_site.admin_view(view)(*args,
**kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\utils\decorators.py"
in _wrapped_view
  110. response = view_func(request, *args, **kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  57. response = view_func(request, *args, **kwargs)
File
"C:\Users\Mudassar\dressikarepo\lib\site-packages\django\contrib\admin\sites.py"
in inner
  233. return view(request, *args, **kwargs)
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
add_view
  83. request,
extra_context=self.build_extra_context(extra_context))
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\admin.py" in
build_extra_context
  78. extra_context['field_data'] =
json.dumps(get_simple_fields(User))
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_simple_fields
  118. return [[f[0], f[3].__name__] for f in get_fields(Model,
**kwargs)]
File "C:\Users\Mudassar\dressikarepo\lib\site-packages\drip\utils.py" in
get_fields
  48. fields = Model._meta.fields + Model._meta.many_to_many +
Model._meta.get_all_related_objects()

Exception Type: TypeError at /admin/drip/drip/add/
Exception Value: can only concatenate tuple (not "list") to tuple

I've also searched issues opened in past with "
https://github.com/zapier/django-drip/issues; and was able to solve few
problems but can't solve this one.Please advise.

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


Re: Django Suit admin panel - Static files configuration Django 1.6 not working

2016-06-02 Thread Roger Lanoue jr
I am rebuilding a new server from scratch now. 

New IP: Same setup with new IP from Digital Ocean 1click install - 

http://162.243.58.204/

I am going to try and setup the Static files directory again. 

Since they are using Django 1.6 and the command makemigration and migrate 
are not in 1.6
Should i start using Django 1.8 or 1.9 before configuring the server?

On Thursday, June 2, 2016 at 10:35:20 AM UTC-4, luisza14 wrote:
>
> Where is  STATIC_ROOT ?
>
> static_root path needs to match with nginx /static location.
>
>
>
> El miércoles, 1 de junio de 2016, Roger Lanoue jr <ro...@rljmedia.com 
> > escribió:
> > Hi Django users group.
> > I am test and learning django out. I have a testing server and got my 
> test page up. 
> > Started to play with the Django suit control panel and ran in to some 
> problems with my setup.
> > Server: Digital Ocean one click install.
> > Ubuntu 14.04
> > Nginx
> > Postgres
> > python 2.7
> > django 1.6
> > Test server
> > http://162.243.201.237/
> >
> > Admin panel: http://django-suit.readthedocs.io/en/develop/
> > http://162.243.201.237/admin/
> > user: demo
> > pasword: demo
> > Static file command I ran
> > python manage.py collectstatic
> >
> > results: 0 static files copied, 116 unmodified.
> > Setting.py: Basics 
> > DEBUG = False 
> > TEMPLATE_DEBUG = False
> > ALLOWED_HOSTS = ['*']
> >
> > STATIC_URL = '/static/'
> > STATICFILES_DIRS = [
> > os.path.join(BASE_DIR, "static"),
> > '/home/django/django_project/static/',
> > Nginx setting:
> >  # Your Django project's media files - amend as required
> > location /media  {
> > alias /home/django/django_project/django_project/media;
> > }
> > # your Django project's static files - amend as required
> > location /static {
> > alias /home/django/django_project/django_project/static; 
> > }
> > # Proxy the static assests for the Django Admin panel
> > location /static/admin {
> >alias 
> /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
> > }
> > location / {
> > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> > proxy_set_header Host $http_host;
> > proxy_redirect off;
> > proxy_pass http://app_server;
> > }
> >  My goal is to get the Django suit working. I do not see anything in my 
> static files directory for the admin suit so the css can be applied. 
> > I am missing something very simple to get this working.
> > Thank you for taking time to look at this and wish to get some clues.
> > Roger
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to django-users...@googlegroups.com .
> > To post to this group, send email to django...@googlegroups.com 
> .
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/f0c19816-b477-43ba-9953-d4793bdfac80%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> -- 
> "La utopía sirve para caminar" Fernando Birri
>
>
>
>

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


Re: Django Suit admin panel - Static files configuration Django 1.6 not working

2016-06-02 Thread Luis Zárate
Where is  STATIC_ROOT ?

static_root path needs to match with nginx /static location.



El miércoles, 1 de junio de 2016, Roger Lanoue jr <ro...@rljmedia.com>
escribió:
> Hi Django users group.
> I am test and learning django out. I have a testing server and got my
test page up.
> Started to play with the Django suit control panel and ran in to some
problems with my setup.
> Server: Digital Ocean one click install.
> Ubuntu 14.04
> Nginx
> Postgres
> python 2.7
> django 1.6
> Test server
> http://162.243.201.237/
>
> Admin panel: http://django-suit.readthedocs.io/en/develop/
> http://162.243.201.237/admin/
> user: demo
> pasword: demo
> Static file command I ran
> python manage.py collectstatic
>
> results: 0 static files copied, 116 unmodified.
> Setting.py: Basics
> DEBUG = False
> TEMPLATE_DEBUG = False
> ALLOWED_HOSTS = ['*']
>
> STATIC_URL = '/static/'
> STATICFILES_DIRS = [
> os.path.join(BASE_DIR, "static"),
> '/home/django/django_project/static/',
> Nginx setting:
>  # Your Django project's media files - amend as required
> location /media  {
> alias /home/django/django_project/django_project/media;
> }
> # your Django project's static files - amend as required
> location /static {
> alias /home/django/django_project/django_project/static;
> }
> # Proxy the static assests for the Django Admin panel
> location /static/admin {
>alias
/usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
> }
> location / {
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>     proxy_set_header Host $http_host;
> proxy_redirect off;
> proxy_pass http://app_server;
> }
>  My goal is to get the Django suit working. I do not see anything in my
static files directory for the admin suit so the css can be applied.
> I am missing something very simple to get this working.
> Thank you for taking time to look at this and wish to get some clues.
> Roger
>
> --
> 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/f0c19816-b477-43ba-9953-d4793bdfac80%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

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

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


Django Suit admin panel - Static files configuration Django 1.6 not working

2016-06-02 Thread Roger Lanoue jr
Hi Django users group.

I am test and learning django out. I have a testing server and got my test 
page up. 

Started to play with the Django suit control panel and ran in to some 
problems with my setup.

*Server: Digital Ocean one click install.*
Ubuntu 14.04
Nginx
Postgres
python 2.7
django 1.6

*Test server*
http://162.243.201.237/

*Admin panel: *http://django-suit.readthedocs.io/en/develop/
http://162.243.201.237/admin/
user: demo
pasword: demo

*Static file command I ran*
python manage.py collectstatic

results: 0 static files copied, 116 unmodified.

*Setting.py: Basics *
DEBUG = False 

TEMPLATE_DEBUG = False

ALLOWED_HOSTS = ['*']

STATIC_URL = '/static/'

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
'/home/django/django_project/static/',

*Nginx setting:*

 # Your Django project's media files - amend as required
location /media  {
alias /home/django/django_project/django_project/media;
}

# your Django project's static files - amend as required
location /static {
alias /home/django/django_project/django_project/static; 
}

# Proxy the static assests for the Django Admin panel
location /static/admin {
   alias 
/usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}

 My goal is to get the Django suit working. I do not see anything in my 
static files directory for the admin suit so the css can be applied. 
I am missing something very simple to get this working.

Thank you for taking time to look at this and wish to get some clues.

Roger

-- 
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/f0c19816-b477-43ba-9953-d4793bdfac80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-12-19 Thread Felipe Serrano
Same problem, your Fix works great!... Thanks, using

MacOS 10.7, Django 1.7, DjanogCMS3, Python 3.4.2

-- 
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/eb800b8b-8bd9-4aab-89af-8ecaa680626d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Decrypting Encrypted Customer Data from Django Queries Not Working, But Working with Regular DB Queries

2014-10-08 Thread Collin Anderson
Do you need to re-initialize your decryptor each time in your django for 
loop, like you do in pure python?

Are you sure you're using the same database and key?

Is the base64 decoded, encrypted data the same between pure python and 
django before you decrypt it?

Same python version? Do you have __future__ imports at the top of any of 
the files?

-- 
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/76449a41-d881-4f51-ae15-b1bdfaf5d477%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Decrypting Encrypted Customer Data from Django Queries Not Working, But Working with Regular DB Queries

2014-10-08 Thread G Z
I'll post some more on this later, I'll post comments and be more 
descriptive.

On Wednesday, October 8, 2014 4:56:27 PM UTC-6, G Z wrote:
>
> I know exactly what my code is doing, and it works in just python 
> something django is doing is screwing it up.
>
> On Wednesday, October 8, 2014 4:41:43 PM UTC-6, Cal Leeming [iops.io] 
> wrote:
>>
>> Encrypting data such as passwords is one acceptable use case. However 
>> encrypting other types of data, such as name/phone numbers etc, is poor 
>> because you lose many search/indexing capabilities. For example, you 
>> wouldn't be able to perform wildcard searches, you could only do "case 
>> sensitive + exact match". 
>>
>> It would also appear you are storing this data as base64 hex 
>> representation in a string field, which is wasting a lot of page space, 
>> although this could be resolved by using a BINARY/VARBINARY and forcing the 
>> raw bytes instead of hex repr.
>>
>> As for data being encrypted over a link, this really doesn't provide any 
>> protections against that at all. If you're worried about link security, 
>> then you should look at using IPSec instead. 
>>
>> It's difficult to say why your script isn't working, as the code is quite 
>> messy with no commenting/documentation. Perhaps try starting again from 
>> scratch, comment/document as you go along, and then compare each step with 
>> your working Python code to see where it's breaking.
>>
>> Cal
>>
>> On Wed, Oct 8, 2014 at 11:29 PM, G Z  wrote:
>>
>>> How is encrypting at the application level wrong? The research I have 
>>> done, says that application level encrypting is better because its 
>>> encrypted over a link, and this is why most web apps use the salt method. I 
>>> would love to hear more about what your talking about I'm still learning.
>>>
>>> Also whats wrong with my code tho?
>>>
>>> On Wednesday, October 8, 2014 4:25:59 PM UTC-6, Cal Leeming [iops.io] 
>>> wrote:

 For the record, this approach towards data security is completely wrong.

 Consider using FDE on your databases, rather than encrypting individual 
 fields.

 Cal

 On Wed, Oct 8, 2014 at 11:11 PM, G Z  wrote:

> so I have a database of information with encrypted customer names. 
> When I use a plain python script to decrypt the names it works correctly 
> and decrypts all of the customer names.
>
> However, when I used Django it will decrypt only one name and the 
> remaining names will still be encrypted.
>
> I encrypt by salting my password key with a 256 bit sha has and then I 
> use AES encryption on the data then i base 64 encode it and stick it into 
> the db.
>
>
> Regular Python Script:
>
> def pad(string):
>return string + ((16-len(string) % 16) * '{' )
>
>
> password = hashlib.sha256("hidmykey").digest()  
> IV = 16 * '\x00'
> mode = AES.MODE_CBC
> decryptor = AES.new(password, mode, IV=IV)
>
>
> config_values = metering_config('VMStats',['logfile','daemon', 
> 'pguser','pgpassword','pghost','pgport']) # 
> postgres = psycopg2.connect(database='metering', 
> user=config_values['pguser'], password=config_values['
> pgpassword'],host=config_values['pghost'], 
> port=config_values['pgport'])
> pg_cursor = postgres.cursor()
> pg_cursor.execute("set timezone TO 'GMT'")
> storage_cursor_pg = postgres.cursor()
>
> customer_list = []
> pg_cursor.execute(''' select customer_name, customer_id from 
> customers''')
>
> for customer_name, customer_id in pg_cursor:
>data = base64.b64decode(customer_name)
>plain = decryptor.decrypt(data)
>lenofdec = plain.count('{')
>customer_list.append((plain[:len(plain)-lenofdec], customer_id)) 
>
> this works perfectly fine.
>
>
> DJANGO
>
>
>
> #these are functions django views calls to decrypt the data.
>
> def pad(string):
>return string + ((16-len(string) % 16) * '{' )
>
> def show_name(customer_name):
>password = hashlib.sha256("hidden").digest()  
>IV = 16 * '\x00'
>mode = AES.MODE_CBC
>decryptor = AES.new(password, mode, IV=IV)
>
>data = base64.b64decode(customer_name)
>enc_customer_name = decryptor.decrypt(data)
>lenofdec = enc_customer_name.count('{')
>customer_name = enc_customer_name[:len(enc_customer_name)-lenofdec] 
>
>return customer_name
>
> The actual django page:
>
>
> @login_required
> def portal(request):
>#define var's
>customer_list = []
>
>user = request.user
>user_name = request.user.username
>
>user.is_superuser = check_user(user, user_name) #my own custom 
> function to do some Active Directory stuff.
>   
>if user.is_active and 

Re: Decrypting Encrypted Customer Data from Django Queries Not Working, But Working with Regular DB Queries

2014-10-08 Thread G Z
I know exactly what my code is doing, and it works in just python something 
django is doing is screwing it up.

On Wednesday, October 8, 2014 4:41:43 PM UTC-6, Cal Leeming [iops.io] wrote:
>
> Encrypting data such as passwords is one acceptable use case. However 
> encrypting other types of data, such as name/phone numbers etc, is poor 
> because you lose many search/indexing capabilities. For example, you 
> wouldn't be able to perform wildcard searches, you could only do "case 
> sensitive + exact match". 
>
> It would also appear you are storing this data as base64 hex 
> representation in a string field, which is wasting a lot of page space, 
> although this could be resolved by using a BINARY/VARBINARY and forcing the 
> raw bytes instead of hex repr.
>
> As for data being encrypted over a link, this really doesn't provide any 
> protections against that at all. If you're worried about link security, 
> then you should look at using IPSec instead. 
>
> It's difficult to say why your script isn't working, as the code is quite 
> messy with no commenting/documentation. Perhaps try starting again from 
> scratch, comment/document as you go along, and then compare each step with 
> your working Python code to see where it's breaking.
>
> Cal
>
> On Wed, Oct 8, 2014 at 11:29 PM, G Z  
> wrote:
>
>> How is encrypting at the application level wrong? The research I have 
>> done, says that application level encrypting is better because its 
>> encrypted over a link, and this is why most web apps use the salt method. I 
>> would love to hear more about what your talking about I'm still learning.
>>
>> Also whats wrong with my code tho?
>>
>> On Wednesday, October 8, 2014 4:25:59 PM UTC-6, Cal Leeming [iops.io] 
>> wrote:
>>>
>>> For the record, this approach towards data security is completely wrong.
>>>
>>> Consider using FDE on your databases, rather than encrypting individual 
>>> fields.
>>>
>>> Cal
>>>
>>> On Wed, Oct 8, 2014 at 11:11 PM, G Z  wrote:
>>>
 so I have a database of information with encrypted customer names. When 
 I use a plain python script to decrypt the names it works correctly and 
 decrypts all of the customer names.

 However, when I used Django it will decrypt only one name and the 
 remaining names will still be encrypted.

 I encrypt by salting my password key with a 256 bit sha has and then I 
 use AES encryption on the data then i base 64 encode it and stick it into 
 the db.


 Regular Python Script:

 def pad(string):
return string + ((16-len(string) % 16) * '{' )


 password = hashlib.sha256("hidmykey").digest()  
 IV = 16 * '\x00'
 mode = AES.MODE_CBC
 decryptor = AES.new(password, mode, IV=IV)


 config_values = metering_config('VMStats',['logfile','daemon', 
 'pguser','pgpassword','pghost','pgport']) # 
 postgres = psycopg2.connect(database='metering', 
 user=config_values['pguser'], password=config_values['
 pgpassword'],host=config_values['pghost'], 
 port=config_values['pgport'])
 pg_cursor = postgres.cursor()
 pg_cursor.execute("set timezone TO 'GMT'")
 storage_cursor_pg = postgres.cursor()

 customer_list = []
 pg_cursor.execute(''' select customer_name, customer_id from 
 customers''')

 for customer_name, customer_id in pg_cursor:
data = base64.b64decode(customer_name)
plain = decryptor.decrypt(data)
lenofdec = plain.count('{')
customer_list.append((plain[:len(plain)-lenofdec], customer_id)) 

 this works perfectly fine.


 DJANGO



 #these are functions django views calls to decrypt the data.

 def pad(string):
return string + ((16-len(string) % 16) * '{' )

 def show_name(customer_name):
password = hashlib.sha256("hidden").digest()  
IV = 16 * '\x00'
mode = AES.MODE_CBC
decryptor = AES.new(password, mode, IV=IV)

data = base64.b64decode(customer_name)
enc_customer_name = decryptor.decrypt(data)
lenofdec = enc_customer_name.count('{')
customer_name = enc_customer_name[:len(enc_customer_name)-lenofdec] 
return customer_name

 The actual django page:


 @login_required
 def portal(request):
#define var's
customer_list = []

user = request.user
user_name = request.user.username

user.is_superuser = check_user(user, user_name) #my own custom 
 function to do some Active Directory stuff.
   
if user.is_active and user.is_superuser: 
   customers = Customers.objects.all().order_by('customer_name')
else:
   customers = Customers.objects.get(customer_id=customer_id_filter)
   
for customer in customers:
   customer_name = show_name(str(customer.customer_name)) 

Re: Decrypting Encrypted Customer Data from Django Queries Not Working, But Working with Regular DB Queries

2014-10-08 Thread Cal Leeming [iops.io]
Encrypting data such as passwords is one acceptable use case. However
encrypting other types of data, such as name/phone numbers etc, is poor
because you lose many search/indexing capabilities. For example, you
wouldn't be able to perform wildcard searches, you could only do "case
sensitive + exact match".

It would also appear you are storing this data as base64 hex representation
in a string field, which is wasting a lot of page space, although this
could be resolved by using a BINARY/VARBINARY and forcing the raw bytes
instead of hex repr.

As for data being encrypted over a link, this really doesn't provide any
protections against that at all. If you're worried about link security,
then you should look at using IPSec instead.

It's difficult to say why your script isn't working, as the code is quite
messy with no commenting/documentation. Perhaps try starting again from
scratch, comment/document as you go along, and then compare each step with
your working Python code to see where it's breaking.

Cal

On Wed, Oct 8, 2014 at 11:29 PM, G Z  wrote:

> How is encrypting at the application level wrong? The research I have
> done, says that application level encrypting is better because its
> encrypted over a link, and this is why most web apps use the salt method. I
> would love to hear more about what your talking about I'm still learning.
>
> Also whats wrong with my code tho?
>
> On Wednesday, October 8, 2014 4:25:59 PM UTC-6, Cal Leeming [iops.io]
> wrote:
>>
>> For the record, this approach towards data security is completely wrong.
>>
>> Consider using FDE on your databases, rather than encrypting individual
>> fields.
>>
>> Cal
>>
>> On Wed, Oct 8, 2014 at 11:11 PM, G Z  wrote:
>>
>>> so I have a database of information with encrypted customer names. When
>>> I use a plain python script to decrypt the names it works correctly and
>>> decrypts all of the customer names.
>>>
>>> However, when I used Django it will decrypt only one name and the
>>> remaining names will still be encrypted.
>>>
>>> I encrypt by salting my password key with a 256 bit sha has and then I
>>> use AES encryption on the data then i base 64 encode it and stick it into
>>> the db.
>>>
>>>
>>> Regular Python Script:
>>>
>>> def pad(string):
>>>return string + ((16-len(string) % 16) * '{' )
>>>
>>>
>>> password = hashlib.sha256("hidmykey").digest()
>>> IV = 16 * '\x00'
>>> mode = AES.MODE_CBC
>>> decryptor = AES.new(password, mode, IV=IV)
>>>
>>>
>>> config_values = metering_config('VMStats',['logfile','daemon',
>>> 'pguser','pgpassword','pghost','pgport']) #
>>> postgres = psycopg2.connect(database='metering',
>>> user=config_values['pguser'], password=config_values['
>>> pgpassword'],host=config_values['pghost'], port=config_values['pgport'])
>>> pg_cursor = postgres.cursor()
>>> pg_cursor.execute("set timezone TO 'GMT'")
>>> storage_cursor_pg = postgres.cursor()
>>>
>>> customer_list = []
>>> pg_cursor.execute(''' select customer_name, customer_id from
>>> customers''')
>>>
>>> for customer_name, customer_id in pg_cursor:
>>>data = base64.b64decode(customer_name)
>>>plain = decryptor.decrypt(data)
>>>lenofdec = plain.count('{')
>>>customer_list.append((plain[:len(plain)-lenofdec], customer_id))
>>>
>>> this works perfectly fine.
>>>
>>>
>>> DJANGO
>>>
>>>
>>>
>>> #these are functions django views calls to decrypt the data.
>>>
>>> def pad(string):
>>>return string + ((16-len(string) % 16) * '{' )
>>>
>>> def show_name(customer_name):
>>>password = hashlib.sha256("hidden").digest()
>>>IV = 16 * '\x00'
>>>mode = AES.MODE_CBC
>>>decryptor = AES.new(password, mode, IV=IV)
>>>
>>>data = base64.b64decode(customer_name)
>>>enc_customer_name = decryptor.decrypt(data)
>>>lenofdec = enc_customer_name.count('{')
>>>customer_name = enc_customer_name[:len(enc_customer_name)-lenofdec]
>>>return customer_name
>>>
>>> The actual django page:
>>>
>>>
>>> @login_required
>>> def portal(request):
>>>#define var's
>>>customer_list = []
>>>
>>>user = request.user
>>>user_name = request.user.username
>>>
>>>user.is_superuser = check_user(user, user_name) #my own custom
>>> function to do some Active Directory stuff.
>>>
>>>if user.is_active and user.is_superuser:
>>>   customers = Customers.objects.all().order_by('customer_name')
>>>else:
>>>   customers = Customers.objects.get(customer_id=customer_id_filter)
>>>
>>>for customer in customers:
>>>   customer_name = show_name(str(customer.customer_name)) #ive tried
>>> with and without making it a string.
>>>   customer_list.append((customer_name, int(customer.customer_id)))
>>>
>>>current_month = date.today().month
>>>
>>>
>>>
>>>
>>>context = Context({'customer_list': customer_list,
>>>  'user.is_superuser':user.is_superuser,
>>>  'current_month':current_month,
>>>   })
>>>   

Re: Decrypting Encrypted Customer Data from Django Queries Not Working, But Working with Regular DB Queries

2014-10-08 Thread G Z
How is encrypting at the application level wrong? The research I have done, 
says that application level encrypting is better because its encrypted over 
a link, and this is why most web apps use the salt method. I would love to 
hear more about what your talking about I'm still learning.

Also whats wrong with my code tho?

On Wednesday, October 8, 2014 4:25:59 PM UTC-6, Cal Leeming [iops.io] wrote:
>
> For the record, this approach towards data security is completely wrong.
>
> Consider using FDE on your databases, rather than encrypting individual 
> fields.
>
> Cal
>
> On Wed, Oct 8, 2014 at 11:11 PM, G Z  
> wrote:
>
>> so I have a database of information with encrypted customer names. When I 
>> use a plain python script to decrypt the names it works correctly and 
>> decrypts all of the customer names.
>>
>> However, when I used Django it will decrypt only one name and the 
>> remaining names will still be encrypted.
>>
>> I encrypt by salting my password key with a 256 bit sha has and then I 
>> use AES encryption on the data then i base 64 encode it and stick it into 
>> the db.
>>
>>
>> Regular Python Script:
>>
>> def pad(string):
>>return string + ((16-len(string) % 16) * '{' )
>>
>>
>> password = hashlib.sha256("hidmykey").digest()  
>> IV = 16 * '\x00'
>> mode = AES.MODE_CBC
>> decryptor = AES.new(password, mode, IV=IV)
>>
>>
>> config_values = metering_config('VMStats',['logfile','daemon', 
>> 'pguser','pgpassword','pghost','pgport']) # 
>> postgres = psycopg2.connect(database='metering', 
>> user=config_values['pguser'], 
>> password=config_values['pgpassword'],host=config_values['pghost'], 
>> port=config_values['pgport'])
>> pg_cursor = postgres.cursor()
>> pg_cursor.execute("set timezone TO 'GMT'")
>> storage_cursor_pg = postgres.cursor()
>>
>> customer_list = []
>> pg_cursor.execute(''' select customer_name, customer_id from customers''')
>>
>> for customer_name, customer_id in pg_cursor:
>>data = base64.b64decode(customer_name)
>>plain = decryptor.decrypt(data)
>>lenofdec = plain.count('{')
>>customer_list.append((plain[:len(plain)-lenofdec], customer_id)) 
>>
>> this works perfectly fine.
>>
>>
>> DJANGO
>>
>>
>>
>> #these are functions django views calls to decrypt the data.
>>
>> def pad(string):
>>return string + ((16-len(string) % 16) * '{' )
>>
>> def show_name(customer_name):
>>password = hashlib.sha256("hidden").digest()  
>>IV = 16 * '\x00'
>>mode = AES.MODE_CBC
>>decryptor = AES.new(password, mode, IV=IV)
>>
>>data = base64.b64decode(customer_name)
>>enc_customer_name = decryptor.decrypt(data)
>>lenofdec = enc_customer_name.count('{')
>>customer_name = enc_customer_name[:len(enc_customer_name)-lenofdec] 
>>return customer_name
>>
>> The actual django page:
>>
>>
>> @login_required
>> def portal(request):
>>#define var's
>>customer_list = []
>>
>>user = request.user
>>user_name = request.user.username
>>
>>user.is_superuser = check_user(user, user_name) #my own custom 
>> function to do some Active Directory stuff.
>>   
>>if user.is_active and user.is_superuser: 
>>   customers = Customers.objects.all().order_by('customer_name')
>>else:
>>   customers = Customers.objects.get(customer_id=customer_id_filter)
>>   
>>for customer in customers:
>>   customer_name = show_name(str(customer.customer_name)) #ive tried 
>> with and without making it a string.
>>   customer_list.append((customer_name, int(customer.customer_id)))
>>   
>>current_month = date.today().month
>>  
>>  
>>  
>>
>>context = Context({'customer_list': customer_list,
>>  'user.is_superuser':user.is_superuser, 
>>  'current_month':current_month,
>>   })
>>return render(request, 'portal.html', context)
>>
>>
>> Here is the output:
>>
>> as you see below ('TESTCUSTOMER', 81) is decrypted in real life that is a 
>> customer name that gets decrypted and its always the same name. However in 
>> my python script outside of django goes through them all and decrypts them.
>>
>> [('\xa9\xdc\xbf\x86#\x7f4\xc7\xcc\xf1q\x8f3\xe2X\xf3', 26), 
>> ('\x8a\xbc\x16\x90\r-B\x7f\xabU\x1d]\xb9M\xc5\xe3', 142), 
>> ('g\x04\xa3aMk\xe49\xb7\xba\xf2Q4\xc6\xc6\xac', 25), 
>> ("\x92\xbbqA\x0fvE\x94S}\x01|\\BX'", 41), 
>> ('\x07\x9a\xe9\xb1G\\\x8e\xa0\xbe\x83A\x86/\xe5%\xb7', 101), 
>> ('a\xf4\x88\xc0H\xd3\x87\xe1\x05\x18\xe1X\xb8\xe6\xf3\xf3', 23), 
>> ('l\xe7\x9c\xd0\x0eOz\x8d\x85\x94\xeb\xd9\x1c\xc2\x08\xc8', 38), 
>> ('\xd0&\x88,T\xe2(\xac7\xbd\xaa\x90s\x17\xec\xae', 31), 
>> ('\x15"\xf3"\xaf[*\xa8\xe0\xb0;L\xb5\x98\x1a\xef', 30), 
>> 

Re: Decrypting Encrypted Customer Data from Django Queries Not Working, But Working with Regular DB Queries

2014-10-08 Thread Cal Leeming [iops.io]
For the record, this approach towards data security is completely wrong.

Consider using FDE on your databases, rather than encrypting individual
fields.

Cal

On Wed, Oct 8, 2014 at 11:11 PM, G Z  wrote:

> so I have a database of information with encrypted customer names. When I
> use a plain python script to decrypt the names it works correctly and
> decrypts all of the customer names.
>
> However, when I used Django it will decrypt only one name and the
> remaining names will still be encrypted.
>
> I encrypt by salting my password key with a 256 bit sha has and then I use
> AES encryption on the data then i base 64 encode it and stick it into the
> db.
>
>
> Regular Python Script:
>
> def pad(string):
>return string + ((16-len(string) % 16) * '{' )
>
>
> password = hashlib.sha256("hidmykey").digest()
> IV = 16 * '\x00'
> mode = AES.MODE_CBC
> decryptor = AES.new(password, mode, IV=IV)
>
>
> config_values = metering_config('VMStats',['logfile','daemon',
> 'pguser','pgpassword','pghost','pgport']) #
> postgres = psycopg2.connect(database='metering',
> user=config_values['pguser'],
> password=config_values['pgpassword'],host=config_values['pghost'],
> port=config_values['pgport'])
> pg_cursor = postgres.cursor()
> pg_cursor.execute("set timezone TO 'GMT'")
> storage_cursor_pg = postgres.cursor()
>
> customer_list = []
> pg_cursor.execute(''' select customer_name, customer_id from customers''')
>
> for customer_name, customer_id in pg_cursor:
>data = base64.b64decode(customer_name)
>plain = decryptor.decrypt(data)
>lenofdec = plain.count('{')
>customer_list.append((plain[:len(plain)-lenofdec], customer_id))
>
> this works perfectly fine.
>
>
> DJANGO
>
>
>
> #these are functions django views calls to decrypt the data.
>
> def pad(string):
>return string + ((16-len(string) % 16) * '{' )
>
> def show_name(customer_name):
>password = hashlib.sha256("hidden").digest()
>IV = 16 * '\x00'
>mode = AES.MODE_CBC
>decryptor = AES.new(password, mode, IV=IV)
>
>data = base64.b64decode(customer_name)
>enc_customer_name = decryptor.decrypt(data)
>lenofdec = enc_customer_name.count('{')
>customer_name = enc_customer_name[:len(enc_customer_name)-lenofdec]
>return customer_name
>
> The actual django page:
>
>
> @login_required
> def portal(request):
>#define var's
>customer_list = []
>
>user = request.user
>user_name = request.user.username
>
>user.is_superuser = check_user(user, user_name) #my own custom function
> to do some Active Directory stuff.
>
>if user.is_active and user.is_superuser:
>   customers = Customers.objects.all().order_by('customer_name')
>else:
>   customers = Customers.objects.get(customer_id=customer_id_filter)
>
>for customer in customers:
>   customer_name = show_name(str(customer.customer_name)) #ive tried
> with and without making it a string.
>   customer_list.append((customer_name, int(customer.customer_id)))
>
>current_month = date.today().month
>
>
>context = Context({'customer_list': customer_list,
>  'user.is_superuser':user.is_superuser,
>  'current_month':current_month,
>   })
>return render(request, 'portal.html', context)
>
>
> Here is the output:
>
> as you see below ('TESTCUSTOMER', 81) is decrypted in real life that is a
> customer name that gets decrypted and its always the same name. However in
> my python script outside of django goes through them all and decrypts them.
>
> [('\xa9\xdc\xbf\x86#\x7f4\xc7\xcc\xf1q\x8f3\xe2X\xf3', 26),
> ('\x8a\xbc\x16\x90\r-B\x7f\xabU\x1d]\xb9M\xc5\xe3', 142),
> ('g\x04\xa3aMk\xe49\xb7\xba\xf2Q4\xc6\xc6\xac', 25),
> ("\x92\xbbqA\x0fvE\x94S}\x01|\\BX'", 41),
> ('\x07\x9a\xe9\xb1G\\\x8e\xa0\xbe\x83A\x86/\xe5%\xb7', 101),
> ('a\xf4\x88\xc0H\xd3\x87\xe1\x05\x18\xe1X\xb8\xe6\xf3\xf3', 23),
> ('l\xe7\x9c\xd0\x0eOz\x8d\x85\x94\xeb\xd9\x1c\xc2\x08\xc8', 38),
> ('\xd0&\x88,T\xe2(\xac7\xbd\xaa\x90s\x17\xec\xae', 31),
> ('\x15"\xf3"\xaf[*\xa8\xe0\xb0;L\xb5\x98\x1a\xef', 30),
> ('6\x15$\xddH\xdbw\xef\x03\xec\x8bk,\xbc2\x8a', 32),
> ('\x1f\xf4\x08S\x1c\xa5\xf0\x11L\x1b\xbe\xe5Cq\xea3', 28),
> ('\xda\x99\xd6\xa8:3bc\x96\x90u\xca\xd3\xc1|L', 22),
> ('\xe3*\x9d\x95\x83\x8c\xe4O\x99\x03\x12\xd4\x87\x1f\xc1\xa7', 35),
> (':\x8f\xbc#\x81g\xe5,fk\xca\x0b9\xca\x99&', 24), ('0
> \t\xfb\xafAT\xae\x8d\x0cW\x86\xa2\xf9\x11\x8f', 21),
> ('\xce\xe3\x17^\xc5\xabI\x9aT\x80\xcaIm\xc4\xcaS', 36),
> ("tA\xe9\xe5S\x90z\xbcw'\x86\x17\x98\xab=[", 37),
> ("\\m\xf9e\xe9\xff\xe5X\xfa\xc9@\xc8'Jh\x81", 34),
> ('\x15)h\x12\x06\xc6\xfd\x86\xcd\x81\xfa\x10\xb6\xad\xbc\x9f', 121),
> ('TESTCUSTOMER', 81),
> ('\x15\x8b\x131\xd8\x1c\x04\xf7\x01\xb2\x8b\x84t\x11l\x07', 61),
> ('XU\xed+\xad*}\\L[M_\r$`\xc9', 141),
> ('l\xc7\xa3\xfc\xc6\xc3\xc5\xe6\xf3\x1ff\nq\x8d\x18"', 29),
> ('k\xb8/}Y\xbb\xf5\xe7`R8N(\x81pWy', 33),
> ('\x90\n\x07\xe8\xd2R6\x89L\xd8\xe5\x92\x95Q %', 1), ('\x92
> 

Decrypting Encrypted Customer Data from Django Queries Not Working, But Working with Regular DB Queries

2014-10-08 Thread G Z
so I have a database of information with encrypted customer names. When I 
use a plain python script to decrypt the names it works correctly and 
decrypts all of the customer names.

However, when I used Django it will decrypt only one name and the remaining 
names will still be encrypted.

I encrypt by salting my password key with a 256 bit sha has and then I use 
AES encryption on the data then i base 64 encode it and stick it into the 
db.


Regular Python Script:

def pad(string):
   return string + ((16-len(string) % 16) * '{' )


password = hashlib.sha256("hidmykey").digest()  
IV = 16 * '\x00'
mode = AES.MODE_CBC
decryptor = AES.new(password, mode, IV=IV)


config_values = metering_config('VMStats',['logfile','daemon', 
'pguser','pgpassword','pghost','pgport']) # 
postgres = psycopg2.connect(database='metering', 
user=config_values['pguser'], 
password=config_values['pgpassword'],host=config_values['pghost'], 
port=config_values['pgport'])
pg_cursor = postgres.cursor()
pg_cursor.execute("set timezone TO 'GMT'")
storage_cursor_pg = postgres.cursor()

customer_list = []
pg_cursor.execute(''' select customer_name, customer_id from customers''')

for customer_name, customer_id in pg_cursor:
   data = base64.b64decode(customer_name)
   plain = decryptor.decrypt(data)
   lenofdec = plain.count('{')
   customer_list.append((plain[:len(plain)-lenofdec], customer_id)) 

this works perfectly fine.


DJANGO



#these are functions django views calls to decrypt the data.

def pad(string):
   return string + ((16-len(string) % 16) * '{' )

def show_name(customer_name):
   password = hashlib.sha256("hidden").digest()  
   IV = 16 * '\x00'
   mode = AES.MODE_CBC
   decryptor = AES.new(password, mode, IV=IV)
   
   data = base64.b64decode(customer_name)
   enc_customer_name = decryptor.decrypt(data)
   lenofdec = enc_customer_name.count('{')
   customer_name = enc_customer_name[:len(enc_customer_name)-lenofdec] 
   return customer_name

The actual django page:


@login_required
def portal(request):
   #define var's
   customer_list = []

   user = request.user
   user_name = request.user.username
   
   user.is_superuser = check_user(user, user_name) #my own custom function 
to do some Active Directory stuff.
  
   if user.is_active and user.is_superuser: 
  customers = Customers.objects.all().order_by('customer_name')
   else:
  customers = Customers.objects.get(customer_id=customer_id_filter)
  
   for customer in customers:
  customer_name = show_name(str(customer.customer_name)) #ive tried 
with and without making it a string.
  customer_list.append((customer_name, int(customer.customer_id)))
  
   current_month = date.today().month


   

   context = Context({'customer_list': customer_list,
 'user.is_superuser':user.is_superuser, 
 'current_month':current_month,
  })
   return render(request, 'portal.html', context)


Here is the output:

as you see below ('TESTCUSTOMER', 81) is decrypted in real life that is a 
customer name that gets decrypted and its always the same name. However in 
my python script outside of django goes through them all and decrypts them.

[('\xa9\xdc\xbf\x86#\x7f4\xc7\xcc\xf1q\x8f3\xe2X\xf3', 26), 
('\x8a\xbc\x16\x90\r-B\x7f\xabU\x1d]\xb9M\xc5\xe3', 142), 
('g\x04\xa3aMk\xe49\xb7\xba\xf2Q4\xc6\xc6\xac', 25), 
("\x92\xbbqA\x0fvE\x94S}\x01|\\BX'", 41), 
('\x07\x9a\xe9\xb1G\\\x8e\xa0\xbe\x83A\x86/\xe5%\xb7', 101), 
('a\xf4\x88\xc0H\xd3\x87\xe1\x05\x18\xe1X\xb8\xe6\xf3\xf3', 23), 
('l\xe7\x9c\xd0\x0eOz\x8d\x85\x94\xeb\xd9\x1c\xc2\x08\xc8', 38), 
('\xd0&\x88,T\xe2(\xac7\xbd\xaa\x90s\x17\xec\xae', 31), 
('\x15"\xf3"\xaf[*\xa8\xe0\xb0;L\xb5\x98\x1a\xef', 30), 
('6\x15$\xddH\xdbw\xef\x03\xec\x8bk,\xbc2\x8a', 32), 
('\x1f\xf4\x08S\x1c\xa5\xf0\x11L\x1b\xbe\xe5Cq\xea3', 28), 
('\xda\x99\xd6\xa8:3bc\x96\x90u\xca\xd3\xc1|L', 22), 
('\xe3*\x9d\x95\x83\x8c\xe4O\x99\x03\x12\xd4\x87\x1f\xc1\xa7', 35), 
(':\x8f\xbc#\x81g\xe5,fk\xca\x0b9\xca\x99&', 24), ('0 
\t\xfb\xafAT\xae\x8d\x0cW\x86\xa2\xf9\x11\x8f', 21), 
('\xce\xe3\x17^\xc5\xabI\x9aT\x80\xcaIm\xc4\xcaS', 36), 
("tA\xe9\xe5S\x90z\xbcw'\x86\x17\x98\xab=[", 37), 
("\\m\xf9e\xe9\xff\xe5X\xfa\xc9@\xc8'Jh\x81", 34), 
('\x15)h\x12\x06\xc6\xfd\x86\xcd\x81\xfa\x10\xb6\xad\xbc\x9f', 121), 
('TESTCUSTOMER', 81), 
('\x15\x8b\x131\xd8\x1c\x04\xf7\x01\xb2\x8b\x84t\x11l\x07', 61), 
('XU\xed+\xad*}\\L[M_\r$`\xc9', 141), 
('l\xc7\xa3\xfc\xc6\xc3\xc5\xe6\xf3\x1ff\nq\x8d\x18"', 29), 
('k\xb8/}Y\xbb\xf5\xe7`R8N(\x81pWy', 33), 
('\x90\n\x07\xe8\xd2R6\x89L\xd8\xe5\x92\x95Q %', 1), ('\x92 
\xad8|!\x82?\xa92\xc3\xe4\x8b7\xb4\x97', 27), 
('1\xbd\x1c\xd1\xd0\xd1\xe7\x89\xa1\xcbKo\x16bW\x9e', 39)] 

-- 
You received this message because you 

Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-09-26 Thread yamil moreno
No hablo inglés.

Tenía el mismo problema. 

1 - Lo que hice fue actualizar mi versión de Python (Python 2.7.* a Python 
3.3.5).
2 - Descargue el driver de MySQL para Python 3.3.* ( 
mysql-connector-python-2.0.1-py3.3.msi ) 
desde http://dev.mysql.com/downloads/file.php?id=453803.
3 - Deje los parámetros del archive SETTINGS ENGINE así ( 'ENGINE': 
'mysql.connector.django' )
4 - Cambie los métodos  __unicode__(self):   a  __str__(self).

# Todo funciona muy bien.

-- 
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/b1776e52-dea1-49d0-8cf6-f67e1e29e668%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-09-26 Thread yamil moreno

No hablo inglés.

Tenía el mismo problema. 

1 - Lo que hice fue actualizar mi versión de Python (Python 2.7.* a Python 
3.3.5).
2 - Descargue el driver de MySQL para Python 3.3.* ( 
mysql-connector-python-2.0.1-py3.3.msi ) 
desde http://dev.mysql.com/downloads/file.php?id=453803.
3 - Deje los parámetros del archive SETTINGS ENGINE así ( 'ENGINE': 
'mysql.connector.django' )
4 - Cambie los métodos  __unicode__(self):   a  __str__(self).

# Todo funciona muy bien.


-- 
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/a41d2b3c-17f2-4ca3-89bc-27c387d7e26d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-08-28 Thread cico
And I wish I could upvote your solution to heaven!
Thanks for sharing that, why is it not documented anywhere? Sounds like a 
killing feature..

Cheers!
mccc

On Saturday, May 10, 2014 1:00:12 AM UTC+2, Richard Esplin wrote:
>
> Thanks for sharing what you did. I wish PostgreSQL was an option for me on 
> this project. 
>
> Oracle's answer was pretty generic, but they are right that Django 1.7 is 
> still in development. It is good to know that they are planning to support 
> it 
> when it is released. I am glad I don't have to roll-out 1.6 and then 
> manage an 
> upgrade a few months after our launch. 
>
> PyMySQL appears to work fine, but I haven't benchmarked it yet. Knowing 
> that I 
> can drop in the Oracle connector if there is a problem makes me confident 
> to 
> move forward. 
>
> Cheers, 
>
> Richard 
>
> On Friday, May 09, 2014 14:49:11 Giovanni wrote: 
> > I switched to PostgreSQL when MySQL wasn't working. PostgreSQL worked 
> > without a hitch and the migrations work wonderfully. But since my target 
> > production environment only runs MySQL I will have to make the switch 
> back 
> > at some point. 
> > 
> > Thanks for submitting the bug to MySQL. I see they posted a somewhat 
> > generic answer. 
> > 
> > On Tuesday, May 6, 2014 11:52:07 AM UTC-4, Richard Esplin wrote: 
> > > In order to move forward with this project, I switched to PyMySQL: 
> > > 
> > > https://github.com/PyMySQL 
> > > 
> > > It appears to work great. In order to use the default Django backend 
> for 
> > > MySQL, I put this in my settings.py: 
> > > 
>  
>

-- 
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/0c46dae7-98a1-4758-8869-a1faccad04e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-05-09 Thread Richard Esplin
Thanks for sharing what you did. I wish PostgreSQL was an option for me on 
this project.

Oracle's answer was pretty generic, but they are right that Django 1.7 is 
still in development. It is good to know that they are planning to support it 
when it is released. I am glad I don't have to roll-out 1.6 and then manage an 
upgrade a few months after our launch.

PyMySQL appears to work fine, but I haven't benchmarked it yet. Knowing that I 
can drop in the Oracle connector if there is a problem makes me confident to 
move forward.

Cheers,

Richard

On Friday, May 09, 2014 14:49:11 Giovanni wrote:
> I switched to PostgreSQL when MySQL wasn't working. PostgreSQL worked
> without a hitch and the migrations work wonderfully. But since my target
> production environment only runs MySQL I will have to make the switch back
> at some point.
> 
> Thanks for submitting the bug to MySQL. I see they posted a somewhat
> generic answer.
> 
> On Tuesday, May 6, 2014 11:52:07 AM UTC-4, Richard Esplin wrote:
> > In order to move forward with this project, I switched to PyMySQL:
> > 
> > https://github.com/PyMySQL
> > 
> > It appears to work great. In order to use the default Django backend for
> > MySQL, I put this in my settings.py:
> > 


-- 
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/3051977.qdXU0Sggfr%40richs.localnet.esplins.org.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-05-09 Thread Giovanni
I switched to PostgreSQL when MySQL wasn't working. PostgreSQL worked 
without a hitch and the migrations work wonderfully. But since my target 
production environment only runs MySQL I will have to make the switch back 
at some point.

Thanks for submitting the bug to MySQL. I see they posted a somewhat 
generic answer.

On Tuesday, May 6, 2014 11:52:07 AM UTC-4, Richard Esplin wrote:
>
> In order to move forward with this project, I switched to PyMySQL:
>
> https://github.com/PyMySQL
>
> It appears to work great. In order to use the default Django backend for 
> MySQL, I put this in my settings.py:
>
> import pymysql
> pymysql.install_as_MySQLdb()
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> . . . .
>
> I have a few months of testing before I'll know if it is reliable, but at 
> least I can move forward with development.
>
> Richard
>
> On Monday, May 5, 2014 6:45:19 PM UTC-6, Richard Esplin wrote:
>>
>> I can't find any evidence on the interwebs of someone successfully using 
>> the Mysql-Connector-Python with Django 1.7. So I reported it as an issue in 
>> the MySQL bug database:
>>
>> http://bugs.mysql.com/bug.php?id=72542
>>
>> If anyone has a suggestion for using MySQL with Python 3 and Django 1.7, 
>> I would appreciate hearing them.
>>
>> Thanks,
>>
>> Richard
>>
>> On Monday, May 5, 2014 6:17:57 PM UTC-6, Richard Esplin wrote:
>>>
>>> I am also trying to use Django 1.7 with the Mysql-Python-Connector 
>>> 1.1.6. I am seeing the same behavior for both the migrate 
>>> NotImplementedError and the syncdb RemovedInDjango19Warrning.
>>>
>>> Were you able to solve these problems?
>>>
>>> Richard
>>>
>>> On Thursday, April 3, 2014 9:09:31 AM UTC-6, Giovanni wrote:

 Documentation states:

- 

syncdb has been deprecated and replaced by migrate. Don’t worry - 
calls to syncdb will still work as before.


 But when I run $ python manage.py syncdb,
 it stops with a django.utils.deprecation.RemovedInDjango19Warning.

 So I can't seem to use syncdb either.


 On Wednesday, April 2, 2014 6:42:55 PM UTC-4, Giovanni wrote:
>
> I upgraded from django 1.6 to 1.7b1 and now it seems like as soon as I 
> want to do anything that interacts with mysql, I keep getting this error:
>
> NotImplementedError: subclasses of BaseDatabaseWrapper may require a 
> schema_editor() method
>
> In Python I can import mysql.connector just fine.
> I've reinstalled mysql 5.6.17 community server.
>
> Any ideas?
>

>

-- 
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/6f15c19d-6712-421f-8b77-c8d3b06615d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-05-06 Thread Richard Esplin
In order to move forward with this project, I switched to PyMySQL:

https://github.com/PyMySQL

It appears to work great. In order to use the default Django backend for 
MySQL, I put this in my settings.py:

import pymysql
pymysql.install_as_MySQLdb()

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
. . . .

I have a few months of testing before I'll know if it is reliable, but at 
least I can move forward with development.

Richard

On Monday, May 5, 2014 6:45:19 PM UTC-6, Richard Esplin wrote:
>
> I can't find any evidence on the interwebs of someone successfully using 
> the Mysql-Connector-Python with Django 1.7. So I reported it as an issue in 
> the MySQL bug database:
>
> http://bugs.mysql.com/bug.php?id=72542
>
> If anyone has a suggestion for using MySQL with Python 3 and Django 1.7, I 
> would appreciate hearing them.
>
> Thanks,
>
> Richard
>
> On Monday, May 5, 2014 6:17:57 PM UTC-6, Richard Esplin wrote:
>>
>> I am also trying to use Django 1.7 with the Mysql-Python-Connector 1.1.6. 
>> I am seeing the same behavior for both the migrate NotImplementedError and 
>> the syncdb RemovedInDjango19Warrning.
>>
>> Were you able to solve these problems?
>>
>> Richard
>>
>> On Thursday, April 3, 2014 9:09:31 AM UTC-6, Giovanni wrote:
>>>
>>> Documentation states:
>>>
>>>- 
>>>
>>>syncdb has been deprecated and replaced by migrate. Don’t worry - 
>>>calls to syncdb will still work as before.
>>>
>>>
>>> But when I run $ python manage.py syncdb,
>>> it stops with a django.utils.deprecation.RemovedInDjango19Warning.
>>>
>>> So I can't seem to use syncdb either.
>>>
>>>
>>> On Wednesday, April 2, 2014 6:42:55 PM UTC-4, Giovanni wrote:

 I upgraded from django 1.6 to 1.7b1 and now it seems like as soon as I 
 want to do anything that interacts with mysql, I keep getting this error:

 NotImplementedError: subclasses of BaseDatabaseWrapper may require a 
 schema_editor() method

 In Python I can import mysql.connector just fine.
 I've reinstalled mysql 5.6.17 community server.

 Any ideas?

>>>

-- 
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/fb7f6911-e755-46ff-9cb3-cb7150e712e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-05-05 Thread Richard Esplin
This is actually a warning, and only halts execution when settings.py has 
DEBUG enabled. See mysql/connector/django/base.py line 59.

However when syncdb proceeds past the deprecation warning, it halts on the 
error about needing schema_editor implemented.

On Thursday, April 3, 2014 9:09:31 AM UTC-6, Giovanni wrote:
>
> Documentation states:
>
>- 
>
>syncdb has been deprecated and replaced by migrate. Don’t worry - 
>calls to syncdb will still work as before.
>
>
> But when I run $ python manage.py syncdb,
> it stops with a django.utils.deprecation.RemovedInDjango19Warning.
>
> So I can't seem to use syncdb either.
>
>
> On Wednesday, April 2, 2014 6:42:55 PM UTC-4, Giovanni wrote:
>>
>> I upgraded from django 1.6 to 1.7b1 and now it seems like as soon as I 
>> want to do anything that interacts with mysql, I keep getting this error:
>>
>> NotImplementedError: subclasses of BaseDatabaseWrapper may require a 
>> schema_editor() method
>>
>> In Python I can import mysql.connector just fine.
>> I've reinstalled mysql 5.6.17 community server.
>>
>> Any ideas?
>>
>

-- 
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/5bb0dcdb-3db3-4604-9bdb-7a43c9b454a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-05-05 Thread Richard Esplin
I can't find any evidence on the interwebs of someone successfully using 
the Mysql-Connector-Python with Django 1.7. So I reported it as an issue in 
the MySQL bug database:

http://bugs.mysql.com/bug.php?id=72542

If anyone has a suggestion for using MySQL with Python 3 and Django 1.7, I 
would appreciate hearing them.

Thanks,

Richard

On Monday, May 5, 2014 6:17:57 PM UTC-6, Richard Esplin wrote:
>
> I am also trying to use Django 1.7 with the Mysql-Python-Connector 1.1.6. 
> I am seeing the same behavior for both the migrate NotImplementedError and 
> the syncdb RemovedInDjango19Warrning.
>
> Were you able to solve these problems?
>
> Richard
>
> On Thursday, April 3, 2014 9:09:31 AM UTC-6, Giovanni wrote:
>>
>> Documentation states:
>>
>>- 
>>
>>syncdb has been deprecated and replaced by migrate. Don’t worry - 
>>calls to syncdb will still work as before.
>>
>>
>> But when I run $ python manage.py syncdb,
>> it stops with a django.utils.deprecation.RemovedInDjango19Warning.
>>
>> So I can't seem to use syncdb either.
>>
>>
>> On Wednesday, April 2, 2014 6:42:55 PM UTC-4, Giovanni wrote:
>>>
>>> I upgraded from django 1.6 to 1.7b1 and now it seems like as soon as I 
>>> want to do anything that interacts with mysql, I keep getting this error:
>>>
>>> NotImplementedError: subclasses of BaseDatabaseWrapper may require a 
>>> schema_editor() method
>>>
>>> In Python I can import mysql.connector just fine.
>>> I've reinstalled mysql 5.6.17 community server.
>>>
>>> Any ideas?
>>>
>>

-- 
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/de3a1dcd-25ce-4b31-a02c-39d5ddbeee1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-05-05 Thread Richard Esplin
I am also trying to use Django 1.7 with the Mysql-Python-Connector 1.1.6. I 
am seeing the same behavior for both the migrate NotImplementedError and 
the syncdb RemovedInDjango19Warrning.

Were you able to solve these problems?

Richard

On Thursday, April 3, 2014 9:09:31 AM UTC-6, Giovanni wrote:
>
> Documentation states:
>
>- 
>
>syncdb has been deprecated and replaced by migrate. Don’t worry - 
>calls to syncdb will still work as before.
>
>
> But when I run $ python manage.py syncdb,
> it stops with a django.utils.deprecation.RemovedInDjango19Warning.
>
> So I can't seem to use syncdb either.
>
>
> On Wednesday, April 2, 2014 6:42:55 PM UTC-4, Giovanni wrote:
>>
>> I upgraded from django 1.6 to 1.7b1 and now it seems like as soon as I 
>> want to do anything that interacts with mysql, I keep getting this error:
>>
>> NotImplementedError: subclasses of BaseDatabaseWrapper may require a 
>> schema_editor() method
>>
>> In Python I can import mysql.connector just fine.
>> I've reinstalled mysql 5.6.17 community server.
>>
>> Any ideas?
>>
>

-- 
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/643b22da-c93d-4711-af61-957677146295%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-04-03 Thread Giovanni
Documentation states:

   - 
   
   syncdb has been deprecated and replaced by migrate. Don’t worry - calls 
   to syncdb will still work as before.
   

But when I run $ python manage.py syncdb,
it stops with a django.utils.deprecation.RemovedInDjango19Warning.

So I can't seem to use syncdb either.


On Wednesday, April 2, 2014 6:42:55 PM UTC-4, Giovanni wrote:
>
> I upgraded from django 1.6 to 1.7b1 and now it seems like as soon as I 
> want to do anything that interacts with mysql, I keep getting this error:
>
> NotImplementedError: subclasses of BaseDatabaseWrapper may require a 
> schema_editor() method
>
> In Python I can import mysql.connector just fine.
> I've reinstalled mysql 5.6.17 community server.
>
> Any ideas?
>

-- 
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/fe96da17-2c59-4238-97b2-ae56e64ea647%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-04-02 Thread Giovanni
I upgraded from django 1.6 to 1.7b1 and now it seems like as soon as I want 
to do anything that interacts with mysql, I keep getting this error:

NotImplementedError: subclasses of BaseDatabaseWrapper may require a 
schema_editor() method

In Python I can import mysql.connector just fine.
I've reinstalled mysql 5.6.17 community server.

Any ideas?

-- 
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/f656b63d-0eb5-4c17-836b-6c3d41938984%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django GenericRelation not working

2014-01-03 Thread arthur . muchir
Thanks Daniel for your answer.

I didn't know I could use a simple FK in this case. I will try using it. I 
didn't want to directly inherit from GenericMedia because I don't want to 
merge ContentType datas (content_type, content_object, etc.) with my own 
Media datas (description, link, ...)

So far I just see a problem I'm going to meet in my save method :

I will change my Media model to this one : 

class Media(models.Model):
description = models.CharField(blank = True, max_length = 500)
link= models.URLField(blank = True)
generic_fk  = models.OneToOneField(GenericMedia)

class Meta:
abstract = True

def __unicode__(self):
return u"%s" % os.path.basename(self.url.name)

def save(self, *args, **kwargs):
super(Media, self).save(*args, **kwargs)
generic_link = GenericMedia(content_object = self)
generic_link.save()
generic_fk = generic_link.id


But I think I will have a problem with the save method, Media have a FK to 
GenericMedia but GenericMedia have to Media, so how could I adapt ? Thanks !

Le jeudi 2 janvier 2014 22:09:22 UTC+1, arthur...@gmail.com a écrit :
>
> I have the following model in my app, using the content-type django 
> framework in version 1.6.1 :
>
> class GenericMedia(models.Model):
> limit   = models.Q(model = 'Image') | models.Q(model = 'Video') | 
> models.Q(model = 'Other')
> content_type= models.ForeignKey(ContentType, limit_choices_to = limit)
> object_id   = models.PositiveIntegerField()
> content_object  = generic.GenericForeignKey('content_type', 'object_id')
>
> def __unicode__(self):
> return u"%s" % os.path.basename(self.content_object.url.name)
>
> def instance(self):
> return self.content_object.__class__.__name__
>
> class Media(models.Model):
> description = models.CharField(blank = True, max_length = 500)
> link= models.URLField(blank = True)
> genericFK   = generic.GenericRelation(GenericMedia, 
> content_type_field='content_type', object_id_field='object_id')
>
> class Meta:
> abstract = True
>
> def __unicode__(self):
> return u"%s" % os.path.basename(self.url.name)
>
> def save(self, *args, **kwargs):
> super(Media, self).save(*args, **kwargs)
> generic_link = GenericMedia(content_object = self)
> generic_link.save()
>
> class Image(Media):
> imgW = models.PositiveSmallIntegerField()
> imgH = models.PositiveSmallIntegerField()
> url  = models.ImageField(upload_to = 'mediamanager', height_field = 
> 'imgH', width_field = 'imgW')
>
> Everythings works fine, excepts the GenericRelation in my abstract Media 
> Class.
>
> In django documentation it is said that :
> If you delete an object that has a GenericRelation, any objects which have a 
> GenericForeignKey pointing at it will be deleted as well.
>
> But my problem is that when I delete an image (wich extends Media), the 
> GenericMedia pointing to it is not deleted.
>
> If anyone has a solution, thanks !
>
>

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


Re: Django GenericRelation not working

2014-01-03 Thread Daniel Roseman
On Thursday, 2 January 2014 21:09:22 UTC, arthur...@gmail.com wrote:
>
> I have the following model in my app, using the content-type django 
> framework in version 1.6.1 :
>
> class GenericMedia(models.Model):
> limit   = models.Q(model = 'Image') | models.Q(model = 'Video') | 
> models.Q(model = 'Other')
> content_type= models.ForeignKey(ContentType, limit_choices_to = limit)
> object_id   = models.PositiveIntegerField()
> content_object  = generic.GenericForeignKey('content_type', 'object_id')
>
> def __unicode__(self):
> return u"%s" % os.path.basename(self.content_object.url.name)
>
> def instance(self):
> return self.content_object.__class__.__name__
>
> class Media(models.Model):
> description = models.CharField(blank = True, max_length = 500)
> link= models.URLField(blank = True)
> genericFK   = generic.GenericRelation(GenericMedia, 
> content_type_field='content_type', object_id_field='object_id')
>
> class Meta:
> abstract = True
>
> def __unicode__(self):
> return u"%s" % os.path.basename(self.url.name)
>
> def save(self, *args, **kwargs):
> super(Media, self).save(*args, **kwargs)
> generic_link = GenericMedia(content_object = self)
> generic_link.save()
>
> class Image(Media):
> imgW = models.PositiveSmallIntegerField()
> imgH = models.PositiveSmallIntegerField()
> url  = models.ImageField(upload_to = 'mediamanager', height_field = 
> 'imgH', width_field = 'imgW')
>
> Everythings works fine, excepts the GenericRelation in my abstract Media 
> Class.
>
> In django documentation it is said that :
> If you delete an object that has a GenericRelation, any objects which have a 
> GenericForeignKey pointing at it will be deleted as well.
>
> But my problem is that when I delete an image (wich extends Media), the 
> GenericMedia pointing to it is not deleted.
>
> If anyone has a solution, thanks !
>
>
I don't understand why you are using generic relations at all here. Model 
subclassing and generic relations are *alternatives* to allow multiple 
model types to relate to a single destination. Since your subclasses 
already all inherit from Media, why do you need a generic relation between 
Media and GenericMedia? Why not a standard ForeignKey? Or why not inherit 
directly from GenericMedia in the first place?
--
DR. 

-- 
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/7dddeb77-bc59-42ff-aca4-bfcaed29677f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django GenericRelation not working

2014-01-02 Thread arthur . muchir
I have the following model in my app, using the content-type django 
framework in version 1.6.1 :

class GenericMedia(models.Model):
limit   = models.Q(model = 'Image') | models.Q(model = 'Video') | 
models.Q(model = 'Other')
content_type= models.ForeignKey(ContentType, limit_choices_to = limit)
object_id   = models.PositiveIntegerField()
content_object  = generic.GenericForeignKey('content_type', 'object_id')

def __unicode__(self):
return u"%s" % os.path.basename(self.content_object.url.name)

def instance(self):
return self.content_object.__class__.__name__

class Media(models.Model):
description = models.CharField(blank = True, max_length = 500)
link= models.URLField(blank = True)
genericFK   = generic.GenericRelation(GenericMedia, 
content_type_field='content_type', object_id_field='object_id')

class Meta:
abstract = True

def __unicode__(self):
return u"%s" % os.path.basename(self.url.name)

def save(self, *args, **kwargs):
super(Media, self).save(*args, **kwargs)
generic_link = GenericMedia(content_object = self)
generic_link.save()

class Image(Media):
imgW = models.PositiveSmallIntegerField()
imgH = models.PositiveSmallIntegerField()
url  = models.ImageField(upload_to = 'mediamanager', height_field = 'imgH', 
width_field = 'imgW')

Everythings works fine, excepts the GenericRelation in my abstract Media Class.

In django documentation it is said that :
If you delete an object that has a GenericRelation, any objects which have a 
GenericForeignKey pointing at it will be deleted as well.

But my problem is that when I delete an image (wich extends Media), the 
GenericMedia pointing to it is not deleted.

If anyone has a solution, thanks !

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


Re: django summernote not working properly

2013-10-16 Thread Hyun-woo Park
Thank you for reporting. 
See 
http://stackoverflow.com/questions/19347067/django-summernote-not-working-properly/19406459#19406459

2013년 10월 14일 월요일 오전 1시 8분 28초 UTC+9, Kakar 님의 말:
>
> I am using django-summernote <https://github.com/lqez/django-summernote>as a 
> wysiwyg editor. And till now, I can save the post from the summernote 
> editor and can display it too using the safe filter. But some of its 
> functionalities are not there in my template.
>
>1. There is no image upload button in the editor.
>2. The Code style is displaying fine, but the Quote style is 
>displaying just a regular text.
>
> And finally, is it safe to use safe filter in the templates?
>
> Please help me how do I solve this problem. Or I can't use it in django? 
> Thank you.
>  

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


django summernote not working properly

2013-10-13 Thread Karl Arunachal
I am using django-summernote  as
a wysiwyg editor. And till now, I can save the post from the summernote
editor and can display it too using the safe filter. But some of its
functionalities are not there in my template.

   1. There is no image upload button in the editor.
   2. The Code style is displaying fine, but the Quote style is displaying
   just a regular text.

And finally, is it safe to use safe filter in the templates?

Please help me how do I solve this problem. Or I can't use it in django?
Thank you.

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


Re: django-admin.py not working on OS X 10.5

2012-08-04 Thread James Walton
Brandon, 

I had the same issue and this is how I resolved it.  

1. Delete the reference django-admin.py in /usr/local/bin that was 
generated by the installer.
2. Then, manually recreate the symlink by doing:
3. ln -s YOUR_ABSOLUTE_PATH/build/scripts-2.7/django-admin.py /usr/local/bin
4. Close the terminal
5. Reopen.
6. Create your project from your desired folder. (django-admin.py 
startproject foo)

Hope that helps!

On Thursday, May 8, 2008 9:33:26 AM UTC-5, Brandon Taylor wrote:
>
> Hello everyone, 
>
> Sorry for the late reply. I have changed the shebang line to /usr/ 
> local/bin, which is where the Python interpreter is installed. I have 
> changed permissions on django-admin.py to be executable. 
>
> Here is my .bash_profile: 
>
> PATH=$PATH:/usr/local/bin 
> PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" 
> PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$ 
> {PATH}" 
> export PATH 
>
> And STILL - django-admin.py startproject foo = command not found 
>
> WTF? I'm at a loss! 
>
> On May 8, 6:45 am, "Shane Emmons"  wrote: 
> > Did you, "chmod +x django-admin.py"? 
> > 
> > 
> > 
> > On Thu, May 8, 2008 at 6:52 AM, Francis  wrote: 
> > 
> > > It works without problem here. 
> > 
> > > 1. I copy my trunk into the default python site-package /Library/ 
> > > Python/2.5/site-packages/django 
> > 
> > > Normally I use /usr/bin, since local/bin doens't exist on Leopard 
> > > (exept if you are using something like fink or macport) 
> > > But I tried it to see if it works. 
> > > 2. I create the directory : sudo mkdir /usr/local/bin 
> > > 3. then symlink : sudo ln -sf 
> /Library/Python/2.5/site-packages/django/ 
> > > bin/django-admin.py /usr/local/bin/django-admin.py 
> > 
> > > it works. /usr/local/bin is already in your path. 
> > 
> > > Francis 
> > 
> > > On May 7, 6:46 pm, Brandon Taylor  wrote: 
> > > > Hello everyone, 
> > 
> > > > I'm setting up a dev environment on a co-worker's Mac running 10.5.2 
> > 
> > > > I have Django cehcked out from trunk, and symlinked into Python 
> 2.5.2. 
> > > > I can successfully import Django from within a Python terminal 
> > > > session. 
> > 
> > > > I have django-admin.py symlinked from the trunk checkout to 
> /usr/local/ 
> > > > bin. 
> > 
> > > > When I try to execute: django-admin.py startproject foo, I get an 
> > > > error saying: 
> > > > django-admin.py: command not found 
> > 
> > > > I have added /usr/local/bin to my .bash_profile, resourced, and 
> > > > restarted, but still no dice. Anyone have any ideas on what I did 
> > > > wrong? I've doen this many times, just not on 10.5. 
> > 
> > > > TIA, 
> > > > Brandon 
> > 
> > -- 
> > Shane Emmons 
> > E: semmon...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Z3oYEu4WrjsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Pagination Not Working!

2012-05-08 Thread Tom Evans
On Sun, May 6, 2012 at 10:56 PM, coded kid  wrote:
> I'm trying to paginate a page in order to display five statuses per
> page. After inputting these codes, it fails to paginate. Below are the
> codes for pagination and updating of status in my django app.
>
>
> Views:
>
>  def qask(request):
>          extra_data_context={}
>             #if there's nothing in the field do nothing.
>          if request. method=="POST":
>              form =AskForm(request.POST)
>              if form.is_valid():
>                  data=form.cleaned_data
>                  newask=Ask(
>                     user= request.user,
>                     status=data['status'],
>                     pub_date=datetime.datetime.now())
>                 newask.save()
>              extra_data_context.update({'AskForm':form})
>        else:
>            form = AskForm()
>            extra_data_context.update({'AskForm':form})
>
> extra_data_context.update({'Asks':Ask.objects.filter(user=request.user)})

So here you specify 'Asks' as all Ask objects associated with the current user.

>
>       plan=Ask.objects.all()
>       paginator=Paginator(plan, 5)
>
>       try:
>           page=int(request.GET.get('page','1'))
>       except ValueError:
>           page=1
>
>       try:
>          fp=paginator.page(page)
>      except (EmptyPage, InvalidPage):
>          fp=paginator.page(paginator.num_pages)

Here you paginate all Ask objects, and don't do anything with pagination object.


>      return render_to_response
> ('quik_ask.html',extra_data_context,context_instance=RequestContext(request))
>
> Template:
>  {% block content %}
>
>
>
>          {% for Ask in Asks %}
>       
>         {{Ask.user}}  
>         {{Ask.status}}
>           {{Ask.state}} | {{Ask.pub_date|timesince }} ago 
>
>          
>        {% endfor %}
>
>    
>       
>    {% if Asks.has_previous %}

And here you start using 'Asks' in the template as though it had been
paginated and was not a raw queryset. This is unlikely to work.

When you paginate a queryset, you need to create a paginator object
with that queryset, page the paginator to select an appropriate page,
and then pass the page to the template.

This is covered in mind numbing detail in the Django docs:

https://docs.djangoproject.com/en/1.4/topics/pagination/#using-paginator-in-a-view

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django Pagination Not Working!

2012-05-06 Thread coded kid
I'm trying to paginate a page in order to display five statuses per
page. After inputting these codes, it fails to paginate. Below are the
codes for pagination and updating of status in my django app.


Views:

 def qask(request):
  extra_data_context={}
 #if there's nothing in the field do nothing.
  if request. method=="POST":
  form =AskForm(request.POST)
  if form.is_valid():
  data=form.cleaned_data
  newask=Ask(
 user= request.user,
 status=data['status'],
 pub_date=datetime.datetime.now())
 newask.save()
  extra_data_context.update({'AskForm':form})
else:
form = AskForm()
extra_data_context.update({'AskForm':form})
 
extra_data_context.update({'Asks':Ask.objects.filter(user=request.user)})

   plan=Ask.objects.all()
   paginator=Paginator(plan, 5)

   try:
   page=int(request.GET.get('page','1'))
   except ValueError:
   page=1

   try:
  fp=paginator.page(page)
  except (EmptyPage, InvalidPage):
  fp=paginator.page(paginator.num_pages)
  return render_to_response
('quik_ask.html',extra_data_context,context_instance=RequestContext(request))

Template:
  {% block content %}



  {% for Ask in Asks %}
   
 {{Ask.user}}  
 {{Ask.status}}
   {{Ask.state}} | {{Ask.pub_date|timesince }} ago 

  
{% endfor %}


   
{% if Asks.has_previous %}
previous
{% endif %}


Page {{ Asks.number }} of {{ Asks.paginator.num_pages }}.


{% if Asks.has_next %}
next
{% endif %}
 




 {% endblock %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django caching not working with SSL(https)

2011-06-22 Thread Anoop Thomas Mathew
Hi all,
I figured it out. The problem was with the google analytics cookies which
made each cookie different and vary on cookie reloaded cache each time.

This snippet helped.
http://djangosnippets.org/snippets/1772/

regards,
Anoop

atm
___
Life is short, Live it hard.




On 21 June 2011 15:55, Anoop Thomas Mathew  wrote:

> Hi all,
>
> A site which was caching through django caching backend db cache) it was
> working well. When we changed it to https instead of http, the system
> suddenly stopped caching. Is there any thought's regarding this?
> Anyone got the same issue?
>
> regards,
> Anoop
>
> atm
> ___
> Life is short, Live it hard.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



  1   2   >