How to write api for sms intregartion in django I am new in django?

2018-08-01 Thread imran
I want to write a api when form submit a sms should go to the phone, I 
don't know how to do that can somone help me regarding 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/253c999f-2151-4b42-8bd9-f7288f57c394%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write api for sms intregartion in django I am new in django?

2018-08-01 Thread Tim Vogt (Tim Vogt)
https://www.twilio.com/blog/2014/04/building-a-simple-sms-message-application-with-twilio-and-django-2.html


> Op 1 aug. 2018, om 09:15 heeft im...@wsegames.com het volgende geschreven:
> 
> I want to write a api when form submit a sms should go to the phone, I don't 
> know how to do that can somone help me regarding 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/253c999f-2151-4b42-8bd9-f7288f57c394%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/1046E16C-657D-4D5F-AF5C-876D37FDE5AB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write api for sms intregartion in django I am new in django?

2018-08-01 Thread imran
I want to write api how to write can you help me?

On Wednesday, August 1, 2018 at 12:47:55 PM UTC+5:30, Tim Vogt wrote:
>
>
> https://www.twilio.com/blog/2014/04/building-a-simple-sms-message-application-with-twilio-and-django-2.html
>
>
> Op 1 aug. 2018, om 09:15 heeft im...@wsegames.com  het 
> volgende geschreven:
>
> I want to write a api when form submit a sms should go to the phone, I 
> don't know how to do that can somone help me regarding 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...@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/253c999f-2151-4b42-8bd9-f7288f57c394%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/dd0204e8-170a-4c52-b920-1a2e57477a40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write api for sms intregartion in django I am new in django?

2018-08-01 Thread imran
Here is my code


class RegisterView(CreateView):
form_class = RegisterForm
template_name = 'accounts/register.html'
success_url = '/success-membership/'

def form_valid(self, form):
url = "http://enterprise.smsgupshup.com/GatewayAPI/rest";
payload = 
"method=sendMessage&send_to=XX&msg=new&msg_type=TEXT&userid=X&auth_scheme=PLAIN&password=X&format=TEXT"
response = requests.request("POST", url, data=payload)
print(response.text)
return HttpResponse(response)


On Wednesday, August 1, 2018 at 12:47:55 PM UTC+5:30, Tim Vogt wrote:
>
>
> https://www.twilio.com/blog/2014/04/building-a-simple-sms-message-application-with-twilio-and-django-2.html
>
>
> Op 1 aug. 2018, om 09:15 heeft im...@wsegames.com  het 
> volgende geschreven:
>
> I want to write a api when form submit a sms should go to the phone, I 
> don't know how to do that can somone help me regarding 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...@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/253c999f-2151-4b42-8bd9-f7288f57c394%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/2d3b91f8-1636-4625-85b5-40699401c3e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write api for sms intregartion in django I am new in django?

2018-08-01 Thread Mark Caglienzi
On Wed, 2018-08-01 at 00:26 -0700, im...@wsegames.com wrote:
> Here is my code
> 
> 
> class RegisterView(CreateView):
> form_class = RegisterForm
> template_name = 'accounts/register.html'
> success_url = '/success-membership/'
> 
> def form_valid(self, form):
> url = "http://enterprise.smsgupshup.com/GatewayAPI/rest";
> payload = 
> "method=sendMessage&send_to=XX&msg=new&msg_type=TEXT&userid=X&auth_scheme=PLAIN&password=X&format=TEXT"
> response = requests.request("POST", url, data=payload)
> print(response.text)
> return HttpResponse(response)

Well, apart from everything, making a request with user and password in the 
clear
it's not a good idea at all.

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


Re: How to write api for sms intregartion in django I am new in django?

2018-08-01 Thread imran
I just want to test other wise I can load the data dynamically

On Wednesday, August 1, 2018 at 1:06:12 PM UTC+5:30, Mark Caglienzi wrote:
>
> On Wed, 2018-08-01 at 00:26 -0700, im...@wsegames.com  
> wrote: 
> > Here is my code 
> > 
> > 
> > class RegisterView(CreateView): 
> > form_class = RegisterForm 
> > template_name = 'accounts/register.html' 
> > success_url = '/success-membership/' 
> > 
> > def form_valid(self, form): 
> > url = "http://enterprise.smsgupshup.com/GatewayAPI/rest"; 
> > payload = 
> "method=sendMessage&send_to=XX&msg=new&msg_type=TEXT&userid=X&auth_scheme=PLAIN&password=X&format=TEXT"
>  
>
> > response = requests.request("POST", url, data=payload) 
> > print(response.text) 
> > return HttpResponse(response) 
>
> Well, apart from everything, making a request with user and password in 
> the clear 
> it's not a good idea at all. 
>
>

-- 
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/696d26a6-0922-47e3-8ee6-f11f50c22f36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problems Faced with some login requirements. Please read the thread below

2018-08-01 Thread vineeth sagar
Hi,

So we are currently doing a project where the client wants the session to 
expire at browser close and also prevent multiple logins from the same 
account. Well there are some ways to implement the multiple login thing, 
consider this say user closes the browser, the session cookie expires. When 
a new request comes in we cannot validate this to see if this is a new 
login request because of expiry or if this a second login from the same 
account. So there's no good way to implement this(I think).

I suggested this, have a rigid session expiry that is it expires in 'N' 
hours/minutes/seconds, So when a new request comes in we can validate with 
the session expiry in the db. If the session has not expired we know that 
he's trying to login for a second time. 
. I needed to change the session middleware to set the outgoing cookie only 
once. I only modified process_response, I pasted it below. I also added a 
new seessionstore class override two methods. The logic is simple, for the 
first time when a new request comes in, load is never invoked. So in 
create_db_instance we set an expiry date. When ever people try to modify 
the session, the load is invoked and we can get the expiry of the exisiting 
session from  that.


*It's works fine without any side affects. From what I understand after 
reading through session modules for a 3 straight days, I am just posting it 
here so that I know if I have not done some thing stupid, I want to have a 
second set of eyes to validate my approach.*



class NewSessionStore(SessionStore):
actual_expiry=None
def _get_session_from_db(self):
try:
return self.model.objects.get(
session_key=self.session_key,
expire_date__gt=timezone.now()
)
except (self.model.DoesNotExist, SuspiciousOperation) as e:
if isinstance(e, SuspiciousOperation):
logger = logging.getLogger(
'django.security.%s' % e.__class__.__name__)
logger.warning(str(e))
self._session_key = None
def load(self):
#print("In load")
s = self._get_session_from_db()
if s:
self.actual_expiry=s.expire_date
return self.decode(s.session_data) if s else {}
def create_model_instance(self, data):
"""
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database. 
"""
#print("In create_model_instance")
if not self.actual_expiry:
from datetime import datetime
print("Expire Time thats being set",datetime.now())
self.actual_expiry=self.get_expiry_date()
return self.model(
session_key=self._get_or_create_session_key(),
session_data=self.encode(data),
expire_date=self.actual_expiry,
)


def process_response(self, request, response):
"""
If request.session was modified, or if the configuration is to save the
session every time, save the changes and set a session cookie or delete
the session cookie if the session has been emptied.
"""
try:
accessed = request.session.accessed
modified = request.session.modified
empty = request.session.is_empty()
except AttributeError:
pass
else:
# First check if we need to delete this cookie.
# The session should be deleted only if the session is entirely empty
if settings.SESSION_COOKIE_NAME in request.COOKIES and empty:
response.delete_cookie(
settings.SESSION_COOKIE_NAME,
path=settings.SESSION_COOKIE_PATH,
domain=settings.SESSION_COOKIE_DOMAIN,
)
else:
if accessed:
patch_vary_headers(response, ('Cookie',))
if (modified or settings.SESSION_SAVE_EVERY_REQUEST) and not empty:
if request.session.get_expire_at_browser_close():
max_age = None
expires = None
else:
max_age = request.session.get_expiry_age()
if request.COOKIES.get(settings.SESSION_COOKIE_NAME):
pass
else:
expires_time = time.time()+max_age
expires = http_date(expires_time)
response.set_cookie(
settings.SESSION_COOKIE_NAME,
request.session.session_key, max_age=max_age,
expires=expires,
domain=settings.SESSION_COOKIE_DOMAIN,
path=settings.SESSION_COOKIE_PATH,
secure=settings.SESSION_COOKIE_SECURE or None,
httponly=settings.SESSION_COOKIE_HTTPONLY or None,
)
# Save the session data and refresh the client cookie.
# Skip session save for 500 responses, refs #3881.
if response.status_code != 500:
try:
request.session.save()
except UpdateError:
raise SuspiciousOperation(
"The request's session was deleted before the "
"request completed. The user may have logged "
"out in a concurrent request, for example."
)

-- 
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/b754ba38-f4bf-4f5f-8db6-e5eb1b0759da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


i want to save is_staff value true in db but not save in database

2018-08-01 Thread lalitaquasoft
*Advance Thanks for your help:*


*is_staff  value is not save in database*

*Here is Code:*

from django.contrib.auth import login, authenticate
from django.shortcuts import render, redirect
from blog.forms import SignUpForm 

def signup(request):
if request.method == 'POST':
form = SignUpForm(request.POST)
if form.is_valid():
form.is_staff = 1
form.save()
# username = form.cleaned_data.get('username')
# raw_password = form.cleaned_data.get('password1')
# user = authenticate(username=username, password=raw_password)
# login(request, user)
# return redirect('home')
else:
form = SignUpForm()
return render(request, 'register.html', {'form': form})

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


Re: Live Streaming Video through WebCam

2018-08-01 Thread mottaz hejaze
this is awesome man ..

On Tue, 31 Jul 2018, 16:20 Pravin Yadav,  wrote:

> *Hello Everyone, I'm using the Live Streaming Video through WebCam. It's
> storing in .avi format. When i'm playing the Video. I'm not getting the
> audio of that video. I hope that opencv does not provide the audio
> features. Kindly let me know if you have any idea. Thanks,*
>
>
> *Please find the below code:---*
>
> import os.path
> import numpy as np
> import cv2, time
> import random
>
> def change_res(cap, width, height):
> cap.set(3, width)
> cap.set(4, height)
>
> #Standard Video Dimensions Sizes
> STD_DIMENSIONS = {
> '480p': (640, 480),
> '720p': (1280, 720),
> '1080p': (1920, 1080),
> '4k': (3840, 2160),
> }
>
> VIDEO_TYPE = {
> 'avi':cv2.VideoWriter_fourcc(*'XVID'),
> 'mp4':cv2.VideoWriter_fourcc(*'XVID'),
> }
>
> def get_video_type(filename):
> ext = os.path.splitext(filename),
> if ext in VIDEO_TYPE:
> return VIDEO_TYPE[ext]
> return VIDEO_TYPE['avi']
>
> def get_dims(cap, res='480p'):
> width, height = STD_DIMENSIONS['480p']
> if res in STD_DIMENSIONS:
> width, height = STD_DIMENSIONS[res]
> change_res(cap, width, height)
> return width, height
>
> #--START LIVE VIDEO--#
> random_id = random.randint(1,9)
> livevideo_name = str('livevideo_'+str(random_id)+'.avi')
> frames_per_second = 20.0  #..Frame Per Second
> my_res = '480p'  #..Frame Size
>
> # Capture video from camera
> livevideos = '/livevideos/'+livevideo_name
> cap = cv2.VideoCapture(-1)
> dims = get_dims(cap, res=my_res)
> video_type_cv2 = get_video_type(livevideos)
>
> # Define the codec and create VideoWriter object
> fourcc = cv2.VideoWriter_fourcc(*'XVID') # Be sure to use the lower case
> out = cv2.VideoWriter(livevideos, video_type_cv2, frames_per_second, dims)
> while(True):
> ret, frame = cap.read()
> if ret==True:
> frame = cv2.flip(frame,1)
> # Write the frame into the file
> out.write(frame)
> cv2.imshow('frame',frame)
> if cv2.waitKey(1) & 0xFF == ord('q'):
> break
> else:
> break
>
> # When everything done, release the video capture and video write objects
> cap.release()
> out.release()
> # Closes all the frames
> cv2.destroyAllWindows()
>
> --
> 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/CAEr6%3DdzZyO44sDLkd-HPoqh-LCuuvvnRiXDfEeXWZduCxBuw4g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


django.db.models.Model save method doesn't call full_clean (Django 1.11.14)

2018-08-01 Thread Uri Even-Chen
Hi,

I noticed that django.db.models.Model save method doesn't
call self.full_clean(). Is it a good practice to call self.full_clean() in
my own models (which subclass django.db.models.Model) save method before
calling "super().save(*args, **kwargs)"? I tried to add it in my models but
I received many errors in tests:

==
ERROR: test_user_gets_redirected_to_his_profile
(speedy.net.accounts.tests.test_views.IndexViewTestCase)
--
Traceback (most recent call last):
  File "speedy\net\accounts\tests\test_views.py", line 8, in setUp
self.user = ActiveUserFactory()
  File "VENV~1\lib\site-packages\factory\base.py", line 46, in __call__
return cls.create(**kwargs)
  File "VENV~1\lib\site-packages\factory\base.py", line 563, in create
return cls._generate(enums.CREATE_STRATEGY, kwargs)
  File "VENV~1\lib\site-packages\factory\base.py", line 500, in _generate
return step.build()
  File "VENV~1\lib\site-packages\factory\builder.py", line 279, in build
kwargs=kwargs,
  File "VENV~1\lib\site-packages\factory\base.py", line 314, in instantiate
return self.factory._create(model, *args, **kwargs)
  File "VENV~1\lib\site-packages\factory\django.py", line 165, in _create
return manager.create(*args, **kwargs)
  File "VENV~1\lib\site-packages\django\db\models\manager.py", line 85, in
manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "VENV~1\lib\site-packages\modeltranslation\manager.py", line 405, in
create
return super(MultilingualQuerySet, self).create(**kwargs)
  File "VENV~1\lib\site-packages\django\db\models\query.py", line 394, in
create
obj.save(force_insert=True, using=self.db)
  File "speedy\core\accounts\models.py", line 52, in save
return super().save(*args, **kwargs)
  File "speedy\core\base\models.py", line 19, in save
self.full_clean()
  File "VENV~1\lib\site-packages\django\db\models\base.py", line 1250, in
full_clean
raise ValidationError(errors)
django.core.exceptions.ValidationError: {'password': ['This field cannot be
blank.']}

--

This is due to how we defined class DefaultUserFactory:

class DefaultUserFactory(factory.DjangoModelFactory):
first_name = factory.Faker('first_name')
last_name = factory.Faker('last_name')
date_of_birth = factory.fuzzy.FuzzyDate(start_date=date(1900, 1, 1))
gender = User.GENDER_OTHER
slug = factory.fuzzy.FuzzyText(chars=string.ascii_lowercase)
username = factory.LazyAttribute(lambda o:
normalize_username(slug=o.slug))
password = factory.PostGenerationMethodCall(method_name='set_password',
raw_password=USER_PASSWORD)

class Meta:
model = User

Formerly the password defined there was invalid (too short, '111', see
https://github.com/urievenchen/speedy-net/blob/master/speedy/core/accounts/tests/test_factories.py)
and I want all fields to be validated before they are saved to the
database. What is the best method to achieve this?

Thanks,
Uri.


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


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


Re: i want to save is_staff value true in db but not save in database

2018-08-01 Thread mazz ahmed
set is_staff to true to Account model in django model after that save
method will be called

On Wed, Aug 1, 2018 at 1:06 PM, lalitaquasoft 
wrote:

> *Advance Thanks for your help:*
>
>
> *is_staff  value is not save in database*
>
> *Here is Code:*
>
> from django.contrib.auth import login, authenticate
> from django.shortcuts import render, redirect
> from blog.forms import SignUpForm
>
> def signup(request):
> if request.method == 'POST':
> form = SignUpForm(request.POST)
> if form.is_valid():
> form.is_staff = 1
> form.save()
> # username = form.cleaned_data.get('username')
> # raw_password = form.cleaned_data.get('password1')
> # user = authenticate(username=username,
> password=raw_password)
> # login(request, user)
> # return redirect('home')
> else:
> form = SignUpForm()
> return render(request, 'register.html', {'form': form})
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/54a3c692-3232-4032-aadd-561789b92c91%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/CABuXbh-CTnYG%2BGWQXDU9o%3D1VnrNCtCzfksH%2B50M55%3Dw2Rh6Z5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problems Faced with some login requirements. Please read the thread below

2018-08-01 Thread Jason
About the only thing I would do is change your session storage db from your 
regular db to redis or memcached.  That would lower your db load with 
unnecessary session validation and offload it to either, which are built 
for fast key-value retrieval.

Not sure of your user load, but I would be hesitant to add anything to a 
project that can add an additional 150-400 requests/second load to the prod 
db cluster.

-- 
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/fb486838-cb6a-4e8b-8e41-8d5571bf623d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-01 Thread Filbert
Thanks Andrew,
So with a load-balanced ten web server implementation using Channels (and 
of course ten instances of redis) do I have a HA solution then?  RIght now 
Django settings simply has a list of those servers in CHANNEL_LAYERS, what 
if (say) three of them crash, will Channels continue to try and hash to the 
dead servers? Again, I'll accept a brief set of errors, but if this 
effectively causes Channels to continue to error that is not my definition 
of HA.
Thanks.

On Sunday, July 22, 2018 at 8:09:16 PM UTC-4, Andrew Godwin wrote:
>
> I don't think redis-cluster supports BLPOP properly still so I don't think 
> you can use it.
>
> Andrew
>
> On Sun, Jul 22, 2018 at 12:46 PM Filbert > 
> wrote:
>
>> And just to be clear as to my options, using Channels 2.0 I can use Redis 
>> cluster if I have to to get failover and fault tolerance, correct?
>>
>> On Sunday, July 22, 2018 at 12:57:22 PM UTC-4, Andrew Godwin wrote:
>>>
>>> I'm afraid I've never used Twemproxy, so I can't really comment on it, 
>>> but if you don't care about data loss, it's probably fine?
>>>
>>> Andrew
>>>
>>> On Fri, Jul 20, 2018 at 3:30 PM Filbert  wrote:
>>>
 Going to have 10 or more EC2 instances running Channels 2.0.  I really 
 don't want to add the complexity of Redis Cluster or Redis sentinel.  Is a 
 decent fault tolerant solution to implement Twemproxy, instead.  I don't 
 care about data loss if an instance crashes, but I do care that the 
 application continues to operate on the remaining instances.

 Is this a workable 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...@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/d1d50730-c1ba-4674-8ef8-54294158d0f6%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...@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/42fe264e-7f1f-426a-82c6-36aed944a923%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/39acd6c1-73e8-46f9-8f39-035d0054c87c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unable to view chart as a seperate webpage

2018-08-01 Thread Sagar T
*details_page.html : *

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
{% load staticfiles %}



https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";>
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.min.js";>

var randomColorGenerator = function () {
return '#' + (Math.random().toString(16) + '000').slice(2, 
8);
};
var options = {
responsive: true,
maintainAspectRatio: true,
legend: {
position: 'left'
},
title: {
display: true
},
animation: {
animateScale: true,
animateRotate: true
}
};
window.onload = function () {
var ctx = document.getElementById("gender-chart");
{% regroup cl.queryset|dictsort:"gender" by get_gender_display 
as gender_list %}
var lineChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: [{% for gender in gender_list %}'{{ 
gender.grouper }}',{% endfor %}],
datasets: [{
data: [{% for gender in gender_list %}'{{ 
gender.list|length }}',{% endfor %}],
backgroundColor: [{% for gender in gender_list 
%}randomColorGenerator(),{% endfor %}]
}]
},
options: options
});
ctx = document.getElementById("size-chart");
{% regroup cl.queryset|dictsort:"teesize" by 
get_teesize_display as size_list %}
lineChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: [{% for teesize in size_list %}'{{ 
teesize.grouper }}',{% endfor %}],
datasets: [{
data: [{% for teesize in size_list %}'{{ 
teesize.list|length }}',{% endfor %}],
backgroundColor: [{% for teesize in size_list 
%}randomColorGenerator(),{% endfor %}]
}]
}, options: options
});
}


 Charts 


 Graphs 











views.py:

def details(request):

return render(request,"details_chart.html" , { })

models.py:

from django.db import models


GENDER = (
('m', 'MALE'),
('f', 'FEMALE'),
('o', 'OTHER')
)

TEE_SIZE = (
('xs', 'XS'),
('s' , 'S'),
('m' , 'M'),
('l' , 'L'),
('xl', 'XL')
)

class Register(models.Model):

phno = models.CharField(max_length=20)
username = models.CharField(max_length=100, null=True)
emailid = models.EmailField(max_length=50, null=True)
gender = models.CharField(max_length=100, choices=GENDER)
dob = models.DateField(null=True, blank=True)
location = models.CharField(max_length=200,null=True)
teesize = models.CharField(max_length=100, choices=TEE_SIZE)
prevruns = models.IntegerField(null=True, blank=True)
bibno = models.IntegerField(null=True, blank=True)


def __str__(self):
return self.username

def get_data(self):
return self.gender

*Please let me know what changes has to be done in the HTML file to make it 
work.*

-- 
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/bc40919a-6029-4d64-bb98-f0f3bc185880%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django security releases issued: 1.11.15 and 2.0.8

2018-08-01 Thread Tim Graham
Today the Django team issued 1.11.15 and 2.0.8 as part of our security
process. These releases address a security issue, and we encourage all
users to upgrade as soon as possible:

https://www.djangoproject.com/weblog/2018/aug/01/security-releases/

As a reminder, we ask that potential security issues be reported via
private email to secur...@djangoproject.com and not via Django's Trac
instance or the django-developers list. Please see
https://www.djangoproject.com/security for further information.

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


Django 2.1 released

2018-08-01 Thread Tim Graham
Django 2.1 is now available:
https://www.djangoproject.com/weblog/2018/aug/01/django-21-released/

With the release of Django 2.1, Django 2.0 has reached the end of
mainstream support. The final minor bug fix release (which is also a
security release), 2.0.8, was issued today. Django 2.0 will receive
security and data loss fixes until April 2019. All users are
encouraged to upgrade before then to continue receiving fixes for
security issues.

See the downloads page [1] for a table of supported versions and the
future release schedule.

[1] https://www.djangoproject.com/download/#supported-versions

-- 
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/CAD-rxRCuqfm3wks%2BUQKzwOG6nYeQ-U9wuCNerX2ji29zGgwu%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Oracle with Django

2018-08-01 Thread Md. Razibul Hasan Mithu
Is it possible to connect Oracle 11g with Django 1.8? Is there exist any method 
then kindly let me know.

-- 
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/a8007b92-d2af-47ae-bd0b-bc7a773ce6a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Oracle with Django

2018-08-01 Thread Jason
A quick google query 'django oracle` returns a number of recent results and 
tutorials including a link directly to the docs.  What work have you done 
to look into 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/7d0613d0-1bfa-4519-8057-01f86058d979%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


External DB layout, two column as PK, modification not possible

2018-08-01 Thread Kevin Olbrich
Hi!

I got the following table definition on inspect db:

class KevinExample(models.Model):

*code = models.CharField(db_column='Code', primary_key=True, 
max_length=50)  # Field name made lowercase.lineid = 
models.IntegerField(db_column='LineId')  # Field name made lowercase.*
object = models.CharField(db_column='Object', max_length=20, 
blank=True, null=True)  # Field name made lowercase.
loginst = models.IntegerField(db_column='LogInst', blank=True, 
null=True)  # Field name made lowercase.
u_contrattr = models.ForeignKey('KevinExpAttr', models.DO_NOTHING, 
db_column='U_contrattr', max_length=50, blank=True, null=True)  # Field 
name made lowercase.
u_attrlinedata = models.CharField(db_column='U_attrlinedata', 
max_length=50)  # Field name made lowercase.
class Meta:
managed = False
db_table = '@KEVIN_EXAMPLE'
*unique_together = (('code', 'lineid'),)*


Inserting new rows by using the constructor and force_insert works fine but 
refresh_from_db() as well as save() is not possible (duplicate key 
constraint).
Problem is, code + lineid is PK and I have to keep it like this (foreign 
table).

Is there a workaround for this? Is it still impossible to define such PK on 
latest Django?

Kind regards
Kevin

-- 
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/857e15d5-e46b-4f1e-b1f3-e5c24b1f3bd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


CI build failing but local builds pass

2018-08-01 Thread Ajat Prabha
Hi,
I'm working on a hobby project  and 
the issue I'm facing is that the CI build 
 is failing and 
I'm not sure why is this happening.
The only difference is that I updated 
 Django to v2.1 
after the last successful build. However, when I try to make migrations and 
migrate on my local machine, it runs smoothly.

Here's the log:

python3 manage.py migrate
/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/psycopg2/__init__.py:144:
 UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in 
order to keep installing from binary please use "pip install psycopg2-binary" 
instead. For details see: 
.
  """)
Operations to perform:
  Apply all migrations: accounts, admin, auth, contenttypes, courses, sessions, 
social_django, study_material
Running migrations:
  Applying accounts.0001_initial... OK
  Applying courses.0001_initial... OK
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying accounts.0002_auto_20180801_1737... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying sessions.0001_initial... OK
  Applying social_django.0001_initial... OK
  Applying social_django.0002_add_related_name...Traceback (most recent call 
last):
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: syntax error at or near "WITH ORDINALITY"
LINE 6: FROM unnest(c.conkey) WITH ORDINALITY co...
  ^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 381, in execute_from_command_line
utility.execute()
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py",
 line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py",
 line 316, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py",
 line 353, in execute
output = self.handle(*args, **options)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py",
 line 83, in wrapped
res = handle_func(*args, **kwargs)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/commands/migrate.py",
 line 203, in handle
fake_initial=fake_initial,
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py",
 line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
fake_initial=fake_initial)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py",
 line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, 
fake_initial=fake_initial)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py",
 line 244, in apply_migration
state = migration.apply(state, schema_editor)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/migration.py",
 line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, 
project_state)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/operations/fields.py",
 line 216, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/base/schema.py",
 line 523, in alter_field
old_db_params, new_db_params, strict)
  File 
"/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/pos

RE: External DB layout, two column as PK, modification not possible

2018-08-01 Thread Matthew Pava
I did some Google searches for you.
There’s still an open ticket for it, open for the past 12 years:
https://code.djangoproject.com/ticket/373

There’s plenty of people asking the same question.  Here’s one on Stack 
Overflow:
https://stackoverflow.com/questions/16800375/how-can-set-two-field-primary-key-for-my-models-in-django

And it looks like there’s an app for it that hasn’t been updated since 2014:
https://github.com/simone/django-compositekey

In short, though, it looks like you’re doing everything correctly.  You could 
always overwrite the save method and the refresh_from_db method for your use 
case.

If you can change the table at all, I would add an ID column and skip 
specifying the primary_key column in the model.  You could also make a new view 
inside the database that is an interface to the foreign table and write your 
trigger SQL in your database system to handle inserts, updates, and deletes.


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Kevin Olbrich
Sent: Wednesday, August 1, 2018 1:01 PM
To: Django users
Subject: External DB layout, two column as PK, modification not possible

Hi!

I got the following table definition on inspect db:
class KevinExample(models.Model):
code = models.CharField(db_column='Code', primary_key=True, max_length=50)  
# Field name made lowercase.
lineid = models.IntegerField(db_column='LineId')  # Field name made 
lowercase.
object = models.CharField(db_column='Object', max_length=20, blank=True, 
null=True)  # Field name made lowercase.
loginst = models.IntegerField(db_column='LogInst', blank=True, null=True)  
# Field name made lowercase.
u_contrattr = models.ForeignKey('KevinExpAttr', models.DO_NOTHING, 
db_column='U_contrattr', max_length=50, blank=True, null=True)  # Field name 
made lowercase.
u_attrlinedata = models.CharField(db_column='U_attrlinedata', 
max_length=50)  # Field name made lowercase.
class Meta:
managed = False
db_table = '@KEVIN_EXAMPLE'
unique_together = (('code', 'lineid'),)

Inserting new rows by using the constructor and force_insert works fine but 
refresh_from_db() as well as save() is not possible (duplicate key constraint).
Problem is, code + lineid is PK and I have to keep it like this (foreign table).

Is there a workaround for this? Is it still impossible to define such PK on 
latest Django?

Kind regards
Kevin
--
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/857e15d5-e46b-4f1e-b1f3-e5c24b1f3bd8%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/368d673d8b234735b47c03ab7356b834%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: CI build failing but local builds pass

2018-08-01 Thread Ajat Prabha
The issue is fixed now, it happened because Travis used PostgreSQL v9.2 by 
default and Django v2.1 works with v9.4+ (changelog 

)

On Wednesday, 1 August 2018 23:47:16 UTC+5:30, Ajat Prabha wrote:
>
> Hi,
> I'm working on a hobby project  
> and the issue I'm facing is that the CI build 
>  is failing 
> and I'm not sure why is this happening.
> The only difference is that I updated 
>  Django to v2.1 
> after the last successful build. However, when I try to make migrations and 
> migrate on my local machine, it runs smoothly.
>
> Here's the log:
>
> python3 manage.py migrate
> /home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/psycopg2/__init__.py:144:
>  UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in 
> order to keep installing from binary please use "pip install psycopg2-binary" 
> instead. For details see: 
> .
>   """)
> Operations to perform:
>   Apply all migrations: accounts, admin, auth, contenttypes, courses, 
> sessions, social_django, study_material
> Running migrations:
>   Applying accounts.0001_initial... OK
>   Applying courses.0001_initial... OK
>   Applying contenttypes.0001_initial... OK
>   Applying auth.0001_initial... OK
>   Applying accounts.0002_auto_20180801_1737... OK
>   Applying admin.0001_initial... OK
>   Applying admin.0002_logentry_remove_auto_add... OK
>   Applying admin.0003_logentry_add_action_flag_choices... OK
>   Applying contenttypes.0002_remove_content_type_name... OK
>   Applying auth.0002_alter_permission_name_max_length... OK
>   Applying auth.0003_alter_user_email_max_length... OK
>   Applying auth.0004_alter_user_username_opts... OK
>   Applying auth.0005_alter_user_last_login_null... OK
>   Applying auth.0006_require_contenttypes_0002... OK
>   Applying auth.0007_alter_validators_add_error_messages... OK
>   Applying auth.0008_alter_user_username_max_length... OK
>   Applying auth.0009_alter_user_last_name_max_length... OK
>   Applying sessions.0001_initial... OK
>   Applying social_django.0001_initial... OK
>   Applying social_django.0002_add_related_name...Traceback (most recent call 
> last):
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py",
>  line 85, in _execute
> return self.cursor.execute(sql, params)
> psycopg2.ProgrammingError: syntax error at or near "WITH ORDINALITY"
> LINE 6: FROM unnest(c.conkey) WITH ORDINALITY co...
>   ^
> The above exception was the direct cause of the following exception:
> Traceback (most recent call last):
>   File "manage.py", line 15, in 
> execute_from_command_line(sys.argv)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py",
>  line 381, in execute_from_command_line
> utility.execute()
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py",
>  line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py",
>  line 316, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py",
>  line 353, in execute
> output = self.handle(*args, **options)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py",
>  line 83, in wrapped
> res = handle_func(*args, **kwargs)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/commands/migrate.py",
>  line 203, in handle
> fake_initial=fake_initial,
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py",
>  line 117, in migrate
> state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
> fake_initial=fake_initial)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py",
>  line 147, in _migrate_all_forwards
> state = self.apply_migration(state, migration, fake=fake, 
> fake_initial=fake_initial)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py",
>  line 244, in apply_migration
> state = migration.apply(state, schema_editor)
>   File 
> "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/migration.py",
>  line 124, in apply
> operation.database_forwards(self.app_label, schema_editor, old_state, 
> project_state)
> 

Need to query a resultset from database in Django using a form

2018-08-01 Thread ryerekar


I have a form which is editing a database entry and saving the changes back 
to the database. after the changes are saved, I want to redirect to a 
contract.html, where I want to populate the details of that entry. below is 
the view: *def edit_res(request, pk=None):

if request.method == 'POST':
resident_form = EditItemForm(request.POST)
if resident_form.is_valid():
key = int(request.POST['id'])
resident = Resident.objects.get(pk=key)
resident_form = EditItemForm(request.POST, instance=resident)
resident_form.save()
#form = EditItemForm(request.POST, instance=key)
#resident = get_object_or_404(Resident, pk=key)
#form = EditItemForm(request.POST, instance=key)
#if form.is_valid():
#form.save()
#return HttpResponse('Saved form')
return redirect('Contract')
else:
item = Resident.objects.get(pk=pk)
form = EditItemForm(instance=item)
args = {}
args.update(csrf(request))
args['form'] = form
args['id'] = pk
return render_to_response('reg_form/edit.html', args)*

currently after the edited entry is saved, I redirected it to the 
Contract.html page. I am trying to write a function, which can be called 
above to return the data from the database: *def res(request,in_res_id): 
data=Resident.objects.get(res_id=in_res_id) return 
TemplateResponse(request,'Contract.html',{'data':data})*

My contract.html is like, where I want to populate the column value for 
res_fname : *This skilled nursing facility Admission Agreement is entered 
into between Located at and _{{data.res_fname}} (hereinafter “Resident”) *

Please advise. 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3d6a5d22-30f2-4081-9438-8bbeaf4fbad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Aa

2018-08-01 Thread Luca Subiaco


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


Re: Oracle with Django

2018-08-01 Thread Md. Razibul Hasan Mithu
I didn't find any way to connect oracle 11g with django. It still gives me
error

On Wed, Aug 1, 2018, 9:52 PM Jason  wrote:

> A quick google query 'django oracle` returns a number of recent results
> and tutorials including a link directly to the docs.  What work have you
> done to look into 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/7d0613d0-1bfa-4519-8057-01f86058d979%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/CACa3qXWH3DzNoZH_FmsXxx5ZhHGBv-q_VEjm21XmqNTQNcPc9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Oracle with Django

2018-08-01 Thread Tim Graham
What's the error? Did you read the Oracle notes? 
https://docs.djangoproject.com/en/stable/ref/databases/#oracle-notes

On Wednesday, August 1, 2018 at 4:04:53 PM UTC-4, Md. Razibul Hasan Mithu 
wrote:
>
> I didn't find any way to connect oracle 11g with django. It still gives me 
> error  
>
> On Wed, Aug 1, 2018, 9:52 PM Jason > 
> wrote:
>
>> A quick google query 'django oracle` returns a number of recent results 
>> and tutorials including a link directly to the docs.  What work have you 
>> done to look into 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...@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/7d0613d0-1bfa-4519-8057-01f86058d979%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/51a591a9-cf22-4607-94b0-f1f1baa6f446%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-01 Thread Filbert
Well in digging through posts I see Sentinel may be an option, does that 
mean if my CHANNEL_LAYER would have a single host entry?

On Wednesday, August 1, 2018 at 9:42:39 AM UTC-4, Filbert wrote:
>
> Thanks Andrew,
> So with a load-balanced ten web server implementation using Channels (and 
> of course ten instances of redis) do I have a HA solution then?  RIght now 
> Django settings simply has a list of those servers in CHANNEL_LAYERS, what 
> if (say) three of them crash, will Channels continue to try and hash to the 
> dead servers? Again, I'll accept a brief set of errors, but if this 
> effectively causes Channels to continue to error that is not my definition 
> of HA.
> Thanks.
>
> On Sunday, July 22, 2018 at 8:09:16 PM UTC-4, Andrew Godwin wrote:
>>
>> I don't think redis-cluster supports BLPOP properly still so I don't 
>> think you can use it.
>>
>> Andrew
>>
>> On Sun, Jul 22, 2018 at 12:46 PM Filbert  wrote:
>>
>>> And just to be clear as to my options, using Channels 2.0 I can use 
>>> Redis cluster if I have to to get failover and fault tolerance, correct?
>>>
>>> On Sunday, July 22, 2018 at 12:57:22 PM UTC-4, Andrew Godwin wrote:

 I'm afraid I've never used Twemproxy, so I can't really comment on it, 
 but if you don't care about data loss, it's probably fine?

 Andrew

 On Fri, Jul 20, 2018 at 3:30 PM Filbert  wrote:

> Going to have 10 or more EC2 instances running Channels 2.0.  I really 
> don't want to add the complexity of Redis Cluster or Redis sentinel.  Is 
> a 
> decent fault tolerant solution to implement Twemproxy, instead.  I don't 
> care about data loss if an instance crashes, but I do care that the 
> application continues to operate on the remaining instances.
>
> Is this a workable 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...@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/d1d50730-c1ba-4674-8ef8-54294158d0f6%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...@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/42fe264e-7f1f-426a-82c6-36aed944a923%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/ae01076f-732c-4574-b878-ccfd7d9ff20d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Autocompletelight 3.3.0 Forward Problem

2018-08-01 Thread umarcja
Hi,

I'm currently learning Django and I've tried the autocomplete-light 
framework base on Select2.

The problem i'm facing is that I want to Forward input field information to 
filter another input field.

There is a lot of information about that on the internet and on the 
autocomplete-light tutorial but, every example that I've seen use the same 
url address to make there Foward. I was wondering if it was possible to 
Forward it to another address ?

I can change the url adress but it make my first input field return element 
of the second.

In the code below, want I want is to filter codePostalResidence base on the 
selected villeMunicipaliteResidence value.

I want the form to filter base on the link "cmunic = munic_id"

I know that's a lot of information, but if someone can give me a hint about 
anything it would really help me.

Thanks!

#forms.py

class ODData2018Form(forms.ModelForm):

villeMunicipaliteResidence = forms.ModelChoiceField(label='Ville / 
Municipalité : ', required=False,
queryset=TbMunicsV01.objects.all(),
widget=autocomplete.ModelSelect2(url='municipalite2001', 
attrs={'data-placeholder': 'Ville / Municipalité', 'data-html': True, 
'style':'width:100%'}, forward=['villeMunicipaliteResidence'])

codePostalResidence = forms.ModelChoiceField(label='Code postal : ', 
required=False,
queryset=TbCpV01.objects.all(),
widget=autocomplete.ModelSelect2(url='codepostal',
attrs={
'data-placeholder': 'Code postal',
},)
)
)

#views.py

class CodePostal(autocomplete.Select2QuerySetView):
def get_queryset(self):
# Don't forget to filter out results depending on the visitor !
#if not self.request.user.is_authenticated:
#return Choice.objects.none()

qs = TbCpV01.objects.all()

villeMunicipaliteResidence = 
self.forwarded.get('villeMunicipaliteResidence', None)
print(str(villeMunicipaliteResidence))
if villeMunicipaliteResidence:
qs = qs.filter(cmunic=villeMunicipaliteResidence)

if self.q:
qs = qs.filter(cp__istartswith=self.q)

return qs

class Municipalite2001(autocomplete.Select2QuerySetView):
def get_queryset(self):
# Don't forget to filter out results depending on the visitor !
#if not self.request.user.is_authenticated:
#return TbMun2001HV01.objects.none()

qs = TbMun2001HV01.objects.all()

if self.q:
qs = qs.filter(nom_mun__istartswith=self.q)

return qs

#models.py

class TbCpV01(models.Model):
cp_idu = models.IntegerField(blank=True, null=True)
cp = models.TextField(blank=True, null=True)
pr = models.IntegerField(blank=True, null=True)
prabv = models.TextField(blank=True, null=True)
sdr2016c = models.TextField(blank=True, null=True)
cmunic = models.IntegerField(blank=True, null=True)
drsdr2016c = models.TextField(blank=True, null=True)
inod18mtl4 = models.IntegerField(blank=True, null=True)
inod18mtl = models.IntegerField(blank=True, null=True)
xll83 = models.FloatField(blank=True, null=True)
yll83 = models.FloatField(blank=True, null=True)
xmtm83z8 = models.FloatField(blank=True, null=True)
ymtm83z8 = models.FloatField(blank=True, null=True)
visible = models.IntegerField(blank=True, null=True)

def __str__(self):
return self.cp

class TbMun2001HV01(models.Model):
munic_id = models.IntegerField(blank=True, null=True)
sdr2001h = models.TextField(blank=True, null=True)
drsdr2001h = models.TextField(blank=True, null=True)
nom_mun = models.TextField(blank=True, null=True)
desg_mun_a = models.TextField(blank=True, null=True)
desg_mun = models.TextField(blank=True, null=True)
drsdr2016c = models.TextField(blank=True, null=True)

def __str__(self):
return self.nom_mun

-- 
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/4674f877-530b-451b-8d5b-10d9412a7cc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: i want to save is_staff value true in db but not save in database

2018-08-01 Thread Lalit Kumar
Thanks Sir for your guidance , but i have many option is_staff  , is_user ,
i have to save it from view views , any other way to save it from views

On Tue, Jul 31, 2018 at 9:41 PM, mazz ahmed  wrote:

> set is_staff to true to Account model in django model after that save
> method will be called
>
> On Wed, Aug 1, 2018 at 1:06 PM, lalitaquasoft 
> wrote:
>
>> *Advance Thanks for your help:*
>>
>>
>> *is_staff  value is not save in database*
>>
>> *Here is Code:*
>>
>> from django.contrib.auth import login, authenticate
>> from django.shortcuts import render, redirect
>> from blog.forms import SignUpForm
>>
>> def signup(request):
>> if request.method == 'POST':
>> form = SignUpForm(request.POST)
>> if form.is_valid():
>> form.is_staff = 1
>> form.save()
>> # username = form.cleaned_data.get('username')
>> # raw_password = form.cleaned_data.get('password1')
>> # user = authenticate(username=username,
>> password=raw_password)
>> # login(request, user)
>> # return redirect('home')
>> else:
>> form = SignUpForm()
>> return render(request, 'register.html', {'form': form})
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/54a3c692-3232-4032-aadd-561789b92c91%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/CABuXbh-CTnYG%2BGWQXDU9o%3D1VnrNCtCzfksH%2B50M55%
> 3Dw2Rh6Z5g%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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