Re: What is meaning of '[::1]'?

2016-11-20 Thread Stephen J. Butler
"::1" is the IPv6 loopback address. If you haven't seen IPv6 addresses
before, they separate the parts of an address with ":" instead of ".".
Using two together ("::") is a shorthand for "fill all these bits with
zero" and it can appear only once in an address.

You see the brackets "[]" in URLs because otherwise any URL parser would
get confused by what's the address and what's the port. For example, is
"http://2607:f8b0:4009:812::200e:8080; telling you to connect to address
"2607:f8b0:4009:812::200e" on port "8080", or address
"2607:f8b0:4009:812::200e:8080" on the standard port 80? Brackets make this
unambiguous: "http://[2607:f8b0:4009:812::200e]:8080/;

On Sun, Nov 20, 2016 at 8:53 PM, James Bennett 
wrote:

> It's the IPv6 loopback address. So it has the same function as 127.0.0.1,
> just for IPv6 instead of IPv4.
>
> On Sun, Nov 20, 2016 at 6:45 PM, bob gailer  wrote:
>
>> From https://docs.djangoproject.com/en/1.10/ref/settings/#std:set
>> ting-ALLOWED_HOSTS:
>>
>> "When DEBUG  is |True| and |ALLOWED_HOSTS| is empty, the host is
>> validated against |['localhost', '127.0.0.1', '[::1]']|."
>>
>> What is meaning of '[::1]'?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/02858789-fa42-f8fe-817f-94360b3ddd7d%40gmail.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/CAL13Cg9a4XzefV0ZQqv%2Bh1c%3Dy9Nrt4zd%2BoFNk%
> 2BTYV0th148TbQ%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/CAD4ANxWLCcCP_QdOQbZ2zPGEAkz-76Eu_Sg_Z934RKQxxOOxmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is meaning of '[::1]'?

2016-11-20 Thread James Bennett
It's the IPv6 loopback address. So it has the same function as 127.0.0.1,
just for IPv6 instead of IPv4.

On Sun, Nov 20, 2016 at 6:45 PM, bob gailer  wrote:

> From https://docs.djangoproject.com/en/1.10/ref/settings/#std:set
> ting-ALLOWED_HOSTS:
>
> "When DEBUG  is |True| and |ALLOWED_HOSTS| is empty, the host is validated
> against |['localhost', '127.0.0.1', '[::1]']|."
>
> What is meaning of '[::1]'?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/02858789-fa42-f8fe-817f-94360b3ddd7d%40gmail.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/CAL13Cg9a4XzefV0ZQqv%2Bh1c%3Dy9Nrt4zd%2BoFNk%2BTYV0th148TbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


What is meaning of '[::1]'?

2016-11-20 Thread bob gailer
From 

https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-ALLOWED_HOSTS:

"When DEBUG  is |True| and |ALLOWED_HOSTS| is empty, the host is 
validated against |['localhost', '127.0.0.1', '[::1]']|."


What is meaning of '[::1]'?

--
You received this message because you are subscribed to the Google Groups "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/02858789-fa42-f8fe-817f-94360b3ddd7d%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with runserver

2016-11-20 Thread Alex Heyden
Is there anything at mysite/urls.py?

Also, how sure are you that you're actually hitting the Django server? If
you turn off the Django server, do you get the same page? If you navigate
to http://localhost:8000/ with runserver running, do you see the GET
request in the console?

On Sun, Nov 20, 2016 at 11:30 AM, NS  wrote:

> """
> Django settings for mysite project.
>
> Generated by 'django-admin startproject' using Django 1.10.3.
>
> For more information on this file, see
> https://docs.djangoproject.com/en/1.10/topics/settings/
>
> For the full list of settings and their values, see
> https://docs.djangoproject.com/en/1.10/ref/settings/
> """
>
> import os
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = '_'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> ]
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'mysite.urls'
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'mysite.wsgi.application'
>
>
> # Database
> # https://docs.djangoproject.com/en/1.10/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> }
> }
>
>
> # Password validation
> # https://docs.djangoproject.com/en/1.10/ref/settings/#
> auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME': 'django.contrib.auth.password_validation.
> UserAttributeSimilarityValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.
> MinimumLengthValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.
> CommonPasswordValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.
> NumericPasswordValidator',
> },
> ]
>
>
> # Internationalization
> # https://docs.djangoproject.com/en/1.10/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/1.10/howto/static-files/
>
> STATIC_URL = '/static/'
>
>
> On Saturday, November 19, 2016 at 9:36:30 PM UTC-5, Alex Heyden wrote:
>>
>> We'd need to see your settings file and maybe your top-level urls.py to
>> answer it conclusively, but in general terms, some view that's been mapped
>> to root on your project is returning that there JSON response. This is not
>> a default Django behavior, or at least wasn't in 1.10 or earlier.
>>
>> On Sat, Nov 19, 2016 at 7:58 PM, NS  wrote:
>>
>>> When I run python manage.py runserver, I get this shown on localhost:8000
>>>
>>> {"status": "fail",  "method": "", "error":""}
>>>
>>>
>>>
>>> What happened?
>>>
>>> --
>>> You received this message because you are subscribed 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/ms
>>> gid/django-users/24a87f66-8799-489b-acc4-db779eb811df%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> 

Re: How to create a django model for a resume/CV app

2016-11-20 Thread 'ron' via Django users
Thanks! I know it's been covered in the official django poll tutorial.

But how do I let users to do that without django admin? I probably will 
have an URL like: example.com/cv/create and only logged in users will be 
able to create their cv.
I am not sure how to set up the view so that users can create new cv.

I know class based view. But in my cv app, each user can have one CV, each 
CV can have one or more precious job and each CV can have one or more 
education entries.
So I can't actually use class based view here because a CV needs more than 
one class, right?

My questions are:
1) Is this the right set up in terms of the relationship for a CV app?
2) How can I let users create a CV with multiple related objects without 
user django admin.

This is my models.py. Is this the right way to set up the relationship of a 
CV??

> class Resume(models.Model): 
> about = models.TextField(max_length=500) 
> applicant = models.ForeignKey(User) 
> 
> 
> class Education(models.Model): 
> resume = models.ForeignKey(Resume) 
> school = models.CharField(max_length=100) 
> course = models.CharField(max_length=100) 
> start_date = models.DateField(blank=True, null=True) 
> end_date = models.DateField(blank=True, null=True) 
> 
> class Job(models.Model): 
> resume = models.ForeignKey(Resume) 
> title = models.CharField(max_length=100) 
> company = models.CharField(max_length=100) 
> start_date = models.DateField(blank=True, null=True) 
> end_date = models.DateField(blank=True, null=True) 



On Sunday, 6 November 2016 22:05:16 UTC+1, ludovic coues wrote:
>
> If you are using the default django admin, you can use inline model 
> admins [1]. The django's tutorial covert this point with polls' 
> questions having many possible choice in part 7 [2] 
>
> [1] 
> https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#inlinemodeladmin-objects
>  
> [2] 
> https://docs.djangoproject.com/en/1.10/intro/tutorial07/#adding-related-objects
>  
>
> 2016-11-06 15:11 GMT+01:00 ronronald97 via Django users 
> : 
> > Hi, 
> > 
> > I am rather new to django and not sure how to set up the relationship 
> for 
> > all the fields of a resume app. 
> > 
> > Let's say each user can have 1 or more resume. In each Resume, there is 
> a 
> > introduction/about, 1 or more education entries and 1 or more previous 
> job 
> > entries. 
> > Is this correct? 
> > 
> > class Resume(models.Model): 
> > about = models.TextField(max_length=500) 
> > applicant = models.ForeignKey(User) 
> > 
> > 
> > class Education(models.Model): 
> > school = models.CharField(max_length=100) 
> > course = models.CharField(max_length=100) 
> > Resume = models.ForeignKey(Resume) 
> > start_date = models.DateField(blank=True, null=True) 
> > end_date = models.DateField(blank=True, null=True) 
> > 
> > class Job(models.Model): 
> > title = models.CharField(max_length=100) 
> > company = models.CharField(max_length=100) 
> > Resume = models.ForeignKey(Resume) 
> > start_date = models.DateField(blank=True, null=True) 
> > end_date = models.DateField(blank=True, null=True) 
> > 
> > What should I do in the view or form to let user to add more education 
> or 
> > job fields? 
> > Or I could only set it up certain amount of entries for each model, for 
> > example 3 eduction entries and 5 previous jobs. 
> > Is there anyway I can do that dynamically so I can just start with 1 for 
> > each model and let the user add more if they need to? 
> > 
> > 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 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/c23fc997-b723-4987-9be7-eb352f88814b%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>
>
 

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


Re: Help with runserver

2016-11-20 Thread NS
"""
Django settings for mysite project.

Generated by 'django-admin startproject' using Django 1.10.3.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '_'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

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

ROOT_URLCONF = 'mysite.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# 
https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

STATIC_URL = '/static/'


On Saturday, November 19, 2016 at 9:36:30 PM UTC-5, Alex Heyden wrote:
>
> We'd need to see your settings file and maybe your top-level urls.py to 
> answer it conclusively, but in general terms, some view that's been mapped 
> to root on your project is returning that there JSON response. This is not 
> a default Django behavior, or at least wasn't in 1.10 or earlier.
>
> On Sat, Nov 19, 2016 at 7:58 PM, NS  
> wrote:
>
>> When I run python manage.py runserver, I get this shown on localhost:8000
>>
>> {"status": "fail",  "method": "", "error":""}
>>
>>
>>
>> What happened?
>>
>> -- 
>> You received this message because you are subscribed 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/24a87f66-8799-489b-acc4-db779eb811df%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/feab6be8-2746-4f7a-a1d5-2b3aee83b458%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with runserver

2016-11-20 Thread NS
DEBUG is set to true, and I don't see any error messages. There is no trace 
in the console either.

On Saturday, November 19, 2016 at 11:11:36 PM UTC-5, Asad Jibran Ahmed 
wrote:
>
> Do you have debugging turned on (DEBUG=True in settings.py) in Django? If 
> you do, you should see a pretty detailed stack trace and not just this. 
> Also, in the console you should see a stack trace with the details of the 
> error. Do you see those?
>
> Asad Jibran Ahmed 
> http://blog.asadjb.com
>
> On Sun, Nov 20, 2016 at 4:58 AM, NS  
> wrote:
>
>> When I run python manage.py runserver, I get this shown on localhost:8000
>>
>> {"status": "fail",  "method": "", "error":""}
>>
>>
>>
>> What happened?
>>
>> -- 
>> You received this message because you are subscribed 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/24a87f66-8799-489b-acc4-db779eb811df%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/8c322601-52a3-48c0-9fd7-4c6a306255dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to hook into the admin site to count login attempts with REST API / proxy?

2016-11-20 Thread Luis Zárate
Hi
You can override the admin login page overwriting the URLs, you can put
your own login view in admin/account/login after admin include in URLs


El domingo, 20 de noviembre de 2016, Reza Shalbafzadeh <
rezashal...@gmail.com> escribió:
> Hi
> you still can use Django axes as described in Django axes  documentation:
>
> django-axes requires a supported Django version. The application is
intended to work around the Django admin and the regular
django.contrib.auth login-powered pages.
>
> Also you can manually register urls for Django axes
>
http://django-axes.readthedocs.io/en/latest/issues.html#not-being-locked-out-after-failed-attempts
> add watch_login to your admin url
>
> On Friday, November 4, 2016 at 8:16:20 PM UTC+3:30, Daniel Grace wrote:
>>
>> Hello, I have a REST API which is not publicly accessible as it is
behind a proxy.  However the admin site is publicly available through an
NGINX server.  The REST API already has functionality to count failed login
attempts and I would like to duplicate that functionality on the admin
login page.  How do I hook into the admin login page and add the
appropriate code?  Can I still use Django Axes or should I create my own
login form as a replacement?
>> 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/1d87fca9-1d1d-4a6f-ba10-30c47152917b%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

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

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


Re: How to hook into the admin site to count login attempts with REST API / proxy?

2016-11-20 Thread Reza Shalbafzadeh
Hi
you still can use Django axes as described in Django axes  documentation 

:

django-axes requires a supported Django version. The application is 
intended to work around the Django admin and the regular django.contrib.auth 
login-powered pages. 

Also you can manually register urls for Django axes
http://django-axes.readthedocs.io/en/latest/issues.html#not-being-locked-out-after-failed-attempts
add watch_login to your admin url 

On Friday, November 4, 2016 at 8:16:20 PM UTC+3:30, Daniel Grace wrote:
>
> Hello, I have a REST API which is not publicly accessible as it is behind 
> a proxy.  However the admin site is publicly available through an NGINX 
> server.  The REST API already has functionality to count failed login 
> attempts and I would like to duplicate that functionality on the admin 
> login page.  How do I hook into the admin login page and add the 
> appropriate code?  Can I still use Django Axes or should I create my own 
> login form as a replacement?
> 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/1d87fca9-1d1d-4a6f-ba10-30c47152917b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Extending FieldField (the way ImageField does)

2016-11-20 Thread Michal Petrucha
On Sat, Nov 19, 2016 at 01:34:31PM -0800, Serge Wroclawski wrote:
> Hi all,
> 
> I've been a casual user of Django for years, but recently have need to make 
> a new field based on FileField. I decided to take a look at ImageField, 
> since it is very similar to what I'm doing.
> 
> Specifically I'm looking at using mutagen (python-mutagen) to get 
> information about audio files. Mutagen can tell me the bitrate, duration 
> and then tags for the audio.
> 
> That's quite similar to how ImageField uses PIL underneith, so all's good 
> there.
> 
> But in my investigation, I'm coming across some code I am having difficulty 
> following.
> 
> Both the ImageField itself and the ImageFieldDescriptor class call a method 
> on ImageField called update_dimension_fields.
> 
> The docstring says that it updates the field's width and height attributes, 
> but even after reading the code many times, I am not seeing where the 
> height and width are retrieved from the image itself, rather than either 
> being passed in values or values already in the database.

All right, so ImageFileDescriptor.__set__ calls
self.field.update_dimension_fields(instance, force=True), where
instance is a model instance, and self.field is an ImageField attached
to that model. ImageField.update_dimension_fields, in turn, calls
getattr(instance, self.attname), which runs the descriptor's __get__ –
that one ensures that the result is an instance of ImageFieldFile,

So at this point inside update_dimension_fields, the file variable is
an ImageFieldFile.

Next up, you can see that it does some checking to find out which
dimension fields to update, if any, and finally gets to the important
part:

# file should be an instance of ImageFieldFile or should be None.
if file:
width = file.width
height = file.height

So here, the dimensions are retrieved from an ImageFieldFile through
its width and height attributes. Where do those come from? If you look
at the ancestors of ImageFieldFile, you'll see that it inherits from
django.core.files.images.ImageFile. This class implements the width
and height properties, which call
django.core.files.images.get_image_dimensions. This is the meat of the
dimension-extracting code, which calls Pillow to do the heavy lifting.

I hope this makes it at least a little bit clearer.

> Another question here is in regards to tags. Similar to image's exif data, 
> these audio files can contain tags, and in the case of many formats (such 
> as Ogg Vorbis) this tag data can be relatively arbitrary. It would seem 
> then that I'm stuck with three ugly options:
> 
> 1. I can make an explicit reference in my new OggVorbisFileField for each 
> field that the user may care about in their model (ie title, artist) 
> similar to how it works with ImageField's height and width
> 
> 2. Instead of referencing each field, have an ugly "tags" field that 
> contains something like a pickle'd dictionary of key/value pairs
> 
> 3. Make an arbitrary set of key/value pairs in the DB through a many/many 
> relationship for each of the tags
> 
> The fields that I care about (title, artist, etc.) will already be stored 
> in my model that will contain the new OggVorbisField, so I'm wondering if 
> there's a best practice here that I should try to follow.

If the set of fields that you care about is a small one, and you
already have regular model fields for them, then personally, I'd
choose the first option. If you have any good reason to store all
metadata, then both options 2 and 3 make sense, although when it comes
to option 2, you shouldn't pickle dicts. Instead, if you're using
postgres, just use a HStoreField, or a JSONField; on other databases,
you can use one of the many JSON field implementations backed by a
simple TextField. Option 2 will be easier to implement and maintain
than option 3, I think, whereas option 3 is more “pure” in terms of
relational database design.

Good luck,

Michal

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


signature.asc
Description: Digital signature