Re: reg: How to use Django Password validation in my existing views?

2019-02-05 Thread Mike Dewhirst

On 6/02/2019 5:15 pm, 'Amitesh Sahay' via Django users wrote:


I have an existing django views.py where I have some password, 
username, and email validation logic applied. However, going forward I 
need to apply more advanced password validation. for e.g. password 
length limitation, uppercase sensitivity etc. I have a code written 
for advanced validation, but I am not able to apply them to my 
existing views.py.




You appear to be avoiding Django forms. Conventional wisdom says the 
best reason for using forms is to employ the built-in validation like 
this ...


from django.contrib.auth.forms import UserCreationForm

class MyUserCreationForm(UserCreationForm):
    """
https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#
    custom-users-and-the-built-in-auth-forms
    """
    first_name = forms.CharField(
    max_length=30,
    required=True,
    help_text='Required',
    )
    last_name = forms.CharField(
    max_length=30,
    required=True,
    help_text='Required'
    )
    username = forms.CharField(
    max_length=150,
    required=True,
    help_text='Required. Letters, digits and @/./+/-/_ only',
    )
    email = forms.EmailField(
    max_length=254,
    required=True,
    help_text='Required'
    )
    class Meta(UserCreationForm.Meta):
    model = User
    fields = [
    'first_name',
    'last_name',
    'username',
    'password1',
    'password2',
    'email',
    ]

    def __init__(self, *args, **kwargs):
    super(CommonUserCreationForm, self).__init__(*args, **kwargs)
    if 'first_name' in self.fields:
self.fields['first_name'].widget.attrs.update({'autofocus': True})


If you do that you can simplify your register_view() like this ...


from django.contrib.auth import get_user_model
from .forms import CommonUserCreationForm

def register_view(request):
    if request.method == 'POST':
    form = MyUserCreationForm(request.POST)

        # don't like usernames which differ only by character case
        #
    username = form.data.get('username')
    User = get_user_model()
    try:
    user = User.objects.get(username__iexact=username)
    i_username = user.username
    if i_username.lower() == username.lower():
    form.add_error(
    'username',
    ValidationError('{0} already 
exists'.format(i_username))

    )
    except User.DoesNotExist:
            # DoesNotExist is the expected case
    pass
    #

    if form.is_valid():
    form.save()
    user = User.objects.get(username__iexact=username)
    user.username = form.cleaned_data.get('username')
    user.first_name = form.cleaned_data.get('first_name')
    user.last_name = form.cleaned_data.get('last_name')
    user.email = form.cleaned_data.get('email')
    user.save()
    raw_password = form.cleaned_data.get('password1')
    user = authenticate(username=username, password=raw_password)
    auth_login(request, user)
    return redirect('myapp:index_view')
    else:
    form = MyUserCreationForm()
    return render(request, 'register.html', {'form': form})


And finally to answer your original question if you do something similar 
to the above you can add password validators *to be used in the form* in 
your settings module. Like this ...



# 
https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators


AUTH_PASSWORD_VALIDATORS = [
    {
    'NAME': 
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',

    },
    {
    'NAME': 
'django.contrib.auth.password_validation.MinimumLengthValidator',

    'OPTIONS': {
    'error_message': 'Password too short',
    'help_message': 'This password needs to be at least 23 
characters',

    }
    },
    {
    'NAME': 
'django.contrib.auth.password_validation.CommonPasswordValidator',

    },
    {
    'NAME': 
'django.contrib.auth.password_validation.NumericPasswordValidator',

    },
    {
    'NAME': 
'pwned_passwords_django.validators.PwnedPasswordsValidator',

    'OPTIONS': {
    'error_message': 'Known insecure password',
    'help_message': 'That is a known insecure password and 
cannot be used here.',

    }
    },
]

Hope that helps

Mike



Below is the code from views.py

|fromdjango.shortcuts ||importrender,redirect|
|fromdjango.contrib.auth.models ||importUser|
|fromdjango.contrib ||importmessages|
|from.importvalidator|
|defregister(request):|
|ifrequest.method =='POST'||:|
|first_name =request.POST[||'first_name'||]|
|last_name =request.POST[||'last_name'||]|
|email =request.POST[||'email'||]|
|username =request.POST[||'username'||]|
|password 

Re: reg: How to use Django Password validation in my existing views?

2019-02-05 Thread 'Amitesh Sahay' via Django users
Anyway, I have found the answer to my own question. Below is the modified 
views.py code.
def register(request):
validators = [MinimumLengthValidator, NumberValidator, UppercaseValidator]
if request.method == 'POST':
   # some code
   password = request.POST('password')
   try:
   for validator in validators:
validator().validate(password)
   except ValidationError as e:
   messages.error(request, str(e))
   return redirect('register')



Regards,
Amitesh Sahay91-750 797 8619 

On Wednesday, 6 February, 2019, 11:48:21 am IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
  
I have an existing django views.py where I have some password, username, and 
email validation logic applied. However, going forward I need to apply more 
advanced password validation. for e.g. password length limitation, uppercase 
sensitivity etc. I have a code written for advanced validation, but I am not 
able to apply them to my existing views.py. Below is the code from views.py
from django.shortcuts import render, redirect
from django.contrib.auth.models import User
from django.contrib import messages
from . import validator
def register(request):
if request.method == 'POST':
first_name = request.POST['first_name']
last_name = request.POST['last_name']
email = request.POST['email']
username = request.POST['username']
password = request.POST['password', validator.MinimumLengthValidator]
password2 = request.POST['password2']

# check if the password match
if password == password2:

if User.objects.filter(username=username).exists():
messages.error(request, 'username already exist')
return redirect('register')
else:
if User.objects.filter(email=email).exists():
messages.error(request, 'Registration Failed - Try 
different email address')
return redirect('register')
else:
user = User.objects.create_user(username=username, 
password=password, email=email,
first_name=first_name, 
last_name=last_name)
user.save()
messages.success(request, 'Registration complete, please 
proceed to login')
return redirect('register')
else:
messages.error(request, 'password dose not match')
return redirect('register')
else:
return render(request, 'ACCOUNTS/register.html')
Below is the code for advanced password validation from validate.py
import re
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _

class MinimumLengthValidator:
def __init__(self, min_length=8):
self.min_length = min_length

def validate(self, password, user=None):
if len(password) < self.min_length:
raise ValidationError(
_("This password must contain at least %(min_length)d 
characters."),
code='password_too_short',
params={'min_length': self.min_length},
)

def get_help_text(self):
return _(
"Your password must contain at least %(self.min_length)d 
characters."
% {'min_length': self.min_length}
)


class NumberValidator(object):
def validate(self, password, user=None):
if not re.findall('\d', password):
raise ValidationError(
_("The password must contain at least %(min_digits)d digit(s), 
0-9."),
code='password_no_number',
)

def get_help_text(self):
return _(
"Your password must contain at least 1 digit, 0-9."
)


class UppercaseValidator(object):
def validate(self, password, user=None):
if not re.findall('[A-Z]', password):
raise ValidationError(
_("The password must contain at least 1 uppercase letter, 
A-Z."),
code='password_no_upper',
)

def get_help_text(self):
return _(
"Your password must contain at least 1 uppercase letter, A-Z."
)
I have tried below steps.
I imported the validator.py in the views.py,and tried to call the 
module.function inside the password field as below

password = request.POST['password', validator.MinimumLengthValidator]
But that doesn't work. If I am right, I can write a mixin class and call it in 
my views.py. But I am using function based views. So, I am not sure if I can 
use mixin. Please suggest how can we achieve the desired result.

Regards,

Amitesh Sahay91-750 797 8619

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

Re: Webinterface for python script

2019-02-05 Thread Scot Hacker
If I were just starting out, and needed to learn how to handle uploaded 
files, google would take me to these two docs:

http://flask.pocoo.org/docs/1.0/patterns/fileuploads/
https://docs.djangoproject.com/en/2.1/topics/http/file-uploads/

Maybe I'm crazy or my perspective is skewed, but I think I would find the 
Django instructions easier to follow, and I would have my solution faster.  
In other words, I don't buy the "Flask is easier to get started with" 
argument (OK maybe for a few very primitive use cases). 

So... 

"Flask is lightweight." What does that mean? It starts up in 1 second 
rather than 2 seconds? Why would that be important to me? 

"Flask is easier to learn." Definitely not, as far as I can see. Because 
Django includes everything you need for common use cases, the path to 
success is almost always easier with Django. 

If I were teaching a class of people new to programming, I would choose 
Django over Flask for its ease of use. And as a developer, there's no web 
project so small that I would choose Flask over Django - just not worth the 
additional time investment and hassle that Flask requires. 

My .02 anyway.

./s


On Tuesday, February 5, 2019 at 5:26:34 AM UTC-8, Derek wrote:
>
> Hi Eric
>
> Of course I also think Django is great ... but I have never seen anyone 
> refer to it as a "lightweight" project (before you, that is).
>
> My use of the word "overkill" was in the context of what how the OP 
> described his need.  If he said he wanted to upload data from a spreadsheet 
> and store in a DB, then I would offered advice how to do that with Django.
>
> But its a mistake to think that "Python" + "data processing" automatically 
> equals Django.
>
> My 2c
> Derek
>
>
> On Tuesday, 5 February 2019 11:04:45 UTC+2, Eric Pascual wrote:
>>
>> Hi,
>>
>> I never know what people mean by "Django is overkill for...". Django is 
>> lightweight and starts up very quickly
>>
>> You're right WRT the Django technical part. 
>>
>> My feeling is that people implicitly refer to the learning curve, because 
>> it's the visible part. Django is a very capable framework with batteries 
>> included, but its documentation is largely ORM-centric* (which is 
>> logical because of its  motivations) *in addition to being quite 
>> voluminous *(which is a good point, since it covers every tiny bit of  
>> the beast)*. This can be intimidating when people are looking for 
>> something very basic which does not require the ORM. 
>>
>> I was among these people until my experience and skills in Django reached 
>> the level where I became aware that it can be stripped down to a very basic 
>> an lightweight framework if needed, thanks to its modular approach. But 
>> this came with time 
>>
>> Best
>>
>> Eric
>> --
>> *From:* django...@googlegroups.com  on 
>> behalf of Scot Hacker 
>> *Sent:* Tuesday, February 5, 2019 08:54
>> *To:* Django users
>> *Subject:* Re: Webinterface for python script 
>>  
>> Make a basic Django view. Place your script in a python module that lives 
>> inside your app. Call that module/ function from the Django view. See 
>> Django docs and tutorials on how to handle uploaded files. Pass the 
>> uploaded file to your module, and handle the return value(s) however you 
>> want. Hard to get more specific than that without seeing your code, but 
>> this should come together pretty quickly with some experimentation.
>>
>> I never know what people mean by "Django is overkill for...". Django is 
>> lightweight and starts up very quickly, even with large/complex projects. 
>> Django saves you mountains of time compared to Flask, which makes you go 
>> shopping for every little piece of framework you need. Every time I've 
>> experimented with Flask, I've come running back to Django after realizing 
>> my time is too valuable to waste it on creating my own framework when a 
>> perfectly great one already exists. 
>>
>> ./s 
>>
>>
>> On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote: 
>>
>> Hi All , 
>>
>>   I have created certain python scripts to analyze log files and 
>> suggest solution based on logic which I invoke on the command line . I need 
>> some information on how to execute these through browser . I am using :
>>
>> python test.py file1 file2 
>>
>> How do I use the browser to upload the files file1 and file2 and it 
>> process the files .
>>
>> Please advice ,
>>
>> 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...@googlegroups.com.
>> To post to this group, send email to djang...@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/88c2337b-7e8a-4e11-968f-30299b6229d4%40googlegroups.com
>>  
>> 

Social media apps in Django

2019-02-05 Thread senthu nithy
I wish to develop a social media like facebook using Django. Is there are
any documents to develop this kind of social media development
K.Senthuja
Undergraduate Student (UOJ),
https://www.linkedin.com/in/senthuja/
https://medium.com/@senthujakarunanithy

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


Re: columns were not added/created to my database table (postgresql) after makemigrations/migrate

2019-02-05 Thread Atsunori Kaneshige
Hi Nitin,

Thank you for your comment.
I did not add any additional class in models.py.
I just added two fields under the same class, List.

class List(models.Model):
item = models.CharField(max_length=200)
completed = models.BooleanField(default=False)
*created_at = models.DateTimeField('date', auto_now_add=True, null = 
True)  *
* updated_at = models.DateTimeField('update', auto_now=True, null = True)  *

In admin.py, I did not change anything.

#this is my admin.py
from django.contrib import admin
from .models import List
# Register your models here. then go to admin page and re-load
admin.site.register(List)

Why new columns (or in other words, new fields) do not show up in my admin 
site? Even though I did makemigrations/migrate.


Thank you for your help!

Nori



On Tuesday, February 5, 2019 at 9:58:30 PM UTC-5, Nitin Kalmaste wrote:
>
> You need to add python's magic method in order to return something from 
> the models you have created. Also you have to register your models to 
> admin.py file. You can refer Django documents for that.
>
> On Wed, Feb 6, 2019, 8:03 AM Atsunori Kaneshige   wrote:
>
>> Hi, Django masters!
>>
>> My app has simple models.py
>> just two fields like below.
>>
>> #models.py
>> class List(models.Model):
>> item = models.CharField(max_length=200)
>> completed = models.BooleanField(default=False)
>>
>> #migration 0001
>> class Migration(migrations.Migration):
>>
>> initial = True
>>
>> dependencies = [
>> ]
>>
>> operations = [
>> migrations.CreateModel(
>> name='List',
>> fields=[
>> ('id', models.AutoField(auto_created=True, 
>> primary_key=True, serialize=False, verbose_name='ID')),
>> ('item', models.CharField(max_length=200)),
>> ('completed', models.BooleanField(default=False)),
>> ],
>> ),
>> ]
>>
>> and after makemigrations/migrate, the app was working no problem.
>> *Then, I wanted to try adding two more fields.*
>>
>> #new models.py
>> class List(models.Model):
>> item = models.CharField(max_length=200)
>> completed = models.BooleanField(default=False)
>> *created_at = models.DateTimeField('date', auto_now_add=True, null = 
>> True)  *
>> * updated_at = models.DateTimeField('update', auto_now=True, null = 
>> True)  *
>>
>> #migrations 0002
>> class Migration(migrations.Migration):
>>
>> dependencies = [
>> ('pages', '0001_initial'),
>> ]
>>
>> operations = [
>> migrations.AddField(
>> model_name='list',
>> name='created_at',
>> field=models.DateTimeField(auto_now_add=True, null=True, 
>> verbose_name='date'),
>> ),
>> migrations.AddField(
>> model_name='list',
>> name='updated_at',
>> field=models.DateTimeField(auto_now=True, null=True, 
>> verbose_name='update'),
>> ),
>> ]
>>
>>
>> Django doc says that I need to add '*null = True*' because I am using 
>> postgresql as my database.
>> Without '*null = True*', the program throws an error saying that column 
>> pages_list.created_at doesn't exist etc. when I try to see the web page. 
>> But, with '*null = True*', I successfully did makemigration and migrate, 
>> then web page showed up without any problem.
>>
>> *But, when I go to admin, I could not find any fields that I though I 
>> created.*
>> I also looked at the table in my postgresql, but again, there are only 
>> original columns, but not other two columns.
>>
>> Do you know how to add new columns by changing models.py??
>> What should I take care to successfully modify models and add new columns 
>> in my database table (postgresql in my case).
>>
>> I really appreciate your advice!
>>
>> Looking forward to hearing from you.
>>
>> Nori
>>
>>  
>>
>>
>>
>> -- 
>> 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/a1d71d4c-1500-4972-af57-dc23f5d1ff20%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> On Wed, Feb 6, 2019, 8:03 AM Atsunori Kaneshige   wrote:
>
>> Hi, Django masters!
>>
>> My app has simple models.py
>> just two fields like below.
>>
>> #models.py
>> class List(models.Model):
>> item = models.CharField(max_length=200)
>> completed = models.BooleanField(default=False)
>>
>> #migration 0001
>> class Migration(migrations.Migration):
>>
>> initial = True
>>
>> dependencies = [
>> ]
>>
>> operations = 

Re: columns were not added/created to my database table (postgresql) after makemigrations/migrate

2019-02-05 Thread Nitin Kalmaste
You need to add python's magic method in order to return something from the
models you have created. Also you have to register your models to admin.py
file. You can refer Django documents for that.

On Wed, Feb 6, 2019, 8:03 AM Atsunori Kaneshige  Hi, Django masters!
>
> My app has simple models.py
> just two fields like below.
>
> #models.py
> class List(models.Model):
> item = models.CharField(max_length=200)
> completed = models.BooleanField(default=False)
>
> #migration 0001
> class Migration(migrations.Migration):
>
> initial = True
>
> dependencies = [
> ]
>
> operations = [
> migrations.CreateModel(
> name='List',
> fields=[
> ('id', models.AutoField(auto_created=True,
> primary_key=True, serialize=False, verbose_name='ID')),
> ('item', models.CharField(max_length=200)),
> ('completed', models.BooleanField(default=False)),
> ],
> ),
> ]
>
> and after makemigrations/migrate, the app was working no problem.
> *Then, I wanted to try adding two more fields.*
>
> #new models.py
> class List(models.Model):
> item = models.CharField(max_length=200)
> completed = models.BooleanField(default=False)
> *created_at = models.DateTimeField('date', auto_now_add=True, null =
> True)  *
> * updated_at = models.DateTimeField('update', auto_now=True, null =
> True)  *
>
> #migrations 0002
> class Migration(migrations.Migration):
>
> dependencies = [
> ('pages', '0001_initial'),
> ]
>
> operations = [
> migrations.AddField(
> model_name='list',
> name='created_at',
> field=models.DateTimeField(auto_now_add=True, null=True,
> verbose_name='date'),
> ),
> migrations.AddField(
> model_name='list',
> name='updated_at',
> field=models.DateTimeField(auto_now=True, null=True,
> verbose_name='update'),
> ),
> ]
>
>
> Django doc says that I need to add '*null = True*' because I am using
> postgresql as my database.
> Without '*null = True*', the program throws an error saying that column
> pages_list.created_at doesn't exist etc. when I try to see the web page.
> But, with '*null = True*', I successfully did makemigration and migrate,
> then web page showed up without any problem.
>
> *But, when I go to admin, I could not find any fields that I though I
> created.*
> I also looked at the table in my postgresql, but again, there are only
> original columns, but not other two columns.
>
> Do you know how to add new columns by changing models.py??
> What should I take care to successfully modify models and add new columns
> in my database table (postgresql in my case).
>
> I really appreciate your advice!
>
> Looking forward to hearing from you.
>
> Nori
>
>
>
>
>
> --
> 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/a1d71d4c-1500-4972-af57-dc23f5d1ff20%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

On Wed, Feb 6, 2019, 8:03 AM Atsunori Kaneshige  Hi, Django masters!
>
> My app has simple models.py
> just two fields like below.
>
> #models.py
> class List(models.Model):
> item = models.CharField(max_length=200)
> completed = models.BooleanField(default=False)
>
> #migration 0001
> class Migration(migrations.Migration):
>
> initial = True
>
> dependencies = [
> ]
>
> operations = [
> migrations.CreateModel(
> name='List',
> fields=[
> ('id', models.AutoField(auto_created=True,
> primary_key=True, serialize=False, verbose_name='ID')),
> ('item', models.CharField(max_length=200)),
> ('completed', models.BooleanField(default=False)),
> ],
> ),
> ]
>
> and after makemigrations/migrate, the app was working no problem.
> *Then, I wanted to try adding two more fields.*
>
> #new models.py
> class List(models.Model):
> item = models.CharField(max_length=200)
> completed = models.BooleanField(default=False)
> *created_at = models.DateTimeField('date', auto_now_add=True, null =
> True)  *
> * updated_at = models.DateTimeField('update', auto_now=True, null =
> True)  *
>
> #migrations 0002
> class Migration(migrations.Migration):
>
> dependencies = [
> ('pages', '0001_initial'),
> ]
>
> operations = [
> migrations.AddField(
> model_name='list',
> 

columns were not added/created to my database table (postgresql) after makemigrations/migrate

2019-02-05 Thread Atsunori Kaneshige
Hi, Django masters!

My app has simple models.py
just two fields like below.

#models.py
class List(models.Model):
item = models.CharField(max_length=200)
completed = models.BooleanField(default=False)

#migration 0001
class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='List',
fields=[
('id', models.AutoField(auto_created=True, 
primary_key=True, serialize=False, verbose_name='ID')),
('item', models.CharField(max_length=200)),
('completed', models.BooleanField(default=False)),
],
),
]

and after makemigrations/migrate, the app was working no problem.
*Then, I wanted to try adding two more fields.*

#new models.py
class List(models.Model):
item = models.CharField(max_length=200)
completed = models.BooleanField(default=False)
*created_at = models.DateTimeField('date', auto_now_add=True, null = 
True)  *
* updated_at = models.DateTimeField('update', auto_now=True, null = True)  *

#migrations 0002
class Migration(migrations.Migration):

dependencies = [
('pages', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='list',
name='created_at',
field=models.DateTimeField(auto_now_add=True, null=True, 
verbose_name='date'),
),
migrations.AddField(
model_name='list',
name='updated_at',
field=models.DateTimeField(auto_now=True, null=True, 
verbose_name='update'),
),
]


Django doc says that I need to add '*null = True*' because I am using 
postgresql as my database.
Without '*null = True*', the program throws an error saying that column 
pages_list.created_at doesn't exist etc. when I try to see the web page. 
But, with '*null = True*', I successfully did makemigration and migrate, 
then web page showed up without any problem.

*But, when I go to admin, I could not find any fields that I though I 
created.*
I also looked at the table in my postgresql, but again, there are only 
original columns, but not other two columns.

Do you know how to add new columns by changing models.py??
What should I take care to successfully modify models and add new columns 
in my database table (postgresql in my case).

I really appreciate your advice!

Looking forward to hearing from you.

Nori

 



-- 
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/a1d71d4c-1500-4972-af57-dc23f5d1ff20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: get_expiry_age does not use expire_date column.

2019-02-05 Thread Tim Graham
Hi Shen, I haven't looked into this much but 
https://code.djangoproject.com/ticket/19201 could be related. Feel free to 
offer a patch to improve the situation.

On Monday, February 4, 2019 at 12:59:16 PM UTC-5, Shen Li wrote:
>
> Hi community,
>
> I find it strange that in the DB session backend, the get_expiry_age does 
> not actually use the value from expire_data column in the model.
>
> What is the indention of this design?
>
> 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/0d01157f-987f-4574-b4b5-3e7a782ca078%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: REST Framework alternatives

2019-02-05 Thread Jani Tiainen
Well we're all entitled to our opinions.

DRF is complex but it's not inflexible. You can do pretty much everything
which is REST related.

There are few alternatives, tastypie is mentioned but there exists also
django-nap which is a bit more lightweight than DRF.

On Tue, Feb 5, 2019 at 6:52 PM Victor Porton  wrote:

> My buddy says that REST Framework is complex and inflexible.
>
> So the question: Any other framework which supports validating JSON data?
>
> --
> 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/1880c6a4-56aa-4073-bbe0-0dbf042587a8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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


REST Framework alternatives

2019-02-05 Thread PARTH PATIL
I agree that indeed REST Framework has a decent learning curve, but i would say 
it is worth a shot if you only have to do validation it will handle it like 
magic with very few lines of code.

-- 
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/b8f6b84f-abf0-4122-8d3a-594b31f05aea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Card Update problem e commerce problems

2019-02-05 Thread tercuman4848
Hi guys ım beginer django , ı have e marketing project  ı wanna doing e 
commerce web site my problem ı cnat add to my product card to basket  and ı 
wannt add to basket and removed on basket 
anyone help to me ??  
thxx

-- 
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/5c7429bf-b243-4976-8e2f-cb23c1e0ade9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: REST Framework alternatives

2019-02-05 Thread Sam Taiwo
What validation does he specifically need? He could probably get away with
writing a few helper functions himself!

On Tue, Feb 5, 2019, 17:50 Miguel Ángel Cumpa Ascuña <
miguel.cumpa.asc...@gmail.com wrote:

> Django tastypie
> good luck!
> https://django-tastypie.readthedocs.io/en/latest/toc.html
>
> El mar., 5 feb. 2019 a las 11:52, Victor Porton ()
> escribió:
>
>> My buddy says that REST Framework is complex and inflexible.
>>
>> So the question: Any other framework which supports validating JSON data?
>>
>> --
>> 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/1880c6a4-56aa-4073-bbe0-0dbf042587a8%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/CAOZHYKP9xCYhLqZneVN7A7qiS9tGF40WLyz8aPor5pfMQZ0JJg%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/CAHKA7fC%3D%2BPMR8Teyrne%2B%3Dr0hCxoAf031p6xFNeaSN2BQAPwVYg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can download the offline version of Django Rest Framework

2019-02-05 Thread Nitin Kalmaste
You can install djangorestframework package using pip.
Just read the documents from djangorestframework.com

On Wed, Feb 6, 2019, 12:11 AM  I am not always online but I like to work with the Django Rest Framework.
> How  can I get it offline.
>
> --
> 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/0add5172-0d3e-4f8d-b01a-67b03e17fdae%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/CAKroR%2B0GQrr5unEi5Tm3h_VNVZ7XwdTY3U76kLp7nePSgXoc6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django opening balance calculation

2019-02-05 Thread Nitin Kalmaste
May I know whether you have started instance of the functions opening and
closing or not. You have to call these functions from somewhere to run the
loops

On Tue, Feb 5, 2019, 9:07 PM   Hi everyone.
>
> I have my models that looks like these:
>
> class Item(models.Model):
> name = models.CharField(max_length=30)
> buying_price = models.PositiveIntegerField()
> selling_price = models.PositiveIntegerField()
> quantity = models.PositiveIntegerField()
>
> def __str__(self):
> return self.name
>
> class SalesSheet(models.Model):
> txn_date = models.DateField()
> item = models.ForeignKey(Item, on_delete=models.CASCADE)
> purchases = models.PositiveIntegerField()
> sales = models.PositiveIntegerField()
>
>
>
>
>
>
> What I want after posting purchases and sales is an output like this
>
>
> id  dateitem  opening  purchases sales closing
>  1  1-1-19  abc   10   205 25
>  2  2-12-19 def   25   201035
>  3  3-1-19  abc   25   102510
>  4  4-1-19  def   35   103015
>  5  7-1-19  abc   10   0 0 10
>  6  9-1-19  def   15   0 5 10
>
>
>
> Note that opening and closing fields are not in the model. They need to be
> calculated on the fly or rather dynamically. Also Note that there will be
> back dated entries and the items are different(not just one item)
>
> My big problem is how to write a view function to calculate opening and
> closing balances.
> I tried putting these functions inside my models, but the loop is not
> working
>
> class SalesSheet(models.Model):
> txn_date = models.DateField()
> item = models.ForeignKey(Item, on_delete=models.CASCADE)
> purchases = models.PositiveIntegerField()
> sales = models.PositiveIntegerField()
>
> def opening_balance(self):
> quantity = self.item.quantity
> items = SalesSheet.objects.all()
> for item in items:
> opening = quantity
> closing = opening + self.purchases - self.sales
> quantity = closing
> return opening
>
> def closing_balance(self):
> quantity = self.item.quantity
> items = SalesSheet.objects.all()
> for item in items:
> opening = quantity
> closing = opening + self.purchases - self.sales
> quantity = closing
> return closing
>
>
> My idea here was to loop through the Transaction Model and update the
> opening balance as the loop continues, but unfortunately the loop isn't
> working.
>
> Please if anyone could help write a view function just to display and
> calculate the balances.
>
> 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/858bb8f6-6651-494f-9386-a25e79dad4b0%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/CAKroR%2B1T5YRgoeWaX7hji93xNKDvOh9hPyMZ-%3DTrA%2BmeTEJHGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How can download the offline version of Django Rest Framework

2019-02-05 Thread sunejack1
I am not always online but I like to work with the Django Rest Framework. 
How  can I get it offline.

-- 
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/0add5172-0d3e-4f8d-b01a-67b03e17fdae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: REST Framework alternatives

2019-02-05 Thread Miguel Ángel Cumpa Ascuña
Django tastypie
good luck!
https://django-tastypie.readthedocs.io/en/latest/toc.html

El mar., 5 feb. 2019 a las 11:52, Victor Porton ()
escribió:

> My buddy says that REST Framework is complex and inflexible.
>
> So the question: Any other framework which supports validating JSON data?
>
> --
> 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/1880c6a4-56aa-4073-bbe0-0dbf042587a8%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/CAOZHYKP9xCYhLqZneVN7A7qiS9tGF40WLyz8aPor5pfMQZ0JJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


REST Framework alternatives

2019-02-05 Thread Victor Porton
My buddy says that REST Framework is complex and inflexible.

So the question: Any other framework which supports validating JSON data? 

-- 
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/1880c6a4-56aa-4073-bbe0-0dbf042587a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django opening balance calculation

2019-02-05 Thread mintuser701
 Hi everyone.

I have my models that looks like these:

class Item(models.Model):
name = models.CharField(max_length=30)
buying_price = models.PositiveIntegerField()
selling_price = models.PositiveIntegerField()
quantity = models.PositiveIntegerField()

def __str__(self):
return self.name

class SalesSheet(models.Model):
txn_date = models.DateField()
item = models.ForeignKey(Item, on_delete=models.CASCADE)
purchases = models.PositiveIntegerField()
sales = models.PositiveIntegerField()






What I want after posting purchases and sales is an output like this


id  dateitem  opening  purchases sales closing
 1  1-1-19  abc   10   205 25
 2  2-12-19 def   25   201035
 3  3-1-19  abc   25   102510
 4  4-1-19  def   35   103015
 5  7-1-19  abc   10   0 0 10
 6  9-1-19  def   15   0 5 10



Note that opening and closing fields are not in the model. They need to be 
calculated on the fly or rather dynamically. Also Note that there will be 
back dated entries and the items are different(not just one item)

My big problem is how to write a view function to calculate opening and 
closing balances.
I tried putting these functions inside my models, but the loop is not 
working

class SalesSheet(models.Model):
txn_date = models.DateField()
item = models.ForeignKey(Item, on_delete=models.CASCADE)
purchases = models.PositiveIntegerField()
sales = models.PositiveIntegerField()

def opening_balance(self):
quantity = self.item.quantity
items = SalesSheet.objects.all()
for item in items:
opening = quantity
closing = opening + self.purchases - self.sales 
quantity = closing
return opening

def closing_balance(self):
quantity = self.item.quantity
items = SalesSheet.objects.all()
for item in items:
opening = quantity
closing = opening + self.purchases - self.sales 
quantity = closing
return closing


My idea here was to loop through the Transaction Model and update the 
opening balance as the loop continues, but unfortunately the loop isn't 
working.

Please if anyone could help write a view function just to display and 
calculate the balances.

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/858bb8f6-6651-494f-9386-a25e79dad4b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Opening Balance Calculations

2019-02-05 Thread mintuser701
 


I am trying to create a simple inventory app using Django. My project
 came to a stand still when I couldn't find a solution for calculating 
opening and closing balances on the fly/dynamically. I tried for days 
researching on the web but no progress yet. If anyone could help i will 
appreciate.


All I need is a query to calculate opening and closing balances dynamically.


My Models:


class Item(models.Model):
name = models.CharField(max_length=30)
buying_price = models.PositiveIntegerField()
selling_price = models.PositiveIntegerField()
quantity = models.PositiveIntegerField()

def __str__(self):
return self.name

class SalesSheet(models.Model):
txn_date = models.DateField()
item = models.ForeignKey(Item, on_delete=models.CASCADE)
purchases = models.PositiveIntegerField()
sales = models.PositiveIntegerField()



What I want after posting purchases and sales is an output like this


id  dateitem  opening  purchases sales closing
 1  1-1-19  abc   10   205 25
 2  2-12-19 def   25   201035
 3  3-1-19  abc   25   102510
 4  4-1-19  def   35   103015
 5  7-1-19  abc   10   0 0 10
 6  9-1-19  def   15   0 5 10



and so on.


I am using item.quantity to store opening stock for the first time only.


Take into consideration that there will be different items and also back 
dated entries.


help me guys.


I tried adding these functions to my models and use them to display 
opening(opening_balance) and closing (closing_balance) balances. But the
 problem is that the loop is not working.


the idea was that if the loop worked then the opening stock will be updated 
by the new closing stock each time the loop runs.


class SalesSheet(models.Model):
txn_date = models.DateField()
item = models.ForeignKey(Item, on_delete=models.CASCADE)
purchases = models.PositiveIntegerField()
sales = models.PositiveIntegerField()

def opening_balance(self):
quantity = self.item.quantity
items = SalesSheet.objects.all()
for item in items:
opening = quantity
closing = opening + self.purchases - self.sales 
quantity = closing
return opening

def closing_balance(self):
quantity = self.item.quantity
items = SalesSheet.objects.all()
for item in items:
opening = quantity
closing = opening + self.purchases - self.sales 
quantity = closing
return closing




-- 
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/6f098e76-4523-4020-b4b7-034fe284da28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TemplateDoesNotExist at /vmail/inbox/

2019-02-05 Thread senthu nithy
Get i,Thank you!
K.Senthuja
Undergraduate Student (UOJ),
https://www.linkedin.com/in/senthuja/
https://medium.com/@senthujakarunanithy


On Tue, Feb 5, 2019 at 8:53 AM Alex Kimeu  wrote:

> It means the template you are trying to render is either not created or
> not in the location where Django expects to be. Django does not see the
> template you are trying to render.
>
> On Tue, 5 Feb 2019, 04:28 senthu nithy 
>> I am doing a project using Django. I got this error. I don't understand
>> what this error really means.
>> Thanks in advance!
>> K.Senthuja
>> Undergraduate Student (UOJ),
>> https://www.linkedin.com/in/senthuja/
>> https://medium.com/@senthujakarunanithy
>>
>> --
>> 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/CALEaTU5PQaiOuekpgJS7B6gQkZeQEz-x8--RMmLvC9mjJDnFNw%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/CACYP3VHVfVCm7LHqt7x6bNN78%2BwjXnVaC4YQEzaXxQygwz1HFg%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/CALEaTU57SpT6561P5obA%2BnOr5_6cRKNFXsP_CuAHesXotppFbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Projects in django

2019-02-05 Thread B.navya spoorthi Sweety
hi
even i am looking for the same...
plz help

On Tue, Feb 5, 2019 at 5:47 PM  wrote:

> Hi Nitin,
>
> I am struggling to connect Django with MongoDB.
>
> Could you please help me to set up a workspace with this combo.
>
> it helps a lot to me.
>
> Thanks,
> Srinivas,
> thammanen...@gmail.com
>
>
>
> On Wednesday, January 16, 2019 at 1:31:01 PM UTC+5:30, Nitin Kumar wrote:
>>
>> Hi,
>>
>> I have an year of experience working in python and django.
>> I am looking for some projects in django for remote work.
>>
>> Regards,
>> Nitin Kumar
>>
> --
> 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/73caa425-7809-4cba-90ff-7ec07881ffbf%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/CAOdZuzxPB2MRts17PqThpCmkMnW3bsPD1Dq3SM3Qc1CT1iS5PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Webinterface for python script

2019-02-05 Thread Derek
Hi Eric

Of course I also think Django is great ... but I have never seen anyone 
refer to it as a "lightweight" project (before you, that is).

My use of the word "overkill" was in the context of what how the OP 
described his need.  If he said he wanted to upload data from a spreadsheet 
and store in a DB, then I would offered advice how to do that with Django.

But its a mistake to think that "Python" + "data processing" automatically 
equals Django.

My 2c
Derek


On Tuesday, 5 February 2019 11:04:45 UTC+2, Eric Pascual wrote:
>
> Hi,
>
> I never know what people mean by "Django is overkill for...". Django is 
> lightweight and starts up very quickly
>
> You're right WRT the Django technical part. 
>
> My feeling is that people implicitly refer to the learning curve, because 
> it's the visible part. Django is a very capable framework with batteries 
> included, but its documentation is largely ORM-centric* (which is logical 
> because of its  motivations) *in addition to being quite voluminous *(which 
> is a good point, since it covers every tiny bit of  the beast)*. This can 
> be intimidating when people are looking for something very basic which does 
> not require the ORM. 
>
> I was among these people until my experience and skills in Django reached 
> the level where I became aware that it can be stripped down to a very basic 
> an lightweight framework if needed, thanks to its modular approach. But 
> this came with time 
>
> Best
>
> Eric
> --
> *From:* django...@googlegroups.com  <
> django...@googlegroups.com > on behalf of Scot Hacker <
> scot@gmail.com >
> *Sent:* Tuesday, February 5, 2019 08:54
> *To:* Django users
> *Subject:* Re: Webinterface for python script 
>  
> Make a basic Django view. Place your script in a python module that lives 
> inside your app. Call that module/ function from the Django view. See 
> Django docs and tutorials on how to handle uploaded files. Pass the 
> uploaded file to your module, and handle the return value(s) however you 
> want. Hard to get more specific than that without seeing your code, but 
> this should come together pretty quickly with some experimentation.
>
> I never know what people mean by "Django is overkill for...". Django is 
> lightweight and starts up very quickly, even with large/complex projects. 
> Django saves you mountains of time compared to Flask, which makes you go 
> shopping for every little piece of framework you need. Every time I've 
> experimented with Flask, I've come running back to Django after realizing 
> my time is too valuable to waste it on creating my own framework when a 
> perfectly great one already exists. 
>
> ./s 
>
>
> On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote: 
>
> Hi All , 
>
>   I have created certain python scripts to analyze log files and 
> suggest solution based on logic which I invoke on the command line . I need 
> some information on how to execute these through browser . I am using :
>
> python test.py file1 file2 
>
> How do I use the browser to upload the files file1 and file2 and it 
> process the files .
>
> Please advice ,
>
> 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...@googlegroups.com .
> To post to this group, send email to djang...@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/88c2337b-7e8a-4e11-968f-30299b6229d4%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/a22625b0-d058-4691-83d3-c2510303ac80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.6 + django-allauth facebook authentication error

2019-02-05 Thread sachit adhikari
Anyone having a issue, look at this tutorial 
: https://www.youtube.com/watch?v=PtVu04V027c

On Tuesday, December 24, 2013 at 6:05:26 PM UTC+11, Nobin Mathew wrote:
>
> Hi,
>
> I am writing a django website using django-allauth for facebook 
> authentication.
>
> When I sign into facebook(after giving username and passwd) from my local 
> development server( `<`http://127.0.0.1:8001/gallery/` 
> >` ) I get following error:
>
> ***
> Social Network Login Failure
>
> An error occurred while attempting to login via your social network 
> account.
> ***
>
> and url in browser while on this error is 
> http://localhost:8001/gallery/accounts/facebook/login/callback/.
>
>
> Settings:
>
> Facebook.com app setting:
> AppId =XXX(not shown)
> APP secret =xxx(not shown)
>
> Wbsite:Site URL = 
> http://localhost:8001/gallery/accounts/facebook/login/callback/
>
> Django setting(local):
>
> LOGIN_REDIRECT_URL = '
> http://localhost:8001/gallery/accounts/facebook/login/callback/'
>
> SOCIALACCOUNT_PROVIDERS = {
>  'facebook': {
> 'SCOPE': ['email', 'publish_stream'],
> 'AUTH_PARAMS': { 'auth_type': 'reauthenticate' },
> 'METHOD': 'oauth2'  # instead of 'oauth2'
>  }
> }
>
> ACCOUNT_LOGOUT_REDIRECT_URL = '/gallery'
> SOCIALACCOUNT_QUERY_EMAIL = True
> SOCIALACCOUNT_AUTO_SIGNUP = True
> ACCOUNT_EMAIL_VERIFICATION = False
>
>
>
> and my base.html template is (not full):
>   
>  {% load url from future %}
>  {% load socialaccount %}
>  {% if request.user.is_authenticated %}
>  Logout
>  {% else %}
>  Sign Up
>  Log in
>  
>  Sign Up/Login with Facebook
>  {% endif %}
>   
>
>  
>
>
> When I am error page  
> http://localhost:8001/gallery/accounts/facebook/login/callback/ it says I 
> am logged in (i.e. displays Logout and user is authenticated).
>
> Any Idea why this happens? Any help will be appreciated.
>
>
>
>
>
>
>

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


Sample work space required for Django with Mongodb integration.

2019-02-05 Thread thammanenitcs
Hi All,

I am trying from so many days to integrate both Django and MongoDB. but 
every time I am facing so many issues while doing migrations.

Could you please share anyone having sample workspace for Django with 
MongoDB.

It helps a lot to me.


Thanks and Regards,
Srinivas.

-- 
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/fc6cc46f-6d8e-49c0-aa92-2bc8992c7439%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels - Request hangs if exception is uncaught in AsyncHttpConsumer

2019-02-05 Thread notorious no
If an exception happens in the `handle` function of a consumer, then the 
exception is simply ignored. I'd like to be able to catch it via middleware 
if at all possible so I don't have to put decorators around every `handle` 
func. is this possible?

-- 
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/56b8e2e0-7ee0-40f2-9a1c-99d0350da14a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mongoengine

2019-02-05 Thread thammanenitcs
I am not sure but try to import mongoengine.

I am also trying many ways to get this combo integration.



On Monday, February 4, 2019 at 11:29:16 PM UTC+5:30, B.navya spoorthi 
Sweety wrote:
>
> hi all
>  
> i am trying django with mongo
>
> i added following lines in settings.py
>
> mongoengine.connect(
> db="tools",
> host="localhost"
> )
>
> i am seeing error 
>   File "", line 697, in exec_module
>   File "", line 222, in 
> _call_with_frames_removed
>   File "C:\c_burra_mongo_1\mysite\mysite\settings.py", line 124, in 
> 
> mongoengine.connect(
> NameError: name 'mongoengine' is not defined
>
> i am aware that i need to change something here
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> }
> }
>
> but not sure what to change
>

-- 
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/7012c024-c5c9-40fa-83e1-0dbc6b6cd9f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels - Catch unhandled exceptions in HTTP consumer

2019-02-05 Thread notorious no
While working with `AsyncHttpConsumer` objects, I noticed that uncaught 
exceptions cause the response to hang. In most cases, my code handles 
exceptions but in the off chance that an exception slips by, I'd like to 
catch it. Here's an example consumer that hangs:


```
class Example(AsyncHttpConsumer):
async def handle(self, body):
await self.send_response(500, 'this should be bytes')# param 2 
should be bytes

```


I tried to use a middleware that has a `process_exception()` but then I 
found this issue https://github.com/django/channels/issues/407.
Then I stumbled upon `handle_uncaught_exception()` 

 
but I don't know how to trigger it from the consumer.
Is there a way I can catch unhandled exceptions? The issue says to "hook 
into the logger", but I don't see any documentation on how to do that.
I would imagine there's a error_back or try/except on the 
`consumer.handle()` call that I can hook into as well.

-- 
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/2f4987b7-23ee-4df4-9d9f-857f286b98a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Projects in django

2019-02-05 Thread thammanenitcs
Hi Nitin,

I am struggling to connect Django with MongoDB. 

Could you please help me to set up a workspace with this combo. 

it helps a lot to me.

Thanks,
Srinivas,
thammanen...@gmail.com



On Wednesday, January 16, 2019 at 1:31:01 PM UTC+5:30, Nitin Kumar wrote:
>
> Hi,
>
> I have an year of experience working in python and django. 
> I am looking for some projects in django for remote work.
>
> Regards, 
> Nitin Kumar 
>

-- 
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/73caa425-7809-4cba-90ff-7ec07881ffbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Webinterface for python script

2019-02-05 Thread PASCUAL Eric
Hi,
I never know what people mean by "Django is overkill for...". Django is 
lightweight and starts up very quickly
You're right WRT the Django technical part.

My feeling is that people implicitly refer to the learning curve, because it's 
the visible part. Django is a very capable framework with batteries included, 
but its documentation is largely ORM-centric (which is logical because of its  
motivations) in addition to being quite voluminous (which is a good point, 
since it covers every tiny bit of  the beast). This can be intimidating when 
people are looking for something very basic which does not require the ORM.

I was among these people until my experience and skills in Django reached the 
level where I became aware that it can be stripped down to a very basic an 
lightweight framework if needed, thanks to its modular approach. But this came 
with time 

Best

Eric

From: django-users@googlegroups.com  on behalf 
of Scot Hacker 
Sent: Tuesday, February 5, 2019 08:54
To: Django users
Subject: Re: Webinterface for python script

Make a basic Django view. Place your script in a python module that lives 
inside your app. Call that module/ function from the Django view. See Django 
docs and tutorials on how to handle uploaded files. Pass the uploaded file to 
your module, and handle the return value(s) however you want. Hard to get more 
specific than that without seeing your code, but this should come together 
pretty quickly with some experimentation.

I never know what people mean by "Django is overkill for...". Django is 
lightweight and starts up very quickly, even with large/complex projects. 
Django saves you mountains of time compared to Flask, which makes you go 
shopping for every little piece of framework you need. Every time I've 
experimented with Flask, I've come running back to Django after realizing my 
time is too valuable to waste it on creating my own framework when a perfectly 
great one already exists.

./s


On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote:
Hi All ,

  I have created certain python scripts to analyze log files and 
suggest solution based on logic which I invoke on the command line . I need 
some information on how to execute these through browser . I am using :

python test.py file1 file2

How do I use the browser to upload the files file1 and file2 and it process the 
files .

Please advice ,

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/88c2337b-7e8a-4e11-968f-30299b6229d4%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/AM0P193MB03087CA6B3D3BD6621C813188C6E0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Webinterface for python script

2019-02-05 Thread Joel Mathew
Exactly. I to use file upload and rendering in a medical report.

@OP Did your research and post your code. Can help with any errors you're
getting.

Research about request.POST, request.FILES. Read this.
https://docs.djangoproject.com/en/2.1/topics/files/

On Tue, 5 Feb, 2019, 1:25 PM Scot Hacker  Make a basic Django view. Place your script in a python module that lives
> inside your app. Call that module/ function from the Django view. See
> Django docs and tutorials on how to handle uploaded files. Pass the
> uploaded file to your module, and handle the return value(s) however you
> want. Hard to get more specific than that without seeing your code, but
> this should come together pretty quickly with some experimentation.
>
> I never know what people mean by "Django is overkill for...". Django is
> lightweight and starts up very quickly, even with large/complex projects.
> Django saves you mountains of time compared to Flask, which makes you go
> shopping for every little piece of framework you need. Every time I've
> experimented with Flask, I've come running back to Django after realizing
> my time is too valuable to waste it on creating my own framework when a
> perfectly great one already exists.
>
> ./s
>
>
> On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote:
>>
>> Hi All ,
>>
>>   I have created certain python scripts to analyze log files and
>> suggest solution based on logic which I invoke on the command line . I need
>> some information on how to execute these through browser . I am using :
>>
>> python test.py file1 file2
>>
>> How do I use the browser to upload the files file1 and file2 and it
>> process the files .
>>
>> Please advice ,
>>
>> 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/88c2337b-7e8a-4e11-968f-30299b6229d4%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/CAA%3Diw_-a-x4dOWwvqckq1E%2B8Bv%2B5n1DHxikEsEBVxDq9pHKV1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.