Re:using HTTPHandler cause Django server side shows http 400 and Invalid HTTP_HOST header message

2017-04-10 Thread Zhao Lee
No, that would cause the following exception 


--- Logging error ---
Traceback (most recent call last):
  File 
"C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 
798, in _get_hostport
port = int(host[i+1:])
ValueError: invalid literal for int() with base 10: '//ezvideo.0letter.com'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File 
"C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\logging\handlers.py", 
line 1137, in emit
h = http.client.HTTPConnection(host)
  File 
"C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 
762, in __init__
(self.host, self.port) = self._get_hostport(host, port)
  File 
"C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\http\client.py", line 
803, in _get_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
http.client.InvalidURL: nonnumeric port: '//ezvideo.0letter.com'
Call stack:
  File "C:\Users\i\Documents\Tencent Files\2281570025\FileRecv\a.py", line 26, 
in 
logger.error('testing remote logging')
Message: 'testing remote logging'
Arguments: ()






在2017年04月11 02时25分, "Camilo Torres"写道:

Hi,
Try with this configuration instead:
_TARGET = 'http://192.168.8.100:8000'

Notice you missed http:// there.

--
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/m42PLb1N_yo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8a6fcb79-dbf6-44f1-9971-7da02af85f27%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/253674e7.d2.15b5ad2d9d6.Coremail.redstone-cold%40163.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django relationships and the admin page

2017-04-10 Thread Lachlan Musicman
On 11 April 2017 at 07:32, Liam H  wrote:

> Hi,
>
> I'm new to Django, programming, web apps, the whole lot. I've been working
> on an app for a while now, but I'm having trouble figuring out how to
> organise my models in an effective way. Im using Django 1.10 and Python 2.7.
>
> Here's a rough example of the structure I'm trying:
>
> class Site(models.Model):
> #...
> def __unicode__(self):
> return self.name
>
> class Image(models.Model):
> #...
> site = models.ForeignKey(Site, ...)
> def __unicode__(self):
> return self.name
>
> class Location(models.Model):
> #...
> site = models.ForeignKey(Site, ...)
> def __unicode__(self):
> return self.name
>
> class LocImage(models.Model):
> #...
> location = models.ForeignKey(Location, ...)
> def __unicode__(self):
> return self.name
>
>
>
> The idea is to have a site (like a castle or other area the user might
> want to visit), and then each site will have various Images like aerial
> photographs associated with it. Each site will also have various locations
> around it with multiple images associated with that location.
>
> So it works something like this:
>
> Site
>
> Images
>
> Location
>
> LocImages
>
>
>
> I've tried doing it this way, but I don't know how to get the admin page
> to show this, for one. I read a post that said that Django's admin page
> can't have nested related items like this, but I'm not sure if that's
> actually true. I was able to run migrations on this code when I removed the
> references to it in the admin page, but I don't know how to access the
> LocImages model in the API, like I can with the Location and Images models
> using something like "Site.objects.get(pk=2).location_set.get(id=2).
> locimage_set.all()".
>
> So, is this how I should be structuring the models? And if it works in the
> database is there any way to get this to show on a single page in the
> Django admin?
>
> The reason I decided to structure it this way is so each location can have
> multiple attributes that are all fields of the same model, making it easier
> to link them together in the templates.
>


Maybe this is what you are looking for?

https://docs.djangoproject.com/en/1.11/topics/db/models/#extra-fields-on-many-to-many-relationships

Where LocImages would be the equivalent to "Membership" in the eg?

Sounds like you are implementing the Dublin Core :)

L.

--
The most dangerous phrase in the language is, "We've always done it this
way."

- Grace Hopper

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


Re: django sample projects

2017-04-10 Thread Bledi
Hi Shahab, 

I am in a similar position like you. I strongly suggest you do the 
following 
tutorial: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django

Its made by Mozilla Developers and it is amazing!

Good luck!

On Monday, March 27, 2017 at 12:27:59 PM UTC-4, Shahab Emami wrote:
>
> hello 
>
> i have question:
> where can i find a few django sample projects?
> i have seen a few tutorials and courses but i don't now how 
> a real project should be.
> then i need to see a few sample django codes . 
>
> i now there are a lot of project in github but i can't use them.
> there are not the thing that i want they are reusable apps
> that i have to use them beside my own project but i want a whole 
> project.
> i want such project that i can run it in my computer by it's own.
>
> can you please help me .
> i am learning django for a year but i cant steel write program.
> i only can create some simple apps.
>
> i can create model , work with forms, templates, angular but still 
> nothing.
>
> i cant do a real project then i all of my trying are nothing.
> 
> thank for your help
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/d814a606-6dfc-41b7-8980-02b9f0efc731%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django relationships and the admin page

2017-04-10 Thread Liam H
Hi,

I'm new to Django, programming, web apps, the whole lot. I've been working 
on an app for a while now, but I'm having trouble figuring out how to 
organise my models in an effective way. Im using Django 1.10 and Python 2.7.

Here's a rough example of the structure I'm trying:

class Site(models.Model):
#...
def __unicode__(self):
return self.name

class Image(models.Model):
#...
site = models.ForeignKey(Site, ...)
def __unicode__(self):
return self.name

class Location(models.Model):
#...
site = models.ForeignKey(Site, ...)
def __unicode__(self):
return self.name

class LocImage(models.Model):
#...
location = models.ForeignKey(Location, ...)
def __unicode__(self):
return self.name



The idea is to have a site (like a castle or other area the user might want 
to visit), and then each site will have various Images like aerial 
photographs associated with it. Each site will also have various locations 
around it with multiple images associated with that location.

So it works something like this:

Site

Images

Location

LocImages 



I've tried doing it this way, but I don't know how to get the admin page to 
show this, for one. I read a post that said that Django's admin page can't 
have nested related items like this, but I'm not sure if that's actually 
true. I was able to run migrations on this code when I removed the 
references to it in the admin page, but I don't know how to access the 
LocImages model in the API, like I can with the Location and Images models 
using something like 
"Site.objects.get(pk=2).location_set.get(id=2).locimage_set.all()".

So, is this how I should be structuring the models? And if it works in the 
database is there any way to get this to show on a single page in the 
Django admin?

The reason I decided to structure it this way is so each location can have 
multiple attributes that are all fields of the same model, making it easier 
to link them together in the templates.

Any help would be appreciated, 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/f901927b-712b-49d7-bf38-1eb746806658%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to django and ORM. So a basic question about data inserts

2017-04-10 Thread Lachlan Musicman
--
The most dangerous phrase in the language is, "We've always done it this
way."

- Grace Hopper

On 11 April 2017 at 05:35, Cassium  wrote:

> Say I am collecting residence history and I allow the user to submit up to
> five previous addresses. I have a PEOPLE model and RESIDENCES model and
> anticipate a many-to-many relationship between. Back when I was working
> with Joomla I would have manages these models (well, tables) with a table
> in the middle called PEOPLE_RESIDENCES which would have also included the
> dates of that relationship. And I understand that I can do that with a
> model and the 'through' statement.
>
> But here is where I'm lost. When I get a form submitted from the user, how
> do I get all the correct rows written to the various tables. Assume for
> simplicity sake that I have a new person being submitted as follows
>
> PERSON
> --RESIDENCE 1, 2005-2008
> --RESIDENCE 2, 2008-2011
> --RESIDENCE 3, 2012-2016
>
> So I would need one new row on the PEOPLE table, three new rows on the
> PEOPLE_RESIDENCES table and up to three new rows on the RESIDENCES table.
> I'm lost on how the necessary rows are added to the PEOPLE_RESIDENCES
> table. Is there some sort of value returned from the create/insert
> statements or do I send the ORM a structured object which manages all of
> the INSERTS including the relatioinships? Or is there something else I have
> to do?
>
>
Have you read this part of the documentation? It describes exactly what you
need:

https://docs.djangoproject.com/en/1.11/topics/db/models/#extra-fields-on-many-to-many-relationships

With regard to "how do I get the correct record written to the right table"
you are putting the cart before the horse.

The whole idea of an ORM is to disappear that type of consideration
(despite it being exactly what *is* happening in the background).

In the example of the documentation, when you create a Group, it is "saved
to the correct table when you call the save() method (successfully)". When
you create a Person, it is also saved to the correct table when you call
the save() method.

When you create a Membership that links to both the Person and the Group,
it too is saved to the correct table when you call the save() method.

Cheers
L.

-- 
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/CAGBeqiPXxcm-OG8mD1PCo3%3Dx%2BmkUw1y5DthpQ-EOqAGios%3DQ8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


New to django and ORM. So a basic question about data inserts

2017-04-10 Thread Cassium
Say I am collecting residence history and I allow the user to submit up to 
five previous addresses. I have a PEOPLE model and RESIDENCES model and 
anticipate a many-to-many relationship between. Back when I was working 
with Joomla I would have manages these models (well, tables) with a table 
in the middle called PEOPLE_RESIDENCES which would have also included the 
dates of that relationship. And I understand that I can do that with a 
model and the 'through' statement.

But here is where I'm lost. When I get a form submitted from the user, how 
do I get all the correct rows written to the various tables. Assume for 
simplicity sake that I have a new person being submitted as follows

PERSON
--RESIDENCE 1, 2005-2008
--RESIDENCE 2, 2008-2011
--RESIDENCE 3, 2012-2016

So I would need one new row on the PEOPLE table, three new rows on the 
PEOPLE_RESIDENCES table and up to three new rows on the RESIDENCES table. 
I'm lost on how the necessary rows are added to the PEOPLE_RESIDENCES 
table. Is there some sort of value returned from the create/insert 
statements or do I send the ORM a structured object which manages all of 
the INSERTS including the relatioinships? Or is there something else I have 
to do?

-- 
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/2987a536-7d42-4440-ab56-e9a54326e4f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inheritance models from Django 1.8.2 to Django 1.11

2017-04-10 Thread Camilo Torres
Hi,
May be you can define your field usind "db_column":

manufact = models.ForeignKey(Manufacture, verbose_name=u'Manufacture', 
db_column='manufacture')

https://docs.djangoproject.com/en/1.11/ref/models/fields/#db-column

-- 
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/935b1fb4-5ee8-40d0-994c-fba20631dc88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


using HTTPHandler cause Django server side shows http 400 and Invalid HTTP_HOST header message

2017-04-10 Thread Camilo Torres
Hi,
Try with this configuration instead:
_TARGET = 'http://192.168.8.100:8000'

Notice you missed http:// there.

-- 
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/8a6fcb79-dbf6-44f1-9971-7da02af85f27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inheritance models from Django 1.8.2 to Django 1.11

2017-04-10 Thread Dmitriy Yusupov


Hello, I have the task of convert the project from django version 1.8.2 to 
version 1.11. Faced a problem with which I can not cope. That model of 
tables, which worked excellently in 1.8.2, stopped working in version 1.11, 
and falls out with an error:


core.CarModel.manufacture: (models.E006) The field 'manufacture' 
clashes with the field 'manufacture' from model 'core.page'.


Apparently this is due to the inheritance of models, since the project is 
old I can not fundamentally change the scheme of tables, please tell me how 
to get out of this situation.

Thank you in advance for your help.


I have reproduced the scheme of models, which works fine on 1.8.2 and stops 
working on 1.11:



# -*- coding:utf-8 -*-

from django.db import models

from django.contrib.contenttypes.models import ContentType



class InheritanceCastModel(models.Model):


real_type = models.ForeignKey(ContentType, editable=False)


def save(self, *args, **kwargs):

if not self.id:

self.real_type = self._get_real_type()

super(InheritanceCastModel, self).save(*args, **kwargs)


def _get_real_type(self):

return ContentType.objects.get_for_model(type(self))


def cast(self):

return self.real_type.get_object_for_this_type(pk=self.pk)


class Meta:

abstract = True



class Page(InheritanceCastModel):

title = models.CharField(max_length=512, verbose_name=u'Title', 
blank=True)



class Manufacture(Page):

ru_title = models.CharField(max_length=128, verbose_name=u'RU 
Title')



class CarModel(Page):

manufacture = models.ForeignKey(Manufacture, 
verbose_name=u'Manufacture')

ru_title = models.CharField(max_length=64, verbose_name=u'RU Title')


this question on 
stackoverflow: 
http://stackoverflow.com/questions/43327543/inheritance-models-from-django-1-8-2-to-django-1-11

-- 
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/7c9da822-cfda-4934-b653-9630b5ed2867%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Run model check with Django 1.11 as deployment check only?

2017-04-10 Thread Matthew Pava
Hi Carsten,
I wish I could provide more help.  I had no idea there was a check method or a 
system check framework until your message.
https://docs.djangoproject.com/en/1.11/topics/checks/

I have learned something new.

One thing mentioned in the topic guide above is this:
If you need to run system checks on your deployment server, trigger them 
explicitly using check.
The check command documentation is here:
https://docs.djangoproject.com/en/1.11/ref/django-admin/#django-admin-check

Hoping that helps,
Matthew



-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Monday, April 10, 2017 11:08 AM
To: django-users@googlegroups.com
Subject: Re: Run model check with Django 1.11 as deployment check only?

Hi Matthew,

Am 10.04.2017 um 15:51 schrieb Matthew Pava:
> I would argue that your code should be able to run successfully with an empty 
> database.
> I would change your assignment of maxID to this:
> maxID = cls.objects.aggregate(Max('id'))['id__max'] or 0

Normally, I would happily agree. However, in this case, the Status objects are 
static and never supposed to change (without reloading the entire project).

Based on this assumption, all that I want is a constant `MAX_ID` that reflects 
the largest possible ID of the existing Status objects, so that frequent access 
to it does not each time inflict a database access.

Therefore, my older code just had a module global variable like this:

MAX_ID = Status.objects.aggregate(Max('id'))['id__max']

This is simple and "usually" works well, but note that it fails whenever an 
empty database is initialized, that is, whenever the very first migration is 
run (in which case the above global code is run even before the Status table 
exists), which in turn happens when the project is deployed to a new site or 
whenever the test database is populated.

In summary:

Code that is run at load time (such as the global `MAX_ID = ...` above) or 
close to load time (such as the Django system checks) cannot access the 
database if the database is only populated at a later time, as is the case with 
initial migrations for new deployments or tests databases.

What I would like to check, though, is the production or development databases; 
thus my question for marking the model check „for deployment only“.

Best regards,
Carsten

--
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/acc78088-9d44-97ee-915a-a9ad40974ff8%40cafu.de.
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/4ab43916b5fd421c877fe35ba7bc5ae9%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


using HTTPHandler cause Django server side shows http 400 and Invalid HTTP_HOST header message

2017-04-10 Thread Philip Lee


I also posted The question here 
http://stackoverflow.com/questions/43185804/using-httphandler-cause-django-server-side-shows-http-400-and-invalid-http-host
 


I am using HTTPHandler 
 to 
send logging messages to a Django Web server with The following code,

import loggingimport logging.handlers

logger = logging.getLogger(__name__)

_TARGET = '192.168.8.100:8000'
_PATH = '/VideoParser/lYYDownloaderClientLog/'

sh = logging.handlers.HTTPHandler(_TARGET, _PATH)

logger.addHandler(sh)
logger.error('testing remote logging')

but The server side shows http 400 and Invalid HTTP_HOST header message 
like this

Invalid HTTP_HOST header: '192.168.8.100:8000,192.168.8.100'. The domain 
name pr ovided is not valid according to RFC 1034/1035. [05/Apr/2017 
10:43:14] "GET /VideoParser/lYYDownloaderClientLog/?relativeCreated 
=117.00654029846191&thread=5468&levelname=ERROR&exc_info=None&exc_text=None&proc
 
ess=8920&filename=a.py&msecs=39.52503204345703&stack_info=None&levelno=40&proces
 
sName=MainProcess&msg=testing+remote+logging&module=a&threadName=MainThread&line
 
no=26&created=1491360192.039525&funcName=%3Cmodule%3E&args=%28%29&name=
*main*& 
pathname=C%3A%5CUsers%5Ci%5CDocuments%5CTencent+Files%5C2281570025%5CFileRecv%5C
 
a.py HTTP/1.1" 400 68137

while request from browser with url

http://192.168.8.100:8000/VideoParser/lYYDownloaderClientLog/?filename=log55.p%20y&levelno=40&relativeCreated=88.00482749938965&funcName=%3Cmodule%3E&thread=7144%20&stack_info=None&module=log55&args=%28%29&exc_text=None&pathname=D%3A%5CBaiduYun%20Download%5C%E7%BC%96%E7%A8%8B%5CPython%5Clog55.py&levelname=ERROR&msecs=668.0548%20191070557&threadName=MainThread&process=6664&name=root&lineno=34&msg=yahoo+Serve%20r+Exception&exc_info=None&processName=MainProcess&created=1491225161.6680548

could actually send a good request to The server , The server shows The 
following in this case

--- '], 'threadName': ['MainThread'], 'filename': ['log55.p y'], 'p
athname': ['D:\\BaiduYun Download\\编程\\Python\\log55.py'], 
'relativeCreated':['88.00482749938965']}>[05/Apr/2017 10:45:26] "GET 
/VideoParser/lYYDownloaderClientLog/?filename=log55.
p%20y&levelno=40&relativeCreated=88.00482749938965&funcName=%3Cmodule%3E&thread=
7144%20&stack_info=None&module=log55&args=%28%29&exc_text=None&pathname=D%3A%5CB
aiduYun%20Download%5C%E7%BC%96%E7%A8%8B%5CPython%5Clog55.py&levelname=ERROR&msec
s=668.0548%20191070557&threadName=MainThread&process=6664&name=root&lineno=34&ms
g=yahoo+Serve%20r+Exception&exc_info=None&processName=MainProcess&created=149122
5161.6680548 HTTP/1.1" 200 27

so what's wrong with my code using HTTPHandler 
 to 
send logging messages to a Django Web server ?

As I have tested: If I pass the IP address of my web server to the host 
parameter of HTTPHandler, the server side would show http 400 and Invalid 
HTTP_HOST header message, there are also exceptions , pasted here 
https://bpaste.net/show/f2d2e64e7a7e , while if I pass the domain name 
instead, then the view function works as expected . so would it be a bug 
within HTTPHandler?

related code For debug

django-test\LYYDownloaderServer\VideoParser\urls.py

from django.conf.urls import urlfrom . import views
app_name = 'VideoParser'
urlpatterns = [
url(r'lYYDownloaderClientLog.+',views.lYYDownloaderClientLog, 
name='lYYDownloaderClientLog')]

django-test\LYYDownloaderServer\VideoParser\views.py

def lYYDownloaderClientLog(request):
print('---', request.GET)
return HttpResponse("")  # The server *successfully* processed the request 
and is not returning any content.

-- 
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/2e383515-3e78-4f6a-8681-0eb7858251f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Run model check with Django 1.11 as deployment check only?

2017-04-10 Thread Carsten Fuchs

Hi Matthew,

Am 10.04.2017 um 15:51 schrieb Matthew Pava:

I would argue that your code should be able to run successfully with an empty 
database.
I would change your assignment of maxID to this:
maxID = cls.objects.aggregate(Max('id'))['id__max'] or 0


Normally, I would happily agree. However, in this case, the Status objects are 
static and never supposed to change (without reloading the entire project).


Based on this assumption, all that I want is a constant `MAX_ID` that reflects 
the largest possible ID of the existing Status objects, so that frequent access 
to it does not each time inflict a database access.


Therefore, my older code just had a module global variable like this:

MAX_ID = Status.objects.aggregate(Max('id'))['id__max']

This is simple and "usually" works well, but note that it fails whenever an 
empty database is initialized, that is, whenever the very first migration is run 
(in which case the above global code is run even before the Status table 
exists), which in turn happens when the project is deployed to a new site or 
whenever the test database is populated.


In summary:

Code that is run at load time (such as the global `MAX_ID = ...` above) or close 
to load time (such as the Django system checks) cannot access the database if 
the database is only populated at a later time, as is the case with initial 
migrations for new deployments or tests databases.


What I would like to check, though, is the production or development databases; 
thus my question for marking the model check „for deployment only“.


Best regards,
Carsten

--
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/acc78088-9d44-97ee-915a-a9ad40974ff8%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.11 doesn't work well behind pgBouncer

2017-04-10 Thread Sergey Fursov
Accepted ticket - https://code.djangoproject.com/ticket/28062

2017-04-06 22:30 GMT+03:00 Sergey Fursov :

> Hi!
>
> In our application stack we connect from our web/background workers to
> postgres database through dedicated pgBouncer service.
> pgBouncer use transaction pooling
> Connections work in autocommit mode.
>
> After upgrading to 1.11 version with new server-side cursors for iterator
> method, many of our DB requests started failing with "Cursor
> _django_curs_ does not exist'.
>
> According to pgBouncer docs, it doesn't support using WITH HOLD cursors
> with transaction pooling mode. But it doesn't seems reasonable to run
> pgBouncer in session pooling mode, we can just switch to direct persistent
> connections to postgres DB. On the other hand in this case we have to
> increase minimum number of DB connection to number of our workers (from 5
> to ~30) to prevent blocking blocking requests. And this is violate
> recommendation to have (core_count * 2) + effective_spindle_count max
> connections to DB.
>
> So is there some recommendations how efficiently work with postgres DB in
> django 1.11?
>
> Thanks,
> Sergey
>
>
>

-- 
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-zk-ACbEWXYVDXW-N%2B6eDBm1j-7L8M24D9tK1E0OOzSHMUJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Yet Another Can't get static files to show up in shared linux website on Godaddy

2017-04-10 Thread Camilo Torres
Hi
You may want to review:
https://docs.djangoproject.com/en/1.11/howto/static-files/deployment/

You may also want to make sure your server supports wsgi deployments:
https://docs.djangoproject.com/en/1.11/howto/deployment/

-- 
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/9119cbe3-bac0-4408-8a50-784b0ef8ded0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


what do i have to do first

2017-04-10 Thread Camilo Torres
Hi,

Read the First Steps section:

https://docs.djangoproject.com/en/1.11/

-- 
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/e9791e60-8340-47a3-9bc0-78f58912c8d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: JsonField icontains filter generates invalid SQL

2017-04-10 Thread Simon Charette
Hello there,

I'm not sure where you determined the SQL that caused the error but I'm 
pretty
sure this was caused by "my_model"."data" -> 'name' not being wrapped in a
parenthesis before the ::text cast.

This has been fixed in Django 1.11[0].

Cheers,
Simon

[0] 
https://github.com/django/django/commit/2eb7d6e6d41480f21305fc6abe2f1a443491ddec#diff-57ceaae67721b3f8d5729222c032af8eR109

Le dimanche 9 avril 2017 21:48:57 UTC-4, cofiem a écrit :
>
> The issue I'm facing is similar to these tickets: 
>
>- Case insensitive lookups on JSONField nested values 
>https://code.djangoproject.com/ticket/27693
>- Use the ->> operator when filtering builtin text lookups on 
>JSONField keys https://code.djangoproject.com/ticket/27257
>- Document how to do a substring search in JSONField 
>https://code.djangoproject.com/ticket/26511
>
> I have a JsonField in a model
>
> data = JSONField(null=True, blank=True)
>
>
> It contains this json:
>
> {"name":"Hello"}
>
>
> My filter is:
>
> models.MyModel.objects.filter(data__name__icontains='el')
>
>
> I expect the query to return the objects that have json where the "name" 
> contains 'el' (case-insensitive).
>
> Instead, I get this:
>
> ProgrammingError at /url/
>> function upper(jsonb) does not exist LINE 1: ... 
>> UPPER("my_model"."data"... 
>> HINT: No function matches the given name and argument types. You might 
>> need to add explicit type casts.
>
>
> The SQL that causes the error is
>
>  WHERE UPPER(("my_model"."data" -> 'name')::text) LIKE UPPER(%el%)
>
>
> The working SQL is (note added quotes around LIKE text):
>
> WHERE UPPER(("my_model"."data" -> 'name')::text) LIKE UPPER('%el%')
>
>
> Is there a fix for this? Am I missing something?
> Any help would 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/a4cab7dd-027d-4eea-b55c-55348b24b78e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


what do i have to do first

2017-04-10 Thread Cyprus Carolyne
 I am new to this platform, anyone help me find out how to start the 
journey,

I have windows ten, what do i have to install on my pc to get started?

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/90c8b6d1-cf99-4021-ac60-f27bbe597bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Run model check with Django 1.11 as deployment check only?

2017-04-10 Thread Matthew Pava
I would argue that your code should be able to run successfully with an empty 
database.
I would change your assignment of maxID to this:
maxID = cls.objects.aggregate(Max('id'))['id__max'] or 0

I often add the 'or 0' to my aggregates because I never really know if my 
aggregate will deal with an empty QuerySet.

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Monday, April 10, 2017 8:38 AM
To: Django users
Subject: Run model check with Django 1.11 as deployment check only?

Dear Django group,

with Django 1.10, I used a model check like this:


class Status(models.Model):
 id = models.AutoField(primary_key=True)
 MAX_ID = 38
 text   = models.CharField(max_length=20, blank=True)

 @classmethod
 def check(cls, **kwargs):
 errors = super(Status, cls).check(**kwargs)
 maxID = cls.objects.aggregate(Max('id'))['id__max']

 # The app sometimes computes histograms,
 # so make sure that the Status.id values are as expected.
 if cls.MAX_ID != maxID:
 errors.append(checks.Warning(...))

 return errors


This used to work well, considering that up to Django 1.10, this and other 
checks weren't run along with `manage.py test`.
Now that Django 1.11 runs checks also with tests, the above check obviously 
fails, because at the time the checks are run, the test database is still 
empty, yielding `maxID = None`.

Declaring the above check as “at deployment only” seems to be a good 
resolution, but is it possible to do that with a model (base-class based) check?

Best regards,
Carsten

--
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/03fdc69d-0ac8-b266-5533-d00301f9fdce%40cafu.de.
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/5c5d952d3e7e4147963f196a64722d3b%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Run model check with Django 1.11 as deployment check only?

2017-04-10 Thread Carsten Fuchs

Dear Django group,

with Django 1.10, I used a model check like this:


class Status(models.Model):
id = models.AutoField(primary_key=True)
MAX_ID = 38
text   = models.CharField(max_length=20, blank=True)

@classmethod
def check(cls, **kwargs):
errors = super(Status, cls).check(**kwargs)
maxID = cls.objects.aggregate(Max('id'))['id__max']

# The app sometimes computes histograms,
# so make sure that the Status.id values are as expected.
if cls.MAX_ID != maxID:
errors.append(checks.Warning(...))

return errors


This used to work well, considering that up to Django 1.10, this and other 
checks weren't run along with `manage.py test`.
Now that Django 1.11 runs checks also with tests, the above check obviously 
fails, because at the time the checks are run, the test database is still empty, 
yielding `maxID = None`.


Declaring the above check as “at deployment only” seems to be a good resolution, 
but is it possible to do that with a model (base-class based) check?


Best regards,
Carsten

--
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/03fdc69d-0ac8-b266-5533-d00301f9fdce%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Yet Another Can't get static files to show up in shared linux website on Godaddy

2017-04-10 Thread Anthony Percy
Hi all,
Sorry to ask this question but I cant get my static files in Mezzanine to 
show up on a Godaddy hosted site e.g http://www.murraybridge.co
I have had to use "pip install flup" and "pip install django-fastcgi-server" 
as Godaddy seems to have the fcgi module active on the apache webserver 
which I understand is now deprecated.
The .htaccess file is in ~/public_html is ;

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mezproject.fcgi/$1 [QSA,L]

My "mezproject.fcgi" file in ~/public_html is;

*#!/home/vk2acp/code/mez/bin/python*
*import sys, os*
*# Add a custom Python path.*
*sys.path.insert(0, "/home/vk2acp/code/mezproject")*
*# Switch to the directory of your project. (Optional.)*
*os.chdir("/home/vk2acp/code/mezproject")*
*# Set the DJANGO_SETTINGS_MODULE environment variable.*
*os.environ['DJANGO_SETTINGS_MODULE'] = "mezproject.settings"*
*from django_fastcgi.servers.fastcgi import runfastcgi*
*from django.core.servers.basehttp import get_internal_wsgi_application*
*wsgi_application = get_internal_wsgi_application()*
*runfastcgi(wsgi_application, method="prefork", daemonize="false", 
minspare=1, maxsp*
*are=1, maxchildren=1)*

The "static" dir exists in the mezproject dir after I did "python manage.py 
collectstatic"
I have tried copying  static dir to the public_html dir with no effect.
Obviously I cant add the "Alias" directive as I have no control over the 
http.conf file.
It seems a pity to get this far and run into this brick wall!!!
Do I have to run the whole mez project from the public_html dir???
Any suggestions?

Best Regards

Anthony

-- 
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/a38ab714-1903-4c92-a5d0-0b1455c29a75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM for structured Logs

2017-04-10 Thread guettli
Thank you for sharing. 

Yes, the model is not difficult, that's why everybody helps himself up to 
now. Maybe this is the best solution and there is not much in common.

The things which are in common (ORM, Admin-Interface) are already provided 
by django.

It's just a bit of glue-code to get it working.

Again, thank you for sharing your solution.

Regards,
  Thomas

Am Samstag, 8. April 2017 18:58:59 UTC+2 schrieb Scot Hacker:
>
> On Tuesday, April 4, 2017 at 5:18:42 AM UTC-7, guettli wrote:
>>
>> In the past I was told: Don't store logs in the database.
>>
>
> For general purposes, I agree with this. Logging is a python standard, 
> logs can be verbose, logrolling solutions are well established (and built 
> in), etc. However, there are certain situations or activities where 
> database logging makes sense, most likely *in addition to* standard logging 
> rather than instead of. In one of my projects, half a dozen non-technical 
> managers need the ability to track certain types of actions (related to 
> account activations at a school). For this, I developed a simple ORM 
> logging solution that lets those managers search and filter these special 
> logs in the Django admin. 
>
> It's not something that really deserves to be its own project, IMO - just 
> a typical thing a dev might do in Django to satisfy an institutional need. 
> But I've put my solution in this gist, in case its helpful:
>
> https://gist.github.com/shacker/05bc1de527a2d7412de361ac659aecde
>  
>

-- 
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/e20e56bd-e82c-4027-afa2-bc08ca35c00b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: password_reset error

2017-04-10 Thread sarfaraz ahmed
Thanks... I tried... everythings...

It worked..




On 10 April 2017 at 13:21, ludovic coues  wrote:

> That should be all the information needed to fix the problem :)
>
> TL:DR:
> use `{{ protocol }}://{{ domain }}{% url 
> 'user_management:password_reset_confirm'
> uidb64=uid token=token %}` on line 5 of your email template.
>
> Long answer:
> The amount of information you provided last time would have been enough
> for my gut feeling, which is the same as the tl;dr. But I needed pretty
> much everything you have given here to be sure :)
>
> The traceback is pretty much useless to finding the origin of the error
> with template. That's why there is a Template error section. In you case,
> as you can guess, django try to find a named url but get nothing. To know
> why, we need to dive into the source and the traceback will be our guide.
>
> Starting with the end, the two last function, _reverse_with_prefix and
> reverse are internal to django routing. I let them alone.
> Next one live in defaulttags and cause issue at a call to reverse. I
> believe that it's the url template tag. I'm mainly curious about the
> current_app argument in reverse. I know that url name can take the form
> "app:name". In your case, that would be 
> "user_management:password_reset_confirm".
> The current_app argument come from the context property of the tag object
> [1].
> When looking at the traceback, two things stand out for the few followings
> lines. They all live in the template module and they all have a context
> argument. So I skip them.
> Next stop is send_mail in contrib/auth/forms.py. We get out of the
> template module but we still have the context argument, which disappear in
> the following line. Look like a good place to find the value of context.
> Oops, look like I was off by one. send_mail take the context argument from
> save, same file. The call to send_mail taking 4 lines, the context argument
> have been stripped from the line in the traceback. But the context is
> defined in the save method [2].
> You will notice it's a simple dict without a request key. But if you have
> looked at how the URL tag define the current_app, you'll notice it make use
> of the request key of the context.
>
> That's the root of your problem. Email are generated without a request.
> And without a request, you need to specify the full name of url, as you
> don't have access to the current_app. By the way, current_app is matching
> app_name you specify in your URL.py file. That's why I asked the full
> urls.py the first time.
>
> I hope I'm clear and that will help you :)
> All you need to remember is that sometimes, you need to specify the full
> name of an url.
>
> [1] https://github.com/django/django/blob/1.10.5/django/
> template/defaulttags.py#L428-L434
> [2] https://github.com/django/django/blob/1.10.5/django/
> contrib/auth/forms.py#L278-L286
>
> 2017-04-10 7:09 GMT+02:00 sarfaraz ahmed :
>
>> Hello Friends,
>>
>> I have attempted to make CustomUser model in django to signin using email.
>>
>> I am using password_reset view when I am getting this error. I checked
>> password_reset view and found i am getting error during this line
>>
>> form.save(**opts)
>>
>> in password_reset
>>
>> 
>> 
>> 
>> URL.py
>> 
>> 
>> from django.conf.urls import url,include
>>
>> from django.conf.urls import url
>> from django.conf.urls import include
>>
>>
>> from . import views
>> from views import *
>>
>>
>> from django.contrib.auth import views as auth_views
>> from django.contrib.auth.views import password_reset,password_reset_done
>>
>>
>> app_name ="user_management"
>>
>> urlpatterns =   [
>> url(r'^login/',login,name='login'),
>> url(r'^auth_view/',auth_view, name='auth_view'),
>> url(r'^signup_success/',signup
>> _success,name='signup_success'),
>> url(r'^signup/',signup,name='signup'),
>> url(r'^logout/',logout,name='logout'),
>> url(r'^signup_confirm/(?P> vation_key>\w+)',signup_confirm,name='signup_confirm'),
>> url(r'^account_info/',account_info,name='account_info'),
>> url(r'^user_profile/',user_profile,name='user_profile'),
>> url(r'^address/',address,name='address'),
>> url(r'^change_password/',chang
>> e_password,name='change_password'),
>> url(r'^add_address/',add_address,name='add_address'),
>> url(r'^edit_address/(?P\d+
>> )',edit_address,name='edit_address'),
>> url(r'^delete_address/(?P\
>> d+)',delete_address,name='delete_address'),
>> url(r'^change_password/',chang
>> e_password,name='change_password'),
>> url(r'^

Re: Displaying multiple images in a blog post

2017-04-10 Thread ludovic coues
I would be a bit wary of a django blog making use of template tag.

Anyway, I believe your code should be more like that: {{
post.images[2].image.url }}.

Personally, I would delegate fetching the url to another part of the code.
Something like one endpoint would return a list of images. A piece of
javascript query that list and store it. When the user press a button,
put an image tag at the cursor position.

Or I would write a custom tag which would be used like {% image 2 %}
and would return the url of the second image of the current post.

2017-04-10 6:29 GMT+02:00 HBat :
> (I don't know what happened to original post.)
>
> Suppose I have two images, "\media\images\image1.jpg" and
> "\media\images\image2.jpg". I want to display them in a blog post that I've
> written. I thought I should create a model for images but with multiple
> images I cannot figure out how to add them to the body of my blog post. It
> seems like I have to write full locations to the body like this:
>
> 
>
> instead of something like this:
>
> 
>
> I prefer a method like the latter one.
>
> Here is my app structure:
> # models.py:
> class Post(models.Model):
> title = models.CharField(max_length=250)
> body = models.TextField()
> slug = models.SlugField(max_length=250)
> publish = models.DateTimeField(default=timezone.now)
>
> class Images(models.Model):
> post = models.ForeignKey(Post, default=None, related_name='images')
> description = models.TextField()
> image = models.ImageField()
>
>
> # views.py:
> def post_detail_view(request, year, month, day, postslug):
> post = get_object_or_404(Post,
>  slug=postslug,
>  publish__year=year,
>  publish__month=month,
>  publish__day=day
>  )
> return render(request=request,
>   template_name='blogapp/post/detail.html',
>   context={'post': post})
>
>
>
>
>
> # detail.html:
> {% extends "blogapp/base.html" %}
> {% block title %}{{ post.title }}{% endblock %}
> {% block content %}
> {{ post.title }}
> {{ post.body|safe }}
> {% endblock %}
>
>
>
> post.body = """
> Example blog post
>   Here is some text. And image for this part:
>/>
>   Here is some other text and image for this part:
>/>
>   I'm ending my blog post 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/2f098a0a-d711-44af-b22a-058447872f22%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Ludovic Coues
+33 6 14 87 43 42

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


Re: password_reset error

2017-04-10 Thread ludovic coues
That should be all the information needed to fix the problem :)

TL:DR:
use `{{ protocol }}://{{ domain }}{% url
'user_management:password_reset_confirm'
uidb64=uid token=token %}` on line 5 of your email template.

Long answer:
The amount of information you provided last time would have been enough for
my gut feeling, which is the same as the tl;dr. But I needed pretty much
everything you have given here to be sure :)

The traceback is pretty much useless to finding the origin of the error
with template. That's why there is a Template error section. In you case,
as you can guess, django try to find a named url but get nothing. To know
why, we need to dive into the source and the traceback will be our guide.

Starting with the end, the two last function, _reverse_with_prefix and
reverse are internal to django routing. I let them alone.
Next one live in defaulttags and cause issue at a call to reverse. I
believe that it's the url template tag. I'm mainly curious about the
current_app argument in reverse. I know that url name can take the form
"app:name". In your case, that would be
"user_management:password_reset_confirm". The current_app argument come
from the context property of the tag object [1].
When looking at the traceback, two things stand out for the few followings
lines. They all live in the template module and they all have a context
argument. So I skip them.
Next stop is send_mail in contrib/auth/forms.py. We get out of the template
module but we still have the context argument, which disappear in the
following line. Look like a good place to find the value of context.
Oops, look like I was off by one. send_mail take the context argument from
save, same file. The call to send_mail taking 4 lines, the context argument
have been stripped from the line in the traceback. But the context is
defined in the save method [2].
You will notice it's a simple dict without a request key. But if you have
looked at how the URL tag define the current_app, you'll notice it make use
of the request key of the context.

That's the root of your problem. Email are generated without a request. And
without a request, you need to specify the full name of url, as you don't
have access to the current_app. By the way, current_app is matching
app_name you specify in your URL.py file. That's why I asked the full
urls.py the first time.

I hope I'm clear and that will help you :)
All you need to remember is that sometimes, you need to specify the full
name of an url.

[1]
https://github.com/django/django/blob/1.10.5/django/template/defaulttags.py#L428-L434
[2]
https://github.com/django/django/blob/1.10.5/django/contrib/auth/forms.py#L278-L286

2017-04-10 7:09 GMT+02:00 sarfaraz ahmed :

> Hello Friends,
>
> I have attempted to make CustomUser model in django to signin using email.
>
> I am using password_reset view when I am getting this error. I checked
> password_reset view and found i am getting error during this line
>
> form.save(**opts)
>
> in password_reset
>
> 
> 
> 
> URL.py
> 
> 
> from django.conf.urls import url,include
>
> from django.conf.urls import url
> from django.conf.urls import include
>
>
> from . import views
> from views import *
>
>
> from django.contrib.auth import views as auth_views
> from django.contrib.auth.views import password_reset,password_reset_done
>
>
> app_name ="user_management"
>
> urlpatterns =   [
> url(r'^login/',login,name='login'),
> url(r'^auth_view/',auth_view, name='auth_view'),
> url(r'^signup_success/',signup_success,name='signup_
> success'),
> url(r'^signup/',signup,name='signup'),
> url(r'^logout/',logout,name='logout'),
> url(r'^signup_confirm/(?P\w+)',signup_
> confirm,name='signup_confirm'),
> url(r'^account_info/',account_info,name='account_info'),
> url(r'^user_profile/',user_profile,name='user_profile'),
> url(r'^address/',address,name='address'),
> url(r'^change_password/',change_password,name='change_
> password'),
> url(r'^add_address/',add_address,name='add_address'),
> url(r'^edit_address/(?P\d+)',edit_address,name='edit_
> address'),
> url(r'^delete_address/(?P\d+)',delete_address,name='
> delete_address'),
> url(r'^change_password/',change_password,name='change_
> password'),
> url(r'^email_test/',email_test,name='email_test'),
> url(r'^password_reset/$', auth_views.password_reset,{'
> post_reset_redirect':'/password_reset/done','template_name':'user_
> management/password_reset.html','email_template_name':'
> user_management/password_reset