Re: Search Field Problem

2009-07-21 Thread PanFei
may I have your version of django ?

On Tue, Jul 21, 2009 at 4:49 PM, Harish  wrote:

>
> Hi Friends,
>
> Just refer the sample code below.
>
> My problem is I am referring a Dependant models field in
> 'search_field'
> it is working correctly but when i delete a record from 'Dept' name
> from Dept Model
> the Search for the firstname is not working..
> For example
>
> The following data is displayed in the Employee Model
>
> Employee
> FirstName   |  Last Name  |  Dept   |
> -
> AAABBB   Sales
> BBBCCC|  Purchase
>
> Dept
> DeptName |  Employee Name   |   Other Detail
> 
> Sales   AAA None
> PurchaseBBB None
>
> In the above example (data) if I Search for Employee 'AAA'
> It produces the result. But When I delete the  'Purchase' record
> from 'Dept' Table, and then  Search 'AAA' in 'Employee' Table
> It is not displaying the Record. (The record exists in the list)
>
> I want to display the records of Employee when there is no record
> exist in the Dept Model with Dept as None
>
> # Code Snippet
> class Employee(models.Model):
>   firstname = models.CharField(maxlength=80)
>   last_name = models.CharField(maxlength=80)
>   salary = models.DecimalField()
>
>   def __str__  (self):
>   return self.firstname
>
>   def getdept(self):
>try:
>dept = Dept.objects.get(pk=self.pk)
>except Dept.DoesNotExist:
>dept = Dept()
>return dept.dept_name
>
>list_display = ('firstname  ','lastname','getdept')
>search_fields = ['firstname','lastname','Dept__dept_name']
>
>
>
> class Dept(models.Model):
>   dept_name = models.CharField(maxlength=80)
>   empName = models.OneToOneField(Employee, )
>   otherDetails = models.TextField()
>
>  def __str__   (self):
>   return self.dept_name
>
>  list_display = ('dept_name')
>  search_fields = ['dept_name']
>
>
>
> Kindly reply if anyone has solution to this??
>
>
> Regards
> Harish Bhat
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Search Field Problem

2009-07-21 Thread PanFei
oh my god ,I begin studying django  by using 1.02 



On Tue, Jul 21, 2009 at 6:06 PM, Harish  wrote:

>
> The Django Version I am using is
> '0.97-pre-SVN-7049'
>
>
> On Jul 21, 2:56 pm, PanFei  wrote:
> > may I have your version of django ?
> >
> > On Tue, Jul 21, 2009 at 4:49 PM, Harish  wrote:
> >
> > > Hi Friends,
> >
> > > Just refer the sample code below.
> >
> > > My problem is I am referring a Dependant models field in
> > > 'search_field'
> > > it is working correctly but when i delete a record from 'Dept' name
> > > from Dept Model
> > > the Search for the firstname is not working..
> > > For example
> >
> > > The following data is displayed in the Employee Model
> >
> > > Employee
> > > FirstName   |  Last Name  |  Dept   |
> > > -
> > > AAABBB   Sales
> > > BBBCCC|  Purchase
> >
> > > Dept
> > > DeptName |  Employee Name   |   Other Detail
> > > 
> > > Sales   AAA None
> > > PurchaseBBB None
> >
> > > In the above example (data) if I Search for Employee 'AAA'
> > > It produces the result. But When I delete the  'Purchase' record
> > > from 'Dept' Table, and then  Search 'AAA' in 'Employee' Table
> > > It is not displaying the Record. (The record exists in the list)
> >
> > > I want to display the records of Employee when there is no record
> > > exist in the Dept Model with Dept as None
> >
> > > # Code Snippet
> > > class Employee(models.Model):
> > >   firstname = models.CharField(maxlength=80)
> > >   last_name = models.CharField(maxlength=80)
> > >   salary = models.DecimalField()
> >
> > >   def __str__  (self):
> > >   return self.firstname
> >
> > >   def getdept(self):
> > >try:
> > >dept = Dept.objects.get(pk=self.pk)
> > >except Dept.DoesNotExist:
> > >dept = Dept()
> > >return dept.dept_name
> >
> > >list_display = ('firstname  ','lastname','getdept')
> > >search_fields = ['firstname','lastname','Dept__dept_name']
> >
> > > class Dept(models.Model):
> > >   dept_name = models.CharField(maxlength=80)
> > >   empName = models.OneToOneField(Employee, )
> > >   otherDetails = models.TextField()
> >
> > >  def __str__   (self):
> > >   return self.dept_name
> >
> > >  list_display = ('dept_name')
> > >  search_fields = ['dept_name']
> >
> > > Kindly reply if anyone has solution to this??
> >
> > > Regards
> > > Harish Bhat
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN: Django 1.1 released!

2009-07-29 Thread PanFei
i will try it

On Wed, Jul 29, 2009 at 3:18 PM, Daniel Roseman wrote:

>
> On Jul 29, 7:23 am, James Bennett  wrote:
> > Tonight we're extremely proud to announce the release of Django 1.1,
> > the latest major milestone in Django's development.
> >
> > To learn about the new release:
> >
> > * Blog post:http://www.djangoproject.com/weblog/2009/jul/29/1-point-1/
> > * Release notes:http://docs.djangoproject.com/en/dev/releases/1.1/
> > * Download:http://www.djangoproject.com/download/
> >
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> Well done, guys.
> --
> DR.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: the parameters of the self-defined tags

2009-08-26 Thread PanFei
Thank you very much , I got it

On Wed, Aug 26, 2009 at 6:07 PM, Daniel Roseman wrote:

>
> On Aug 26, 6:55 am, Apple  wrote:
> > hi , now I want to pass a parameter named user (user is a instance of
> > User) to the self_defined tags,could I do this ? I think the passed
> > parameter are all strings , is there a way to get its real type ?
> > thank you for your replying !
>
> You can use the template.Variable() class to access the real variable
> referenced the name you pass to the tag. See
>
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#passing-template-variables-to-the-tag
> --
> DR.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to not delete Image files

2009-12-10 Thread PanFei
Hi all, I have a model that use ImageField , now i want to delete a
recorder from the database,but after call delete() my the file is also
deleted ! i think i should override some method ,but where it
is ,looking forward for you reply ,thank you .

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: how to not delete Image files

2009-12-10 Thread PanFei
Ps : I use the model in django admin .

On Dec 11, 3:02 pm, PanFei  wrote:
> Hi all, I have a model that use ImageField , now i want to delete a
> recorder from the database,but after call delete() my the file is also
> deleted ! i think i should override some method ,but where it
> is ,looking forward for you reply ,thank you .

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: how to not delete Image files

2009-12-10 Thread PanFei
hi all,I have solve the problem ,I custom a Storage class and assign it to
the ImageField , then OK!

On Fri, Dec 11, 2009 at 3:16 PM, Xia Kai(夏恺)  wrote:

> Hope this link would be of use to you:
>
>
> http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
>
>
> Xia Kai(夏恺)
> xia...@gmail.com
> http://blog.xiaket.org
>
> ------
> From: "PanFei" 
> Sent: Friday, December 11, 2009 3:02 PM
> To: "Django users" 
> Subject: how to not delete Image files
>
> > Hi all, I have a model that use ImageField , now i want to delete a
> > recorder from the database,but after call delete() my the file is also
> > deleted ! i think i should override some method ,but where it
> > is ,looking forward for you reply ,thank you .
> >
>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




how to get all the context variable name in a template

2010-03-27 Thread PanFei
hi all, i want to know if there is a way to get all the context
variable (name) in a template.

for example :

I use render_to_response(template, {}
context_instance=RequestContext(request)) to return a response .but I
really do not know the context_instance=RequestContext(request) put a
user object in the template context ! oh my god ,how to show all the
context variable in the template ?

thank you for your help !

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Share my project !

2010-04-11 Thread PanFei
I created a project based on Django, It is a small group system, if
you are interest in it ,you can check it out using subversion .

the project is on Google code : http://code.google.com/p/opengroup/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



is it OK to process the "next=xxx" url parameter in the admin login view

2013-07-04 Thread panfei
for some simple use cases, it is convenient to reuse the admin login site,
if the admin login view can process the next parameter in the url, we can
reuse it more smoothly.

-- 
不学习,不知道

-- 
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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Discussion: Why not Django include uWSGI/FastCGI support internally just like Spring Boot include tomcat ?

2019-02-27 Thread panfei
If Django include these production-ready container, and then implement a
mange.py admin command, by just executing the command we can start a
production-ready service.

Any possibilities on this idea ?

-- 
不学习,不知道

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


Re: Discussion: Why not Django include uWSGI/FastCGI support internally just like Spring Boot include tomcat ?

2019-02-27 Thread panfei
Exactly !   It's cool to have a project like Django Boot ~~

Simone Federici  于2019年2月27日周三 下午4:52写道:

> Spring boot is like a django boot external lib to start a django
> microservice.
> exactly like spring boot. you can build your spring application without a
> spring boot starter.
>
>
> On Wed, 27 Feb 2019 at 09:35, panfei  wrote:
>
>> If Django include these production-ready container, and then implement a
>> mange.py admin command, by just executing the command we can start a
>> production-ready service.
>>
>> Any possibilities on this idea ?
>>
>>
>> --
>> 不学习,不知道
>>
>> --
>> 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/CA%2BJstLDyb3TABCsHpPqv_wFU_cjX0Qn23phcZnxgwO4QWvLgOw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2BJstLDyb3TABCsHpPqv_wFU_cjX0Qn23phcZnxgwO4QWvLgOw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CAKsNYugXWXtnj-8y9HKQEQs%3D%2BHdVEVESx5Kcj6yCTmteHRoLkA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKsNYugXWXtnj-8y9HKQEQs%3D%2BHdVEVESx5Kcj6yCTmteHRoLkA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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/CA%2BJstLAbuhPQkQKfTEY5Xga2fvxe-FO_QZ0Nn3vBm2mkMvX7uw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reusable Chat Application for Django Developers

2019-03-18 Thread panfei
Congratulations !

Ahmed Ishtiaque  于2019年3月19日周二 上午5:44写道:

> Hello everyone,
>
> A couple of months ago I was trying to check if I can use any of the apps
> that appear in Django Packages  Chat
> section but it seems like none of them are maintained very well. So I
> decided to build an open source chat project based on the latest Django
> Channels and WebSocket technologies. The goal of this project is to have a
> chat application that can be easily plugged in to an external parent
> project and would work right out of the box.
>
> The source is here: https://github.com/dibs-devs/chatter
> It's on PyPI as well: https://pypi.org/project/django-chatter/
>
> I would appreciate any feedback/contribution on this project!
>
> Best,
> Ahmed
>
> --
> 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/c3955729-2f8d-431b-988e-e9257bea2c77%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/CA%2BJstLAzoSTG18aB8d_PguFQv1Si4Ce-yb81RD1b2TdZJmQ-Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Integrating Machine Learning Model in Django

2019-04-11 Thread panfei
Video analysis is a GPU intensive process, it may take a long time to
process a whole video, I think you can use Celery to run the process as an
asynchronous task, and use callback to trace the progress of the tasks .

Celery can be easily integrated with Django, officially support.

Aakash Baranwal  于2019年4月11日周四 下午3:59写道:

> Hi Everybody,
>
> I need a help in integrating a machine learning model with my website.
>
> I have a file upload button where I can upload either an image or a video.
> After it is uploaded, I want to run my model into it and whatever is the
> result I want to display it and keep a record of the whole process.
>
> Also, I wish to add a feature of connecting my website with my CCTV
> camera, so I can have a live video feed instead of uploading a video and
> then do the same.
>
> PS - I can select whether I want to upload the image or the video or I
> want to use the live footage of the camera and run my model on that.
>
> Thank You in advance.
>
> With Kind Regards
>
> Aakash
>
> --
> 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/CALr9hQ0sxzr%3DwZfNa6%3DhAy1tU6KdRE3-S6nJ4YbOock1SoFpmw%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/CA%2BJstLBMiWgmukrN71Vu1Ei2xKK6mTyV%2Buk2Ppgu2ync%3DddhzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to modify LOGGING settings in unittest

2019-06-10 Thread panfei
There is a logger path for production environment, but I want to put the
logs in /tmp/ in unittests.

This is the LOGGING settings for production environment:

LOGGING_DIR = '/data0/bridge_logs_test/'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'default': {
'format':
'{levelname}\t{asctime}\t{pathname}\t{lineno:d}\t{process:d}\t{message}',
'style': '{'
}
},

'handlers': {
'console_log_handler': {
'level': 'ERROR',
'class': 'logging.StreamHandler',
},

'backup_log_handler': {
'level': 'INFO',
'class': 'logging.handlers.WatchedFileHandler',
'filename': os.path.join(LOGGING_DIR, 'put.log'),
'formatter': 'default',
},

..
},

'loggers': {
'django': {
'handlers': ['console_log_handler', ],
'level': 'DEBUG',
'propagate': True,
},

'backup': {
'handlers': ['backup_log_handler', ],
'level': 'INFO',
'propagate': False,
},

..
},
}

And in unittests, I write:

from django.test import TestCase
class FaceAITestCase(TestCase):
def test_function1(self):
with self.modify_settings(LOGGING_DIR="/tmp/test_logs/"):
pass


When run the unittests, it reports:
ValueError: Unable to configure handler 'access_log_handler': [Errno
2] No such file or directory: '/data0/bridge_logs_test/access.log'

And how to use /tmp/test_logs/ as the log directory in unittests ? any
ideas ? 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/CA%2BJstLD7nDPz_%2BCs203Eh2Qzk-A1wawOzbtA%3DpFE7Lb0FZBaeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to modify LOGGING settings in unittest

2019-06-10 Thread panfei
Still get the same error message

vineeth sagar  于2019年6月11日周二 上午2:08写道:

> Try this with the override_settings decorator. like this.
>
> @override_settings(LOGGING_DIR='/tmp/test_logs/'
> def test_function1(self):
> pass
>
> On Mon, Jun 10, 2019 at 7:15 PM panfei  wrote:
>
>> There is a logger path for production environment, but I want to put the
>> logs in /tmp/ in unittests.
>>
>> This is the LOGGING settings for production environment:
>>
>> LOGGING_DIR = '/data0/bridge_logs_test/'
>> LOGGING = {
>> 'version': 1,
>> 'disable_existing_loggers': False,
>> 'formatters': {
>> 'default': {
>> 'format': 
>> '{levelname}\t{asctime}\t{pathname}\t{lineno:d}\t{process:d}\t{message}',
>> 'style': '{'
>> }
>> },
>>
>> 'handlers': {
>> 'console_log_handler': {
>> 'level': 'ERROR',
>> 'class': 'logging.StreamHandler',
>> },
>>
>> 'backup_log_handler': {
>> 'level': 'INFO',
>> 'class': 'logging.handlers.WatchedFileHandler',
>> 'filename': os.path.join(LOGGING_DIR, 'put.log'),
>> 'formatter': 'default',
>> },
>>
>> ..
>> },
>>
>> 'loggers': {
>> 'django': {
>> 'handlers': ['console_log_handler', ],
>> 'level': 'DEBUG',
>> 'propagate': True,
>> },
>>
>> 'backup': {
>> 'handlers': ['backup_log_handler', ],
>> 'level': 'INFO',
>> 'propagate': False,
>> },
>>
>> ..
>> },
>> }
>>
>> And in unittests, I write:
>>
>> from django.test import TestCase
>> class FaceAITestCase(TestCase):
>> def test_function1(self):
>> with self.modify_settings(LOGGING_DIR="/tmp/test_logs/"):
>> pass
>>
>>
>> When run the unittests, it reports:
>> ValueError: Unable to configure handler 'access_log_handler': [Errno 2] No 
>> such file or directory: '/data0/bridge_logs_test/access.log'
>>
>> And how to use /tmp/test_logs/ as the log directory in unittests ? any
>> ideas ? 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/CA%2BJstLD7nDPz_%2BCs203Eh2Qzk-A1wawOzbtA%3DpFE7Lb0FZBaeQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2BJstLD7nDPz_%2BCs203Eh2Qzk-A1wawOzbtA%3DpFE7Lb0FZBaeQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CAMMZq8NDG_WFJXofeBub7oMysWKFDWo%3DUUC23r0NdM0DC3UV1w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMMZq8NDG_WFJXofeBub7oMysWKFDWo%3DUUC23r0NdM0DC3UV1w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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/CA%2BJstLCkXm6-fy5fQgHr8XhXubMMk9qj2ODVfXtzsEzVpCSD6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread panfei
System environment:

Cent OS 7
Sqlite3 3.34.0 (Compile from source)
Python 3.9.1 (Compile from source)
Django 3.1.5 (Pip install)


1. Compile sqlite3:
./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0
make && make install

2. Add sqlite3 lib to lib search path:

export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/lib
export LD_RUN_PATH=/home/felix/.local/sqlite/default/lib

3. Compile Python 3.9.1
C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
--prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
make && make install

4. Create a venv and install django and start a demo project
cd /tmp
/home/felix/.local/python/python-3.9.1/bin/python3 -m venv venv
source venv/bin/activate
pip install django
djagno-admin startproject demo
cd demo

4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
(venv) [felix@localhost blueprint]$ python manage.py shell
Python 3.9.0 (default, Jan 20 2021, 12:53:25)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>>

5. Run the demo project (cannot find the new sqlite version ? strange.):
(venv) [felix@localhost blueprint]$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
line 219, in ensure_connection
self.connect()
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
line 26, in inner
return func(*args, **kwargs)
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
line 200, in connect
self.connection = self.get_new_connection(conn_params)
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
line 26, in inner
return func(*args, **kwargs)
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py",
line 215, in get_new_connection
create_deterministic_function('django_date_extract', 2,
_sqlite_datetime_extract)
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
higher

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py",
line 950, in _bootstrap_inner
self.run()
  File "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py",
line 888, in run
self._target(*self._args, **self._kwargs)
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/autoreload.py",
line 53, in wrapper
fn(*args, **kwargs)
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py",
line 121, in inner_run
self.check_migrations()
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/core/management/base.py",
line 459, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/executor.py",
line 18, in __init__
self.loader = MigrationLoader(self.connection)
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/loader.py",
line 53, in __init__
self.build_graph()
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/loader.py",
line 216, in build_graph
self.applied_migrations = recorder.applied_migrations()
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/recorder.py",
line 77, in applied_migrations
if self.has_table():
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/migrations/recorder.py",
line 55, in has_table
with self.connection.cursor() as cursor:
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
line 26, in inner
return func(*args, **kwargs)
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
line 259, in cursor
return self._cursor()
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
line 235, in _cursor
self.ensure_connection()
  File
"/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
line 26, in i

Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread panfei
I found that, it may not be a Django-related issue, It's more likely a
Python level issue, but do anyone know how to avoid this problem?:

(venv) [felix@localhost blueprint]$ python
Python 3.9.1 (default, Jan 20 2021, 14:32:50)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
higher
>>> sqlite3.sqlite_version
'3.34.0'
>>> sqlite3.version
'2.6.0'
>>>


panfei  于2021年1月20日周三 下午8:03写道:

>
> System environment:
>
> Cent OS 7
> Sqlite3 3.34.0 (Compile from source)
> Python 3.9.1 (Compile from source)
> Django 3.1.5 (Pip install)
>
>
> 1. Compile sqlite3:
> ./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0
> make && make install
>
> 2. Add sqlite3 lib to lib search path:
>
> export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/lib
> export LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
>
> 3. Compile Python 3.9.1
> C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
> --prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
> make && make install
>
> 4. Create a venv and install django and start a demo project
> cd /tmp
> /home/felix/.local/python/python-3.9.1/bin/python3 -m venv venv
> source venv/bin/activate
> pip install django
> djagno-admin startproject demo
> cd demo
>
> 4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
> (venv) [felix@localhost blueprint]$ python manage.py shell
> Python 3.9.0 (default, Jan 20 2021, 12:53:25)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import sqlite3
> >>> sqlite3.sqlite_version
> '3.34.0'
> >>> sqlite3.version
> '2.6.0'
> >>>
>
> 5. Run the demo project (cannot find the new sqlite version ? strange.):
> (venv) [felix@localhost blueprint]$ python manage.py runserver
> Watching for file changes with StatReloader
> Performing system checks...
>
> System check identified no issues (0 silenced).
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
> line 219, in ensure_connection
> self.connect()
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
> line 26, in inner
> return func(*args, **kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
> line 200, in connect
> self.connection = self.get_new_connection(conn_params)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
> line 26, in inner
> return func(*args, **kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py",
> line 215, in get_new_connection
> create_deterministic_function('django_date_extract', 2,
> _sqlite_datetime_extract)
> sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
> higher
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File
> "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", line
> 950, in _bootstrap_inner
> self.run()
>   File
> "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", line
> 888, in run
> self._target(*self._args, **self._kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/autoreload.py",
> line 53, in wrapper
> fn(*args, **kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py",
> line 121, in inner_run
> self.check_migrations()
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/core/management/base.py",
> line 459, in check_migratio

Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread panfei
I have tried, it works in Python 3.6 environment. but I still want to find
a way (maybe a workaround) to solve this problem.

'Amitesh Sahay' via Django users 
于2021年1月20日周三 下午9:48写道:

> Try older version of Python interpreter and see if that works. May be
> consider using 3.6
>
> Regards,
> Amitesh
>
>
> On Wednesday, 20 January, 2021, 05:55:32 pm IST, panfei 
> wrote:
>
>
> I found that, it may not be a Django-related issue, It's more likely a
> Python level issue, but do anyone know how to avoid this problem?:
>
> (venv) [felix@localhost blueprint]$ python
> Python 3.9.1 (default, Jan 20 2021, 14:32:50)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sqlite3
> >>> conn = sqlite3.connect(':memory:')
> >>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
> Traceback (most recent call last):
>   File "", line 1, in 
> sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
> higher
> >>> sqlite3.sqlite_version
> '3.34.0'
> >>> sqlite3.version
> '2.6.0'
> >>>
>
>
> panfei  于2021年1月20日周三 下午8:03写道:
>
>
> System environment:
>
> Cent OS 7
> Sqlite3 3.34.0 (Compile from source)
> Python 3.9.1 (Compile from source)
> Django 3.1.5 (Pip install)
>
>
> 1. Compile sqlite3:
> ./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0
> make && make install
>
> 2. Add sqlite3 lib to lib search path:
>
> export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/lib
> export LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
>
> 3. Compile Python 3.9.1
> C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
> --prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
> make && make install
>
> 4. Create a venv and install django and start a demo project
> cd /tmp
> /home/felix/.local/python/python-3.9.1/bin/python3 -m venv venv
> source venv/bin/activate
> pip install django
> djagno-admin startproject demo
> cd demo
>
> 4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
> (venv) [felix@localhost blueprint]$ python manage.py shell
> Python 3.9.0 (default, Jan 20 2021, 12:53:25)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import sqlite3
> >>> sqlite3.sqlite_version
> '3.34.0'
> >>> sqlite3.version
> '2.6.0'
> >>>
>
> 5. Run the demo project (cannot find the new sqlite version ? strange.):
> (venv) [felix@localhost blueprint]$ python manage.py runserver
> Watching for file changes with StatReloader
> Performing system checks...
>
> System check identified no issues (0 silenced).
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
> line 219, in ensure_connection
> self.connect()
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
> line 26, in inner
> return func(*args, **kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
> line 200, in connect
> self.connection = self.get_new_connection(conn_params)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
> line 26, in inner
> return func(*args, **kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py",
> line 215, in get_new_connection
> create_deterministic_function('django_date_extract', 2,
> _sqlite_datetime_extract)
> sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
> higher
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File
> "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", line
> 950, in _bootstrap_inner
> self.run()
>   File
> "/home/felix/.local/python/python-3.9.0/lib/python3.9/threading.py", line
> 888, in run
> self._target(*self._args, **self._kwargs)
>   File
>

Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread panfei
The exception is raised from inside the C implementation in Python when
checking sqlite3 version check.
In Django:

@async_unsafe
def get_new_connection(self, conn_params):
conn = Database.connect(**conn_params)
if PY38:
create_deterministic_function = functools.partial(
conn.create_function,
deterministic=True,
)
else:
create_deterministic_function = conn.create_function

if PY38 (means python version greater or equal to 3.8) is True, the new
created function will call conn.create_function with deterministic=True, so
the exception happens.

panfei  于2021年1月20日周三 下午9:54写道:

> I have tried, it works in Python 3.6 environment. but I still want to find
> a way (maybe a workaround) to solve this problem.
>
> 'Amitesh Sahay' via Django users 
> 于2021年1月20日周三 下午9:48写道:
>
>> Try older version of Python interpreter and see if that works. May be
>> consider using 3.6
>>
>> Regards,
>> Amitesh
>>
>>
>> On Wednesday, 20 January, 2021, 05:55:32 pm IST, panfei <
>> cnwe...@gmail.com> wrote:
>>
>>
>> I found that, it may not be a Django-related issue, It's more likely a
>> Python level issue, but do anyone know how to avoid this problem?:
>>
>> (venv) [felix@localhost blueprint]$ python
>> Python 3.9.1 (default, Jan 20 2021, 14:32:50)
>> [GCC 10.2.0] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import sqlite3
>> >>> conn = sqlite3.connect(':memory:')
>> >>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
>> higher
>> >>> sqlite3.sqlite_version
>> '3.34.0'
>> >>> sqlite3.version
>> '2.6.0'
>> >>>
>>
>>
>> panfei  于2021年1月20日周三 下午8:03写道:
>>
>>
>> System environment:
>>
>> Cent OS 7
>> Sqlite3 3.34.0 (Compile from source)
>> Python 3.9.1 (Compile from source)
>> Django 3.1.5 (Pip install)
>>
>>
>> 1. Compile sqlite3:
>> ./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0
>> make && make install
>>
>> 2. Add sqlite3 lib to lib search path:
>>
>> export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/lib
>> export LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
>>
>> 3. Compile Python 3.9.1
>> C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
>> CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
>> LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
>> --prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
>> make && make install
>>
>> 4. Create a venv and install django and start a demo project
>> cd /tmp
>> /home/felix/.local/python/python-3.9.1/bin/python3 -m venv venv
>> source venv/bin/activate
>> pip install django
>> djagno-admin startproject demo
>> cd demo
>>
>> 4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
>> (venv) [felix@localhost blueprint]$ python manage.py shell
>> Python 3.9.0 (default, Jan 20 2021, 12:53:25)
>> [GCC 10.2.0] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>> (InteractiveConsole)
>> >>> import sqlite3
>> >>> sqlite3.sqlite_version
>> '3.34.0'
>> >>> sqlite3.version
>> '2.6.0'
>> >>>
>>
>> 5. Run the demo project (cannot find the new sqlite version ? strange.):
>> (venv) [felix@localhost blueprint]$ python manage.py runserver
>> Watching for file changes with StatReloader
>> Performing system checks...
>>
>> System check identified no issues (0 silenced).
>> Exception in thread django-main-thread:
>> Traceback (most recent call last):
>>   File
>> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
>> line 219, in ensure_connection
>> self.connect()
>>   File
>> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
>> line 26, in inner
>> return func(*args, **kwargs)
>>   File
>> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
>> line 200, in co

Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread panfei
Thanks for all the suggestions.

'Amitesh Sahay' via Django users 
于2021年1月20日周三 下午10:06写道:

> Please read the release notes of the Django version you are using. It will
> be a life saver as well.
>
> Regards,
> Amitesh
>
>
> On Wednesday, 20 January, 2021, 07:35:14 pm IST, Amitesh Sahay <
> amitesh.sa...@yahoo.com> wrote:
>
>
> So, this seems to be a version compatibility issue, a a work around you
> can use some other database(mysql, oracle, etc). This cud save ur day and
> time as well.
>
> Regards,
> Amitesh
>
> On Wednesday, 20 January, 2021, 07:32:59 pm IST, panfei 
> wrote:
>
>
> I have tried, it works in Python 3.6 environment. but I still want to find
> a way (maybe a workaround) to solve this problem.
>
> 'Amitesh Sahay' via Django users 
> 于2021年1月20日周三 下午9:48写道:
>
> Try older version of Python interpreter and see if that works. May be
> consider using 3.6
>
> Regards,
> Amitesh
>
>
> On Wednesday, 20 January, 2021, 05:55:32 pm IST, panfei 
> wrote:
>
>
> I found that, it may not be a Django-related issue, It's more likely a
> Python level issue, but do anyone know how to avoid this problem?:
>
> (venv) [felix@localhost blueprint]$ python
> Python 3.9.1 (default, Jan 20 2021, 14:32:50)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sqlite3
> >>> conn = sqlite3.connect(':memory:')
> >>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
> Traceback (most recent call last):
>   File "", line 1, in 
> sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
> higher
> >>> sqlite3.sqlite_version
> '3.34.0'
> >>> sqlite3.version
> '2.6.0'
> >>>
>
>
> panfei  于2021年1月20日周三 下午8:03写道:
>
>
> System environment:
>
> Cent OS 7
> Sqlite3 3.34.0 (Compile from source)
> Python 3.9.1 (Compile from source)
> Django 3.1.5 (Pip install)
>
>
> 1. Compile sqlite3:
> ./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0
> make && make install
>
> 2. Add sqlite3 lib to lib search path:
>
> export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/lib
> export LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
>
> 3. Compile Python 3.9.1
> C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
> --prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
> make && make install
>
> 4. Create a venv and install django and start a demo project
> cd /tmp
> /home/felix/.local/python/python-3.9.1/bin/python3 -m venv venv
> source venv/bin/activate
> pip install django
> djagno-admin startproject demo
> cd demo
>
> 4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
> (venv) [felix@localhost blueprint]$ python manage.py shell
> Python 3.9.0 (default, Jan 20 2021, 12:53:25)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import sqlite3
> >>> sqlite3.sqlite_version
> '3.34.0'
> >>> sqlite3.version
> '2.6.0'
> >>>
>
> 5. Run the demo project (cannot find the new sqlite version ? strange.):
> (venv) [felix@localhost blueprint]$ python manage.py runserver
> Watching for file changes with StatReloader
> Performing system checks...
>
> System check identified no issues (0 silenced).
> Exception in thread django-main-thread:
> Traceback (most recent call last):
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
> line 219, in ensure_connection
> self.connect()
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
> line 26, in inner
> return func(*args, **kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/base/base.py",
> line 200, in connect
> self.connection = self.get_new_connection(conn_params)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/utils/asyncio.py",
> line 26, in inner
> return func(*args, **kwargs)
>   File
> "/home/felix/PycharmProjects/blueprint/venv/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py"

Re: python manage.py runserver can not use newly compiled sqlite3 lib on CentOS 7

2021-01-20 Thread panfei
It finally proved a compilation issue, this is the right way to compile
Python 3.9:

1033 C_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
--prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
1034 C_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib make
1035 make clean
1036 C_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
--prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
1037 C_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib make
1038 C_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/default/include/
LD_RUN_PATH=/home/felix/.local/sqlite/default/lib make install
1039 /home/felix/.local/python/python-3.9.1/bin/python3
1040 history
[felix@localhost Python-3.9.1]$
/home/felix/.local/python/python-3.9.1/bin/python3
Python 3.9.1 (default, Jan 21 2021, 10:58:50)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn = sqlite3.connect(':memory:')
>>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
>>>

Every step should specify the same environment variables.

'Amitesh Sahay' via Django users 
于2021年1月20日周三 下午10:06写道:

> Please read the release notes of the Django version you are using. It will
> be a life saver as well.
>
> Regards,
> Amitesh
>
>
> On Wednesday, 20 January, 2021, 07:35:14 pm IST, Amitesh Sahay <
> amitesh.sa...@yahoo.com> wrote:
>
>
> So, this seems to be a version compatibility issue, a a work around you
> can use some other database(mysql, oracle, etc). This cud save ur day and
> time as well.
>
> Regards,
> Amitesh
>
> On Wednesday, 20 January, 2021, 07:32:59 pm IST, panfei 
> wrote:
>
>
> I have tried, it works in Python 3.6 environment. but I still want to find
> a way (maybe a workaround) to solve this problem.
>
> 'Amitesh Sahay' via Django users 
> 于2021年1月20日周三 下午9:48写道:
>
> Try older version of Python interpreter and see if that works. May be
> consider using 3.6
>
> Regards,
> Amitesh
>
>
> On Wednesday, 20 January, 2021, 05:55:32 pm IST, panfei 
> wrote:
>
>
> I found that, it may not be a Django-related issue, It's more likely a
> Python level issue, but do anyone know how to avoid this problem?:
>
> (venv) [felix@localhost blueprint]$ python
> Python 3.9.1 (default, Jan 20 2021, 14:32:50)
> [GCC 10.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sqlite3
> >>> conn = sqlite3.connect(':memory:')
> >>> conn.create_function('f', 2, lambda *args: None, deterministic=True)
> Traceback (most recent call last):
>   File "", line 1, in 
> sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or
> higher
> >>> sqlite3.sqlite_version
> '3.34.0'
> >>> sqlite3.version
> '2.6.0'
> >>>
>
>
> panfei  于2021年1月20日周三 下午8:03写道:
>
>
> System environment:
>
> Cent OS 7
> Sqlite3 3.34.0 (Compile from source)
> Python 3.9.1 (Compile from source)
> Django 3.1.5 (Pip install)
>
>
> 1. Compile sqlite3:
> ./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0
> make && make install
>
> 2. Add sqlite3 lib to lib search path:
>
> export LD_LIBRARY_PATH=/home/felix/.local/sqlite/default/lib
> export LD_RUN_PATH=/home/felix/.local/sqlite/default/lib
>
> 3. Compile Python 3.9.1
> C_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> CPLUS_INCLUDE_PATH=/home/felix/.local/sqlite/sqlite-3.34.0/include/
> LD_RUN_PATH=/home/felix/.local/sqlite/default/lib ./configure
> --prefix=/home/felix/.local/python/python-3.9.1 --enable-optimizations
> make && make install
>
> 4. Create a venv and install django and start a demo project
> cd /tmp
> /home/felix/.local/python/python-3.9.1/bin/python3 -m venv venv
> source venv/bin/activate
> pip install django
> djagno-admin startproject demo
> cd demo
>
> 4 Check sqlite3 lib version (seems to be OK, sqlite_version is 3.34.0)
> (venv) [felix@localhost blueprin