Re: DoesNotExist at /admin/blog/blog/add/: blog matching query does not exist

2022-09-13 Thread mailinglists
Sorry, the wrong list.

Op 2022-09-12T20:35:46+ schreef mailingli...@vanwingerde.nl
 in bericht
, inzake:
 het volgende.

> Suddenly I can no longer add blogs to Django. Django says 'blog
> matching query does not exist'. That seems strange to me because I
> want to add something to the database and not request a blog. What
> could be going on here?
> 
> admin.py:
> class blogadmin(admin.ModelAdmin):
> def save_model(self, request, obj, form, change):
> if not change:
> obj.added_by_user = request.user.username
> obj.ip_added = request.META['REMOTE_ADDR']
> if obj.ip_added == '127.0.0.1':
> obj.ip_added = request.META['HTTP_X_FORWARDED_FOR']
> obj.publish = False
> del obj.publish_date
> else:
> obj.changed_by_user = request.user.username
> obj.ip_changed = request.META['REMOTE_ADDR']
> if obj.ip_changed == '127.0.0.1':
> obj.ip_changed = request.META['HTTP_X_FORWARDED_FOR']
> if obj.publish == True:
> if not obj.publish_date:
> obj.publish_date = obj.datetime_changed
> super(blogadmin,self).save_model(request, obj, form, change)
> 
> I can add text, photographs etc., but no blogs.
> 
> Notifications:
> DoesNotExist at /admin/blog/blog/add/
> 
> blog matching query does not exist.
> 
> Request Method:   POST
> Request URL:  http://127.0.0.1:8001/admin/blog/blog/add/
> Django Version:   4.1.1
> Exception Type:   DoesNotExist
> Exception Value:  
> 
> blog matching query does not exist.
> 
> Traceback
> Environment:
> Request Method: POST
> Request URL: http://127.0.0.1:8001/admin/blog/blog/add/
> 
> Django Version: 4.1.1
> Python Version: 3.10.5
> Installed Applications:
> ['grappelli',
>  'django.contrib.admin',
>  'django.contrib.admindocs',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'blog.apps.BlogConfig']
> Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware',
>  'django.contrib.admindocs.middleware.XViewMiddleware']
> 
> Traceback (most recent call last):
>   File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/core/handlers/exception.py",
> line 55, in inner response = get_response(request) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/core/handlers/base.py",
> line 197, in _get_response response = wrapped_callback(request,
> *callback_args, **callback_kwargs) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/contrib/admin/options.py",
> line 686, in wrapper return self.admin_site.admin_view(view)(*args,
> **kwargs) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/utils/decorators.py",
> line 133, in _wrapped_view response = view_func(request, *args,
> **kwargs) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/views/decorators/cache.py",
> line 62, in _wrapped_view_func response = view_func(request, *args,
> **kwargs) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/contrib/admin/sites.py",
> line 242, in inner return view(request, *args, **kwargs) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/contrib/admin/options.py",
> line 1890, in add_view return self.changeform_view(request, None,
> form_url, extra_context) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/utils/decorators.py",
> line 46, in _wrapper return bound_method(*args, **kwargs) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/utils/decorators.py",
> line 133, in _wrapped_view response = view_func(request, *args,
> **kwargs) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/contrib/admin/options.py",
> line 1750, in changeform_view return self._changeform_view(request,
> object_id, form_url, extra_context) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/contrib/admin/options.py",
> line 1802, in _changeform_view self.save_model(request, new_object,
> form, not add) File "/var/django/liakoster.nl/blog-1/blog/admin.py",
> line 26, in save_model super(blogadmin,self).save_model(request, obj,
> form, change) File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/contrib/admin/options.py",
> line 1225, in save_model obj.save() File
> "/var/django/liakoster.nl/blog-1/lib/python3.10/site-packages/django/db/models/base.py",
> line 831, in save self.save

poetry: local dependencies in dev and prod environments

2022-09-13 Thread Loris Bennett
Hi,

Say I have two modules: main application and a utility.

With poetry I can add the utility as local dependency to the main
application thus:
 
  poetry add ../utilities/mailer/dist/my_mailer-0.1.0-py3-none-any.whl

This then generates the following in the pyproj.toml of the main
application:

  [tool.poetry.dependencies]
  python = "^3.6"
  my-mailer = {path = 
"../utilities/mailer/dist/my_mailer-0.1.0-py3-none-any.whl"}

With this configuration I can run the application in the development
environment.

However, if I want to install both the main application and the
utility to my 'site-package' directory, I need to change pyproj.toml to 

  [tool.poetry.dependencies]
  python = "^3.6"
  my-mailer = ">0.1.0"

This seems a bit clunky to me and I wonder whether there is a better way
of handling the situation.

The problem is that the venv used by poetry for the main application
correctly ignores the 'site-packages' directory, which contains the
utility when it is installed.  However, it would be handy if I could
allow just this single package from 'site-packages' to be used within
the venv.  Is this possible?

Cheers,

Loris
 
-- 
This signature is currently under construction.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain the query interface url of BCS server.

2022-09-13 Thread hongy...@gmail.com
On Tuesday, September 13, 2022 at 4:20:12 AM UTC+8, DFS wrote:
> On 9/12/2022 5:00 AM, hongy...@gmail.com wrote: 
> > I want to do the query from with in script based on the interface here [1]. 
> > For this purpose, the underlying posting URL must be obtained, say, the URL 
> > corresponding to "ITA Settings" button, so that I can make the 
> > corresponding query URL and issue the query from the script. 
> > 
> > However, I did not find the conversion rules from these buttons to the 
> > corresponding URL. Any hints for achieving this aim? 
> > 
> > [1] 
> > https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-getgen?list=new&what=gen&gnum=10
> >  
> > 
> > Regards, 
> > Zhao
> You didn't say what you want to query. Are you trying to download 
> entire sections of the Bilbao Crystallographic Server? 

I am engaged in some related research and need some specific data used by BCS 
server.

> Maybe the admins will give you access to the data. 

I don't think they will provide such convenience to researchers who have no 
cooperative relationship with them. 

> * this link: https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-getgen 
> brings up the table of space group symbols. 
> 
> * choose say #7: Pc 
> 
> * now click ITA Settings, then choose the last entry "P c 1 1" and it 
> loads: 
> 
> https://www.cryst.ehu.es/cgi-bin/cryst/programs//nph-trgen?gnum=007&what=gp&trmat=b,-a-c,c&unconv=P%20c%201%201&from=ita
>  

Not only that, but I want to obtain all such URLs programmatically!
 
> You might be able to fool around with that URL and substitute values and 
> get back the data you want (in HTML) via Python. Do you really want 
> HTML results? 
> 
> Hit Ctrl+U to see the source HTML of a webpage 
> 
> Right-click or hit Ctrl + Shift + C to inspect the individual elements 
> of the page

For batch operations, all these manual methods are inefficient.

Best Regards,
Zhao
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain the query interface url of BCS server.

2022-09-13 Thread DFS

On 9/13/2022 3:46 AM, hongy...@gmail.com wrote:

On Tuesday, September 13, 2022 at 4:20:12 AM UTC+8, DFS wrote:

On 9/12/2022 5:00 AM, hongy...@gmail.com wrote:

I want to do the query from with in script based on the interface here [1]. For this 
purpose, the underlying posting URL must be obtained, say, the URL corresponding to 
"ITA Settings" button, so that I can make the corresponding query URL and issue 
the query from the script.

However, I did not find the conversion rules from these buttons to the 
corresponding URL. Any hints for achieving this aim?

[1] 
https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-getgen?list=new&what=gen&gnum=10

Regards,
Zhao

You didn't say what you want to query. Are you trying to download
entire sections of the Bilbao Crystallographic Server?


I am engaged in some related research and need some specific data used by BCS 
server.


What specific data?

Is it available elsewhere?



Maybe the admins will give you access to the data.


I don't think they will provide such convenience to researchers who have no 
cooperative relationship with them.


You can try.  Tell the admins what data you want, and ask them for the 
easiest way to get it.




* this link: https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-getgen
brings up the table of space group symbols.

* choose say #7: Pc

* now click ITA Settings, then choose the last entry "P c 1 1" and it
loads:

https://www.cryst.ehu.es/cgi-bin/cryst/programs//nph-trgen?gnum=007&what=gp&trmat=b,-a-c,c&unconv=P%20c%201%201&from=ita


Not only that, but I want to obtain all such URLs programmatically!
  

You might be able to fool around with that URL and substitute values and
get back the data you want (in HTML) via Python. Do you really want
HTML results?

Hit Ctrl+U to see the source HTML of a webpage

Right-click or hit Ctrl + Shift + C to inspect the individual elements
of the page


For batch operations, all these manual methods are inefficient.


Yes, but I don't think you'll be able to retrieve the URLs 
programmatically.  The JavaScript code doesn't put them in the HTML 
result, except for that one I showed you, which seems like a mistake on 
their part.


So you'll have to figure out the search fields, and your python program 
will have to cycle through the search values:


Sample from above
gnum   = 007
what   = gp
trmat  = b,-a-c,c
unconv = P c 1 1
from   = ita

wBase   = "https://www.cryst.ehu.es/cgi-bin/cryst/programs//nph-trgen";
wGnum   = "?gnum="   + findgnum
wWhat   = "&what="   + findWhat
wTrmat  = "&trmat="  + findTrmat
wUnconv = "&unconv=" + findUnconv
wFrom   = "&from="   + findFrom
webpage  = wBase + wGnum + wWhat + wTrmat + wUnconv + wFrom

Then if that returns a hit, you'll have to parse the resulting HTML and 
extract the exact data you want.




I did something similar a while back using the requests and lxml libraries

#build url
wBase= "http://www.usdirectory.com";
wForm= "/ypr.aspx?fromform=qsearch"
wKeyw= "&qhqn=" + keyw
wCityZip = "&qc="   + cityzip
wState   = "&qs="   + state
wDist= "&rg="   + str(miles)
wSort= "&sb=a2z"  #sort alpha
wPage= "&ap="   #used with the results page number
webpage  = wBase + wForm + wKeyw + wCityZip + wState + wDist

#open URL
page = requests.get(webpage)
tree = html.fromstring(page.content)

#no matches
matches = tree.xpath('//strong/text()')
if passNbr == 1 and ("No results were found" in str(matches)):
print "No results found for that search"
exit(0)




2.x code file: https://file.io/VdptORSKh5CN




Best Regards,
Zhao


--
https://mail.python.org/mailman/listinfo/python-list


Virtual PUG-meeting: An applied introduction to Finite State Machines

2022-09-13 Thread dn
An applied introduction to Finite State Machines
0730 UTC, Wed 21 Sep 2022

The basics of Finite State Machines and what they are good for. How to
use FSM for solving optimization problems.

- A simple traffic jam
- A bigger traffic jam
- A sudoku

After this lecture there won't be any discrete optimization problem you
won't be able to solve.

Dr. Bjorn Madsen solves optimization problems using Python, for DoD,
LEGO, Coca Cola, Airbus and many other companies.


These meetups have two sessions. At least one is aimed at a beginner
level - in either Python or FSMs.

Sign-up and more details from https://www.meetup.com/nzpug-auckland/
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Virtual PUG-meeting: An applied introduction to Finite State Machines

2022-09-13 Thread Sam Ezeh
That seems interesting.

Is this hosted online? And are there any suggested reading materials for
those who might not be able to attend?

Kind regards,
Sam Ezeh

On Tue, 13 Sept 2022 at 22:53, dn  wrote:

> An applied introduction to Finite State Machines
> 0730 UTC, Wed 21 Sep 2022
>
> The basics of Finite State Machines and what they are good for. How to
> use FSM for solving optimization problems.
>
> - A simple traffic jam
> - A bigger traffic jam
> - A sudoku
>
> After this lecture there won't be any discrete optimization problem you
> won't be able to solve.
>
> Dr. Bjorn Madsen solves optimization problems using Python, for DoD,
> LEGO, Coca Cola, Airbus and many other companies.
>
>
> These meetups have two sessions. At least one is aimed at a beginner
> level - in either Python or FSMs.
>
> Sign-up and more details from https://www.meetup.com/nzpug-auckland/
> --
> Regards,
> =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Uninstall tool not working.

2022-09-13 Thread Salvatore Bruzzese
Hi,
I was trying to uninstall version 3.10.7 of python but I've
encountered problems with the uninstall tool.
I open the python setup program, click on the uninstall button but it
doesn't even start deleting python even though it says that the
process has finished.
Feel free to ask for more details in case I didn't explain it correctly.

Thanks in advance for your help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obtain the query interface url of BCS server.

2022-09-13 Thread hongy...@gmail.com
On Tuesday, September 13, 2022 at 9:33:20 PM UTC+8, DFS wrote:
> On 9/13/2022 3:46 AM, hongy...@gmail.com wrote: 
> > On Tuesday, September 13, 2022 at 4:20:12 AM UTC+8, DFS wrote: 
> >> On 9/12/2022 5:00 AM, hongy...@gmail.com wrote: 
> >>> I want to do the query from with in script based on the interface here 
> >>> [1]. For this purpose, the underlying posting URL must be obtained, say, 
> >>> the URL corresponding to "ITA Settings" button, so that I can make the 
> >>> corresponding query URL and issue the query from the script. 
> >>> 
> >>> However, I did not find the conversion rules from these buttons to the 
> >>> corresponding URL. Any hints for achieving this aim? 
> >>> 
> >>> [1] 
> >>> https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-getgen?list=new&what=gen&gnum=10
> >>>  
> >>> 
> >>> Regards, 
> >>> Zhao 
> >> You didn't say what you want to query. Are you trying to download 
> >> entire sections of the Bilbao Crystallographic Server? 
> > 
> > I am engaged in some related research and need some specific data used by 
> > BCS server.
> What specific data? 

All the data corresponding to the total catalog here:
https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-getgen
 
> Is it available elsewhere?

This is an internationally recognized authoritative data source in this field. 
Data from other places, even if there are readily available electronic 
versions, are basically taken from here and are not comprehensive.

> >> Maybe the admins will give you access to the data. 
> > 
> > I don't think they will provide such convenience to researchers who have no 
> > cooperative relationship with them.
> You can try. Tell the admins what data you want, and ask them for the 
> easiest way to get it.
> >> * this link: https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-getgen 
> >> brings up the table of space group symbols. 
> >> 
> >> * choose say #7: Pc 
> >> 
> >> * now click ITA Settings, then choose the last entry "P c 1 1" and it 
> >> loads: 
> >> 
> >> https://www.cryst.ehu.es/cgi-bin/cryst/programs//nph-trgen?gnum=007&what=gp&trmat=b,-a-c,c&unconv=P%20c%201%201&from=ita
> >>  
> > 
> > Not only that, but I want to obtain all such URLs programmatically! 
> > 
> >> You might be able to fool around with that URL and substitute values and 
> >> get back the data you want (in HTML) via Python. Do you really want 
> >> HTML results? 
> >> 
> >> Hit Ctrl+U to see the source HTML of a webpage 
> >> 
> >> Right-click or hit Ctrl + Shift + C to inspect the individual elements 
> >> of the page 
> > 
> > For batch operations, all these manual methods are inefficient.
> Yes, but I don't think you'll be able to retrieve the URLs 
> programmatically. The JavaScript code doesn't put them in the HTML 
> result, except for that one I showed you, which seems like a mistake on 
> their part. 
> 
> So you'll have to figure out the search fields, and your python program 
> will have to cycle through the search values: 
> 
> Sample from above 
> gnum = 007 
> what = gp 
> trmat = b,-a-c,c 
> unconv = P c 1 1 
> from = ita 

The problem is that I must first get all possible combinations of these 
variables.
 
> wBase = "https://www.cryst.ehu.es/cgi-bin/cryst/programs//nph-trgen"; 
> wGnum = "?gnum=" + findgnum 
> wWhat = "&what=" + findWhat 
> wTrmat = "&trmat=" + findTrmat 
> wUnconv = "&unconv=" + findUnconv 
> wFrom = "&from=" + findFrom 
> webpage = wBase + wGnum + wWhat + wTrmat + wUnconv + wFrom 
> 
> Then if that returns a hit, you'll have to parse the resulting HTML and 
> extract the exact data you want. 
> 
> 
> 
> I did something similar a while back using the requests and lxml libraries 
>  
> #build url 
> wBase = "http://www.usdirectory.com"; 
> wForm = "/ypr.aspx?fromform=qsearch" 
> wKeyw = "&qhqn=" + keyw 
> wCityZip = "&qc=" + cityzip 
> wState = "&qs=" + state 
> wDist = "&rg=" + str(miles) 
> wSort = "&sb=a2z" #sort alpha 
> wPage = "&ap=" #used with the results page number 
> webpage = wBase + wForm + wKeyw + wCityZip + wState + wDist 
> 
> #open URL 
> page = requests.get(webpage) 
> tree = html.fromstring(page.content) 
> 
> #no matches 
> matches = tree.xpath('//strong/text()') 
> if passNbr == 1 and ("No results were found" in str(matches)): 
> print "No results found for that search" 
> exit(0) 
>  
> 
> 
> 
> 2.x code file: https://file.io/VdptORSKh5CN 
> 
> 
> 
> > Best Regards, 
> > Zhao
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Virtual PUG-meeting: An applied introduction to Finite State Machines

2022-09-13 Thread dn
On 14/09/2022 10.18, Sam Ezeh wrote:
> That seems interesting.
> 
> Is this hosted online? And are there any suggested reading materials for
> those who might not be able to attend?


Yes there are - if you'd like to follow the link (below), the published
meeting-details include references.

One of my colleagues on the PUG Leadership Team has organised the
speaker, but I recall mention of "notebooks", etc. So, there may be
further resources which will be made-available during/after the talk
itself...

If you are a 'late-owl' in the (US) Pacific Time-Zone, you may like to
join us 'live'. Sadly, the timings rapidly become anti-social for more
easterly time-zones in the Americas.

If you are anywhere in the rest of the world, you will find that the
meeting falls sometime during your working-day, through to Europeans
at-breakfast!

You'll be most welcome!


> Kind regards,
> Sam Ezeh
> 
> On Tue, 13 Sept 2022 at 22:53, dn  > wrote:
> 
> An applied introduction to Finite State Machines
> 0730 UTC, Wed 21 Sep 2022
> 
> The basics of Finite State Machines and what they are good for. How to
> use FSM for solving optimization problems.
> 
> - A simple traffic jam
> - A bigger traffic jam
> - A sudoku
> 
> After this lecture there won't be any discrete optimization problem you
> won't be able to solve.
> 
> Dr. Bjorn Madsen solves optimization problems using Python, for DoD,
> LEGO, Coca Cola, Airbus and many other companies.
> 
> 
> These meetups have two sessions. At least one is aimed at a beginner
> level - in either Python or FSMs.
> 
> Sign-up and more details from https://www.meetup.com/nzpug-auckland/
> 
> -- 
> Regards,
> =dn
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 
> 


-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list