Re: SHA-512 in django model? Optimization help?

2019-04-07 Thread René Fleschenberg
Hi

Assuming you are on Postgres, Using BinaryField(max_length=64) should be
good if you want to optimize for size. According to the Postgres docs,
it will use "1 or 4 bytes" plus the actual string.

It is also reasonably convenient to work with:

instance.hashfield = hashlib.sha512(b'test').digest()
instance.save()

And if you want to output for display:

print(instance.hashfield.encode('hex'))

An integer is not going to work, since you need 64 bytes (512 / 8 = 64)
and the largest integer type can only hold 8 bytes.


René


On 4/8/19 3:12 AM, Benjamin Schollnick wrote:
> Right now, I’m generating a SHA-512 of a file in my Django model, but
> that requires a string of 128 bytes…
> 
> I’m not positive on a better way to store the sha-512 in my model?  Can
> anyone suggest a method / design that would be better optimized?
> 
> A quick test, looks like I might be able to store this in a blob of 64
> bytes, which would be a considerable savings…
> 
> t = hashlib.sha512(test.encode("utf-16”))
> digest = t.digest()
> len(digest)
> 64
> 
> t = hashlib.sha512(test.encode("utf-16”))
> hexdigest = t.hexdigest()
> len(hexdigest)
> 128
> 
> But thinking about it, I could convert the hex digest to an integer?
> 
> int(hexdigest,16)
> 4298666745768817459166789395753510504053621749752930724783367173454957154660445390018210346619930005782627382250329880502243093184532984814018267510704707
> z = int(hexdigest,16)
> type(z)
> 
> 
> 
> ‘52137203c3c4b62bc981fd9c8770952bfd1984ee9ce6e33ec94e485bc31a5631b6c6d15c1a2646f39c887575b576e66ed1ddbd96112d5355e574f06df8878a43'
> 0x52137203c3c4b62bc981fd9c8770952bfd1984ee9ce6e33ec94e485bc31a5631b6c6d15c1a2646f39c887575b576e66ed1ddbd96112d5355e574f06df8878a43
> 
> They convert identically, but I’m not sure that converting to integer
> would keep the integrity of the sha-512?
> 
> Can anyone make any sort of suggestion on the best way to handle this?
> 
> - Benjamin
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "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/61a7c17c-7c23-49ca-9cdb-0df325672ed5%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
René Fleschenberg

Rosastrasse 53, 45130 Essen, Germany
Phone: +49 1577 170 7363
https://fleschenberg.net
E-mail: r...@fleschenberg.net

-- 
You received this message because you are subscribed to the Google Groups 
"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/b4bcaa0d-507b-7ffb-1b99-571f1bfb84d1%40fleschenberg.net.
For more options, visit https://groups.google.com/d/optout.


Urgently help for how to deploy django on bigrock server?

2019-04-07 Thread surojitsahu07
Urgently help for how to deploy django on bigrock server?

-- 
You received this message because you are subscribed to the Google Groups 
"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/fa54873d-f8ce-4031-9337-eea7a2dcfba5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Custom sign up / log in for multi role in DRF

2019-04-07 Thread Shubham Joshi
My concern is I want to develop an API's for user registration having the 
multiple fields, there will be admin registration , after that, 
student/teacher registraion form.

The form will be mailed to admin email for verification , if validated then 
student/teacher should able to login. 

-- 
You received this message because you are subscribed to the Google Groups 
"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/f7270a6a-4977-43b1-98e1-c94c19672bbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Builtin Admin

2019-04-07 Thread carlos
Hi, i thing this app help you
https://github.com/oscarmlage/django-cruds-adminlte



On Sun, Apr 7, 2019 at 6:37 AM  wrote:

> Hello Django Users,
> I know django builtin admin is not possible to customize same to as the
> attached picture. But Client like a nice and attractive dashboard. Is there
> any one who can show me the right way?
> Still now I have done like this such as created two different apps like
> one is for public view and another is for creating dashboard using view,
> model forms and auth. Is it a right way?
> and what does do the professional developer to develop same kind of
> dashboard in django. please explain me.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/d8b9ad14-d402-4e27-8270-1a19e153b417%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
att.
Carlos Rocha

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAM-7rO2T-ampP%2BK5r3Bh3meugYXaCfHb54LDtNFheAo3w3mb0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


SHA-512 in django model? Optimization help?

2019-04-07 Thread Benjamin Schollnick
Right now, I’m generating a SHA-512 of a file in my Django model, but that 
requires a string of 128 bytes…

I’m not positive on a better way to store the sha-512 in my model?  Can 
anyone suggest a method / design that would be better optimized?

A quick test, looks like I might be able to store this in a blob of 64 
bytes, which would be a considerable savings…

t = hashlib.sha512(test.encode("utf-16”))
digest = t.digest()
len(digest)
64

t = hashlib.sha512(test.encode("utf-16”))
hexdigest = t.hexdigest()
len(hexdigest)
128

But thinking about it, I could convert the hex digest to an integer?

int(hexdigest,16)
4298666745768817459166789395753510504053621749752930724783367173454957154660445390018210346619930005782627382250329880502243093184532984814018267510704707
z = int(hexdigest,16)
type(z)



‘52137203c3c4b62bc981fd9c8770952bfd1984ee9ce6e33ec94e485bc31a5631b6c6d15c1a2646f39c887575b576e66ed1ddbd96112d5355e574f06df8878a43'
0x52137203c3c4b62bc981fd9c8770952bfd1984ee9ce6e33ec94e485bc31a5631b6c6d15c1a2646f39c887575b576e66ed1ddbd96112d5355e574f06df8878a43

They convert identically, but I’m not sure that converting to integer would 
keep the integrity of the sha-512?

Can anyone make any sort of suggestion on the best way to handle this?

- Benjamin

-- 
You received this message because you are subscribed to the Google Groups 
"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/61a7c17c-7c23-49ca-9cdb-0df325672ed5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unsupported operand type (s) for -: 'NoneType' and 'NoneType'

2019-04-07 Thread 'Vinod Kumar' via Django users
Hi
It error generate from model string represention where you are trying to
add two other relationship model key those don't have any object.

Please let me know if you have any other questions.
Or share with me model structure.

I'm happy to help you.

On Mon, Apr 8, 2019, 5:45 AM Elias Coutinho 
wrote:

> Save some people.
>
> Friends lack sufficient knowledge to try to solve this problem alone.
>
> I have these 3 classes below:
>
> Historical
> ,
> Account
> ,
> Payment
> 
>
> In the admin I can list in the History the added values of Account and
> Payment as well so I will search in the respective models, however I think
> it is interesting to also present a column with the remaining value, that
> is, Account - Payment (Clustered value of accounts subtracted from the
> payment) .
>
> I thought it would be easy to do but it returns me the following error:
>
> unsupported operand type (s) for -: 'NoneType' and 'NoneType'
>
> I know it means the message but I do not know how to solve it.
>
> Has anyone ever experienced this? Can you help me?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/d3190fd9-0fdf-4e1d-9f3d-6a0120662b3e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 









This e-mail and all attachments are intended solely for use by
the intended 
recipient and may contain confidential / proprietary information
of 
KiwiTech, LLC, subject to important disclaimers and conditions including

restrictions on the use, disclosure, transfer or export of such 
information. If you have received this
message in error or are not the 
named recipient(s), please immediately notify
the sender at the telephone 
number stated above or by reply e-mail and delete
this e-mail from your 
computer





-- 
You received this message because you are subscribed to the Google Groups 
"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/CAJOHC1y6PAWRJBmGqk7%3DZFbDrFFZJaqgAvEwZdxm5x5T%3DAq-TQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


unsupported operand type (s) for -: 'NoneType' and 'NoneType'

2019-04-07 Thread Elias Coutinho
Save some people.

Friends lack sufficient knowledge to try to solve this problem alone.

I have these 3 classes below:

Historical 
,
 
Account 
,
 
Payment 


In the admin I can list in the History the added values of Account and 
Payment as well so I will search in the respective models, however I think 
it is interesting to also present a column with the remaining value, that 
is, Account - Payment (Clustered value of accounts subtracted from the 
payment) .

I thought it would be easy to do but it returns me the following error:

unsupported operand type (s) for -: 'NoneType' and 'NoneType'

I know it means the message but I do not know how to solve it.

Has anyone ever experienced this? Can you help me?

-- 
You received this message because you are subscribed to the Google Groups 
"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/d3190fd9-0fdf-4e1d-9f3d-6a0120662b3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django external libraries

2019-04-07 Thread Gabo LaTo
Hi Saed. Maybe what you are trying to install does not need a migration.
What is it?
But the lack of error message it's an improvement.
Are you able to use the library you installed now?

El dom., 7 abr. 2019 a las 12:40, Saeed Pooladzadeh ()
escribió:

> I did what you say, but when I run the  migration I see this:
>
> Running migrations:
>   No migrations to apply.
> Executing manage.py migrate
> Operations to perform:
>   Apply all migrations: (none)
> Running migrations:
>   No migrations to apply.
>
> Is it mean the migration has happened before?
>
> How can I understand?
>
> در یکشنبه 7 آوریل 2019، ساعت 14:28:18 (UTC+4:30)، Saeed Pooladzadeh نوشته:
>>
>> Hello
>>
>> I've added an external library in django. I have installed in installed
>> apps but when I try to migrate the model I keep getting this error:
>>
>> ERRORS:
>> ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware'
>> must be in MIDDLEWARE in order to use the admin application.
>> ?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware'
>> must be in MIDDLEWARE in order to use the admin application.
>> The interactive Python process has exited.
>> The interactive Python process has exited.
>>
>> and my middleware is this:
>>
>> MIDDLEWARE_CLASSES = [
>> 'django.middleware.security.SecurityMiddleware',
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware'
>> ]
>>
>> Also my IDE is visual studio.
>>
>> Please inform me.
>>
>> Saeed
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "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/93acf38e-a685-45e7-9ba3-cf78f964f268%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/CAF6hzDPzQmj9xUHTaSxjnfX0xBUKx7sMDP7KRw8QTHP4BQh4DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError unsupported operand type(s) for *: 'NoneType' and 'int'

2019-04-07 Thread omar ahmed
ok i understood 
thanks for help

On Sunday, April 7, 2019 at 11:58:50 AM UTC+2, Roger Gammans wrote:
>
> Omar,
>
> When posting question to the list it's good practice to practice tell us a 
> little bit about what your trying to do, and how what
> actions cause the error to occur.
>
> In this case though you only have a (single line in CalcPoints) which uses 
> the '*' operator.
>
> On Sat, 2019-04-06 at 10:35 -0700, omar ahmed wrote:
>
> models.py
> def CalcPoints(self):
> return self.won*3 + self.draw
>
>
>
> The python documentation has this to say about the '*' operator
> *(from: *
> https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
> )
>
> *The * (multiplication) operator yields the product of its arguments. The 
> arguments must either both be numbers, or one argument must be an integer 
> and the other must be a sequence. In the former case, the numbers are 
> converted to a common type and then multiplied together. In the latter 
> case, sequence repetition is performed; a negative repetition factor yields 
> an empty sequence.*
>
> Since you've provided a literal integer ( the '3') as one of your 
> arguments, we can deduce the None value
> is in self.won. Since you have 'declared' self.won as an IntegerField; we 
> can see that as in the
> normal case we should satisfy the first clause of the reference, "*arguments 
> must either both be numbers"*
> however so some reason self.won is None in your case.
>
> Without seeing the rest of your code it's impossible to guess accurately 
> but my instinct is your haven't
> initialised your instance from the database (or set a won value when 
> creating the object).
>
> If you expected to have a default value you need to set one where you set 
> up self.won see 
> : https://docs.djangoproject.com/en/2.2/ref/models/fields/#default
>
> HTH,
>
> -- 
>
> Roger Gammans >
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/d152c3b3-591d-4012-b18a-d4014156c8a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django external libraries

2019-04-07 Thread Saeed Pooladzadeh
I did what you say, but when I run the  migration I see this:

Running migrations:
  No migrations to apply.
Executing manage.py migrate
Operations to perform:
  Apply all migrations: (none)
Running migrations:
  No migrations to apply.

Is it mean the migration has happened before?

How can I understand?

در یکشنبه 7 آوریل 2019، ساعت 14:28:18 (UTC+4:30)، Saeed Pooladzadeh نوشته:
>
> Hello
>
> I've added an external library in django. I have installed in installed 
> apps but when I try to migrate the model I keep getting this error:
>
> ERRORS:
> ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' 
> must be in MIDDLEWARE in order to use the admin application.
> ?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' 
> must be in MIDDLEWARE in order to use the admin application.
> The interactive Python process has exited.
> The interactive Python process has exited.
>
> and my middleware is this:
>
> MIDDLEWARE_CLASSES = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware'
> ]
>
> Also my IDE is visual studio.
>
> Please inform me.
>
> Saeed
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/93acf38e-a685-45e7-9ba3-cf78f964f268%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django external libraries

2019-04-07 Thread Asif Saif Uddin
try to make MIDDLEWARE_CLASSES to MIDDLEWARE first, you didn't mentioned 
the version of django and the extension you installed.

On Sunday, April 7, 2019 at 3:58:18 PM UTC+6, Saeed Pooladzadeh wrote:
>
> Hello
>
> I've added an external library in django. I have installed in installed 
> apps but when I try to migrate the model I keep getting this error:
>
> ERRORS:
> ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' 
> must be in MIDDLEWARE in order to use the admin application.
> ?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' 
> must be in MIDDLEWARE in order to use the admin application.
> The interactive Python process has exited.
> The interactive Python process has exited.
>
> and my middleware is this:
>
> MIDDLEWARE_CLASSES = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware'
> ]
>
> Also my IDE is visual studio.
>
> Please inform me.
>
> Saeed
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/26cdf25a-0aa3-4803-a0a8-541ee9501201%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Filtering choices in a form based on previous field selection

2019-04-07 Thread Gavin Boyle
Hi all,

Just quickly to summarize I have an app, which allows clubs to sign up and
carry out different tasks. One of the features is a scheduling / rosters.
Currently I have a form to add times to the roster. The club pages work off
a session key based on the initially selected club.

My form consists of:
*club_id* - which I have hidden and initialized based on the logged in user.
*pitch_id - *which is currently displaying all pitches associated to all
clubs but I need this to *only show pitches based on the foreign key for
the club_id *

Would appreciate any help.

Please see code below:

*form.py *

from django import forms
from clubkit.roster.models import RosterId
import datetime
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _


# Form to add/edit club roster
class RosterForm(forms.ModelForm):

class Meta():
model = RosterId
fields = ('club_id', 'pitch_id', 'team_id', 'date',
  'start_time', 'finish_time', 'reoccuring_event',)
widgets = {
'date': forms.DateInput(attrs={'id': 'datepicker'})
}

def clean_date(self):
date = self.clean_date['date']
if date < datetime.date.today():
raise ValidationError(_('Date cannot be in the past.'))
return date

def __init__(self, *args, **kwargs):
super(RosterForm, self).__init__(*args, **kwargs)
self.fields['club_id'].widget = forms.HiddenInput()

*model.py - for roster*

from django.db import models
from clubkit.clubs.models import ClubInfo, Pitch, Team


# Model to store roster information
class RosterId(models.Model):
club_id = models.ForeignKey(ClubInfo, on_delete=models.CASCADE)
pitch_id = models.ForeignKey(Pitch, on_delete=models.CASCADE)
team_id = models.ForeignKey(Team, on_delete=models.CASCADE)
date = models.DateField(max_length=8)
start_time = models.TimeField(default='')
finish_time = models.TimeField(default='')
reoccuring_event = models.BooleanField(default=False)

*model.py - for pitch*

class Pitch(models.Model):
club_id = models.ForeignKey(ClubInfo, on_delete=models.CASCADE,
related_name="pitches")
pitch_name = models.CharField(max_length=30)
PITCH_SIZES = (
('S', 'Small'),
('M', 'Medium'),
('L', 'Large'),
)
PITCH_TYPE = (
('1', 'Outdoor'),
('2', 'Indoor'),
)
pitch_size = models.CharField(max_length=1, choices=PITCH_SIZES)
pitch_type = models.CharField(max_length=1, choices=PITCH_TYPE)
open_time = models.TimeField(default='09:00')
close_time = models.TimeField(default='22:00')
RENT_TYPE = (
('0', 'Not Available To Rent'),
('1', 'Available To Rent'),
)
rental = models.CharField(max_length=1, choices=RENT_TYPE)
rental_price = models.DecimalField(default=0.00, max_digits=6,
decimal_places=2)
max_people = models.IntegerField(null=True)

def __str__(self):
return self.pitch_name

*view.py*

class ClubRoster(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'roster.html'

# Get method to retrieve current roster information and form
def get(self, request):
if request.user.is_authenticated:
club_pk = request.session.get('pk')
club_info = ClubInfo.objects.filter(user=request.user).first()
reoccuring_event =
RosterId.objects.filter(reoccuring_event=True, club_id=club_pk)
inital_data = {
'club_id': club_info,
}
form = RosterForm(initial=inital_data)
roster = RosterId.objects.filter(club_id=club_pk)
return Response({'form': form,
 'roster': roster,
 'club_pk': club_pk,
 'reoccuring_event': reoccuring_event
 })

-- 
__

Séanadh Ríomhphoist/_

Email Disclaimer__
**

Tá an ríomhphost seo agus 
aon chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus 
sin amháin é. Is féidir tuilleadh a léamh anseo. 
  
*
_

This e-mail and any 
files transmitted with it are confidential and are intended solely for use 
by the addressee. Read more here. 
 _
*_

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

Does django have a user editable templating language that is secure like liquid?

2019-04-07 Thread Jeff_dev


Does django have a user editable templating language that is secure like 
rails has liquid?

i.e. an end user can't hack template code to somehow access properties of 
sensitive template variables

-- 
You received this message because you are subscribed to the Google Groups 
"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/4992a747-47a4-4018-8cbd-2fff45393128%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Builtin Admin

2019-04-07 Thread shaumik . gh
Hello Django Users,
I know django builtin admin is not possible to customize same to as the 
attached picture. But Client like a nice and attractive dashboard. Is there 
any one who can show me the right way?
Still now I have done like this such as created two different apps like one 
is for public view and another is for creating dashboard using view, model 
forms and auth. Is it a right way?
and what does do the professional developer to develop same kind of 
dashboard in django. please explain me.

-- 
You received this message because you are subscribed to the Google Groups 
"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/d8b9ad14-d402-4e27-8270-1a19e153b417%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django external libraries

2019-04-07 Thread Saeed Pooladzadeh
I removed them but still see the error.

در یکشنبه 7 آوریل 2019، ساعت 14:28:18 (UTC+4:30)، Saeed Pooladzadeh نوشته:
>
> Hello
>
> I've added an external library in django. I have installed in installed 
> apps but when I try to migrate the model I keep getting this error:
>
> ERRORS:
> ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' 
> must be in MIDDLEWARE in order to use the admin application.
> ?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' 
> must be in MIDDLEWARE in order to use the admin application.
> The interactive Python process has exited.
> The interactive Python process has exited.
>
> and my middleware is this:
>
> MIDDLEWARE_CLASSES = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware'
> ]
>
> Also my IDE is visual studio.
>
> Please inform me.
>
> Saeed
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/ce8a8529-6be2-4b9f-b79b-1aeb6a65109f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django external libraries

2019-04-07 Thread Manas Nikam
Remove the bottom two duplicate middleware  already present and try again

On Sun, Apr 7, 2019, 3:28 PM Saeed Pooladzadeh  wrote:

> Hello
>
> I've added an external library in django. I have installed in installed
> apps but when I try to migrate the model I keep getting this error:
>
> ERRORS:
> ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware'
> must be in MIDDLEWARE in order to use the admin application.
> ?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware'
> must be in MIDDLEWARE in order to use the admin application.
> The interactive Python process has exited.
> The interactive Python process has exited.
>
> and my middleware is this:
>
> MIDDLEWARE_CLASSES = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware'
> ]
>
> Also my IDE is visual studio.
>
> Please inform me.
>
> Saeed
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/40cb99e0-bb41-4f46-ab69-a8701e3d8de9%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/CAF%2BYYc5iYMSVrhg7zO8JZ7TnkYTcNRLv9SF2jUFvHUJgnJFTcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError unsupported operand type(s) for *: 'NoneType' and 'int'

2019-04-07 Thread Roger Gammans
Omar,

When posting question to the list  it's good practice to  practice tell
us a little bit about what your trying to do, and how what
actions cause the error to occur.

In this case though you only have a (single line in CalcPoints) which
uses the '*' operator.

On Sat, 2019-04-06 at 10:35 -0700, omar ahmed wrote:
> models.py
> def CalcPoints(self):
> return self.won*3 + self.draw


The python documentation has this to say about the '*' operator
(from: 
https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
)

The * (multiplication) operator yields the product of its
arguments.  The
arguments must either both be numbers, or one argument must be an
integer and
the other must be a sequence. In the former case, the numbers are
converted to a
common type and then multiplied together.  In the latter case, sequence
repetition is performed; a negative repetition factor yields an empty
sequence.

Since you've provided a literal integer ( the '3') as one of your
arguments, we can deduce the None value
is in self.won. Since you have 'declared' self.won as an
IntegerField;  we can see that as in the
normal case we should satisfy the first clause of the reference,
"arguments must either both be numbers"
however so some reason self.won is None in your case.

Without seeing the rest of your code it's impossible to guess
accurately but my instinct is your haven't
initialised your instance from the database (or set a won value when
creating the object).

If you expected to have a default value you need to set one where you
set up self.won see 
:  https://docs.djangoproject.com/en/2.2/ref/models/fields/#default

HTH,


-- 
Roger Gammans 

-- 
You received this message because you are subscribed to the Google Groups 
"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/ea23ce16123320b41ad5f468ebb742f1bcb25b37.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Django external libraries

2019-04-07 Thread Saeed Pooladzadeh
Hello

I've added an external library in django. I have installed in installed 
apps but when I try to migrate the model I keep getting this error:

ERRORS:
?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' 
must be in MIDDLEWARE in order to use the admin application.
?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' must 
be in MIDDLEWARE in order to use the admin application.
The interactive Python process has exited.
The interactive Python process has exited.

and my middleware is this:

MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware'
]

Also my IDE is visual studio.

Please inform me.

Saeed


-- 
You received this message because you are subscribed to the Google Groups 
"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/40cb99e0-bb41-4f46-ab69-a8701e3d8de9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Specifying model relationship as string vs concrete model?

2019-04-07 Thread PASCUAL Eric
Hi Mohit,

The only situations where I have used strings are forward declarations or 
potential reference loops.

Intuitively I'd say that referencing models by their name adds a slight 
overhead for class lookup. But since this is supposed to happen only when the 
model definition is loaded (fields are class level attributes), there are 
chances that there is no impact on performances during the application normal 
operation. The impact should be on the application start phase, but it's 
probably neglectable compared to the overall start time.

Since I've never done any real timing about this point, nor studied Django 
source code to identify the real mechanism, I'm strongly interested in other 
opinions... especially if my analysis is wrong 😉

Best

Eric


From: django-users@googlegroups.com  on behalf 
of Mohit Solanki 
Sent: Sunday, April 7, 2019 05:43
To: Django users
Subject: Specifying model relationship as string vs concrete model?

Since Django provides two ways of specifying model relationship,

models.ForeignKey('User') vs models.ForeignKey(User)

Which one is more preferred and recommended? Is there any upside or downside of 
choosing one over the other?  In Django documentation, all the example are of 
the second form but I have seen many people specifying the relationship as a 
string. Can Someone please elaborate more on this?

Regards,

Mohit

--
You received this message because you are subscribed to the Google Groups 
"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/06988f5c-9ad0-47b1-9216-5f689abb1720%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/AM0P193MB0308A3049D2828BB316C4B348C530%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.