newbie: which settings file? ["settings.DATABASES is improperly configured. "]

2012-09-10 Thread Bob Aalsma
I'm new at Django, renewing the start I made some two years ago by 
following the tutorial. 
And I'm aware there are some problems with my python, which I'm trying to 
solve as well. 
And I didn't find the answer to my question in djangoproject, this group or 
any other group.

I'm in Chapter 5 of the tutorial, configuring the database. 
I think I've done everything correct to set the DATABASE_ENGINE = 
'sqlite3'. 
Then I check the settings and see an error:
bobaalsma$ python ./manage.py shell
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on 
darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.db import connection
>>> cursor = connection.cursor()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Python/2.7/site-packages/django/db/backends/dummy/base.py", line 
15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly 
configured. "
ImproperlyConfigured: settings.DATABASES is improperly configured. Please 
supply the ENGINE value. Check settings documentation for more details.

Also:
>>> from django.conf import settings
>>> settings.DATABASES
{'default': {'ENGINE': 'django.db.backends.dummy', 'TEST_MIRROR': None, 
'NAME': '', 'TEST_CHARSET': None, 'TIME_ZONE': 'America/Chicago', 
'TEST_COLLATION': None, 'PORT': '', 'HOST': '', 'USER': '', 'TEST_NAME': 
None, 'PASSWORD': '', 'OPTIONS': {}}}

I think these answers are valid only IF Django would look at 
/Library/Python/2.7/site-packages/django/conf/project_template/project_name/settings.py,
 
which is NOT the settings.py of my project.
For some peculiar reason a new settings.pyc is created in the expected 
settinngs location within the project environment.

Questions: 

   - how to point Django to the correct settings file? 
   - what other variables will likely be affected in this situation?
   

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/oaBBFqRkleMJ.
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: newbie: which settings file? ["settings.DATABASES is improperly configured. "]

2012-09-10 Thread Bob Aalsma
Ah, yes, thanks!

Regards,
Bob


Op maandag 10 september 2012 21:31:17 UTC+2 schreef Thomas het volgende:
>
>  On 9/10/12 11:30 AM, Bob Aalsma wrote:
>  
>
> I'm in Chapter 5 of the tutorial, configuring the database. 
> I think I've done everything correct to set the DATABASE_ENGINE = 
> 'sqlite3'. 
> Then I check the settings and see an error:
> ImproperlyConfigured: settings.DATABASES is improperly configured. Please 
> supply the ENGINE value. Check settings documentation for more details.
>  
>  You are mixing an older tutorial with a newer version of Django.
>
> Find instructions which describe setting "ENGINE" in the "DATABASES" 
> structure. You see that the error message mentions "DATABASES" and 
> "ENGINES", not "DATABASE_ENGINE" which is the clue here.
>
> hth
>
>- Tom
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YtRexvFo3QoJ.
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.



newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
I'm a newbie following the tutorial. In this, creating a superuser is 
described, using 

manage.py createsuperuser --username=joe --email=j...@example.com


Using this leads to an error, which I could match to the closed ticket 
#16017.

But I couldn't find how to proceed from there. It seems some software was 
changed about 4 weeks ago:
"Made createsuperuser more robust when getting current OS username."

So where can I find it?
[I'm assuming there is a procedure for this, but I'm sorry to say I 
couldn't find that either]

Regards,
Bob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Xjd5_oHid9UJ.
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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
Django 1.4.1
Python 2.7.3
OS X 10.7.4


Op donderdag 13 september 2012 19:12:30 UTC+2 schreef creecode het volgende:
>
> Which version of django are you using?
>
> On Thursday, September 13, 2012 7:58:11 AM UTC-7, Bob Aalsma wrote:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
>> described, using 
>>
>> manage.py createsuperuser --username=joe --email=j...@example.com
>>
>>
>> Using this leads to an error, which I could match to the closed ticket 
>> #16017.
>>
>> But I couldn't find how to proceed from there. It seems some software was 
>> changed about 4 weeks ago:
>> "Made createsuperuser more robust when getting current OS username."
>>
>> So where can I find it?
>> [I'm assuming there is a procedure for this, but I'm sorry to say I 
>> couldn't find that either]
>>
>
> Toodle-loo.
> creecode 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UnmJDyc7alQJ.
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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
Hmm, I'd seen this solution in 
http://keeyai.com/2012/02/17/django-deployment-create-superuser-fails-with-locale-error/
 
but was reluctant to use this as " I have no idea if this causes any 
negative side effects."
So that is the official repair?
OK.
Thanks!

Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>
> Regards,
> Bob
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LbEFlfhWbVoJ.
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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
Umm, could you be more specific about how/where to put this?
All the combinations and location I could think of will all still give the 
same error...



Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>
> Regards,
> Bob
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/shAajf44XV4J.
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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-14 Thread Bob Aalsma
The command & error from createsuperuser:
macpro1:dripFeedSite bobaalsma$ python manage.py createsuperuser
Traceback (most recent call last):
  File "manage.py", line 19, in 
execute_from_command_line(sys.argv)
  File 
"/Library/Python/2.7/site-packages/django/core/management/__init__.py", 
line 443, in execute_from_command_line
utility.execute()
  File 
"/Library/Python/2.7/site-packages/django/core/management/__init__.py", 
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", 
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", 
line 232, in execute
output = self.handle(*args, **options)
  File 
"/Library/Python/2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
 
line 70, in handle
default_username = get_default_username()
  File 
"/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", 
line 105, in get_default_username
default_username = get_system_username()
  File 
"/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", 
line 85, in get_system_username
return getpass.getuser().decode(locale.getdefaultlocale()[1])
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", 
line 503, in getdefaultlocale
return _parse_localename(localename)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", 
line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Funny thing here is that "unknown locale: UTF-8" because yesterday the 
missing locale was connected to the language setting (although I don't 
recall the literal text)

Some settings do go right, though:
macpro1:dripFeedSite bobaalsma$ python manage.py shell
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import os
>>> os.environ
{'LC_CTYPE': 'UTF-8', 'TERM_PROGRAM_VERSION': '303.2', 'LOGNAME': 
'bobaalsma', 'USER': 'bobaalsma', 'PATH': 
'/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin',
 
'HOME': '/Users/bobaalsma', 'DISPLAY': '/tmp/launch-v6JEoW/org.x:0', 
'TERM_PROGRAM': 'Apple_Terminal', 'LANG': 'nl-NL', 'TERM': 
'xterm-256color', 'Apple_PubSub_Socket_Render': 
'/tmp/launch-h01Q9P/Render', 'TZ': 'Europe/Amsterdam', 'SHLVL': '1', 
'TMPDIR': '/var/folders/c8/j7h0mxjn7x993xm51xqyfplwgn/T/', 
'TERM_SESSION_ID': '5CEEB33C-3AC2-475C-807B-3A3909952D3F', 'SSH_AUTH_SOCK': 
'/tmp/launch-H5Mr23/Listeners', 'SHELL': '/bin/bash', '_': 
'/Library/Frameworks/Python.framework/Versions/2.7/bin/python', 'OLDPWD': 
'/Users/bobaalsma', '__CF_USER_TEXT_ENCODING': '0x1F5:0:5', 
'Apple_Ubiquity_Message': '/tmp/launch-iTRGIn/Apple_Ubiquity_Message', 
'PWD': '/Users/bobaalsma/Programmatuurontwikkeling/DripFeed/dripFeedSite', 
'DJANGO_SETTINGS_MODULE': 'dripFeedSite.settings', 'COMMAND_MODE': 
'unix2003'}

I'm not really sure what to do here: obviously creating a superuser is not 
an everyday thing, so maybe an other route will suffice. On the other hand: 
this situation feels like an unpredictable system :((





Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>
> Regards,
> Bob
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/I0tSu_BgzHQJ.
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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-14 Thread Bob Aalsma
macpro1:~ bobaalsma$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
macpro1:~ bobaalsma$ python -c 'import locale; print 
locale.getdefaultlocale()'
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", 
line 503, in getdefaultlocale
return _parse_localename(localename)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", 
line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
macpro1:~ bobaalsma$ LANG="nl_NL.UTF-8" python -c'import locale ; print 
locale.getdefaultlocale()' 
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", 
line 503, in getdefaultlocale
return _parse_localename(localename)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", 
line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Op vrijdag 14 september 2012 11:17:24 UTC+2 schreef Tom Evans het volgende:
>
> On Fri, Sep 14, 2012 at 8:52 AM, Bob Aalsma 
> > 
> wrote: 
> > The command & error from createsuperuser: 
> > macpro1:dripFeedSite bobaalsma$ python manage.py createsuperuser 
> > … 
>
> Can I ask you to try some things, just to see how your environment is 
> setup. All of these commands run on the bash shell as a regular user. 
>
> 1) The output of running "locale". Hopefully OS X has this, it should 
> show your current locale settings, as OS X sees them. Eg: 
>
> > $ locale 
> LANG=en_GB.UTF-8 
> LC_CTYPE="en_GB.UTF-8" 
> LC_COLLATE="en_GB.UTF-8" 
> LC_TIME="en_GB.UTF-8" 
> LC_NUMERIC="en_GB.UTF-8" 
> LC_MONETARY="en_GB.UTF-8" 
> LC_MESSAGES="en_GB.UTF-8" 
> LC_ALL= 
>
> 2) What does python see as your locale as? Full output from this command: 
>
> > $ python -c 'import locale ; print locale.getdefaultlocale()' 
> ('en_GB', 'UTF-8') 
>
> 3) How about this variant - attempting to coerce the correct lang: 
>
> > $ LANG="nl_NL.UTF-8" python -c 'import locale ; print 
> locale.getdefaultlocale()' 
> ('nl_NL', 'UTF-8') 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/TgI2QVXz9NMJ.
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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-14 Thread Bob Aalsma
SOLVED by Tom Evans:
insert 
unset LC_CTYPE ; export LANG="nl_NL.UTF-8"
into .bash_profile



Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>
> Regards,
> Bob
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Lb8favCcs-YJ.
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: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-14 Thread Bob Aalsma
Well, I have tried your suggestion in all places I could think of and none 
of those helped: the createsuperuser kept returning the same error message. 
I posted this as a reply some 24 hours ago.

 


Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>
> Regards,
> Bob
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WnCSyDEH9WYJ.
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.



Newbie: do I need to upload in order to access data?

2013-08-10 Thread Bob Aalsma
Hi,

I'm trying to achieve the following:

   - user indicates a file on his/her machine 
   - the program opens the file, reads the data and acts on that


So far, I can find examples of indicating the file on the user's machine, 
but this is always combined with saving to database (which I don't want); 
the clearest example I could find 
is 
http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example

Question 1: is it really necessary to store the data in my database?

If not, I've not been able to find how to actually open and read the file.
I've been trying out variations on reading, based on what I could find in 
the Tutorials and Managing files 
(https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem to 
understand how to actually find the path and filename the user would have 
indicated. I seem to get completely lost in FileField and FieldFile and 
connected methods 

Question 2: how do I find the indicated path and filename from the user?

Regards,
Bob

-- 
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.




Re: Newbie: do I need to upload in order to access data?

2013-08-10 Thread Bob Aalsma
Thanks Nigel, this looks very promising ;)

If I interpret your text correctly, this is based on the upload/save 
example I mentioned.
I'm really interested in the meaning of parts your closing paragraph:

   - "This saves the file in 'media/documents/2013/08/10/datafile.csv'." - 
   I think this means the contents of the file is copied from the user disk to 
   my disk, right? 
   - "pointing them to the correct directory and file." - could I not 
   simply point to the *original* directory and file (on the user's 
   machine) and read the contents from that location?


Regards,
Bob

Op zaterdag 10 augustus 2013 18:39:38 UTC+2 schreef Nigel Legg:
>
> I've based my process a minimal file upload - I think based on the answer 
> to the link above.  I use:
> models.py:
> class Document(models.Model):
> docfile = models.FileField(upload_to='documents/%Y/%m/%d')
>
> views.py:
> def list(request):
> # Handle file uploadf
> if request.method == 'POST':
> form = DocumentForm(request.POST, request.FILES)
> if form.is_valid():
> newdoc = Document(docfile = request.FILES['docfile'])
> newdoc.save()
>
> # Redirect to the document list after POST
> return 
> HttpResponseRedirect(reverse('myproject.myapp.views.list'))
> else:
> form = DocumentForm() # A empty, unbound form
>
> # Load documents for the list page
> documents = Document.objects.all()
>
> # Render list page with the documents and the form
> return render_to_response(
> 'myapp/list.html',
> {'documents': documents, 'form': form},
> context_instance=RequestContext(request)
> )
>
> forms.py:
> class DocumentForm(forms.Form):
> docfile = forms.FileField(
> label='Select a file',
> help_text='max. 42 megabytes'
> )
>
> This saves the file in 'media/documents/2013/08/10/datafile.csv'.  You can 
> then access this using the normal open() and read() functions, pointing 
> them to the correct directory and file.  As far as I can see, the data 
> remains in the file you upload, but the location and name are stored in the 
> database - in this case, "documents/2013/10/08/datafile.csv". 
>
> Hope this helps 
>
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 10 August 2013 15:52, Bob Aalsma >wrote:
>
>> Hi,
>>
>> I'm trying to achieve the following:
>>
>>- user indicates a file on his/her machine 
>>- the program opens the file, reads the data and acts on that 
>>
>>
>> So far, I can find examples of indicating the file on the user's machine, 
>> but this is always combined with saving to database (which I don't want); 
>> the clearest example I could find is 
>> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
>>
>> Question 1: is it really necessary to store the data in my database?
>>
>> If not, I've not been able to find how to actually open and read the file.
>> I've been trying out variations on reading, based on what I could find in 
>> the Tutorials and Managing files (
>> https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem 
>> to understand how to actually find the path and filename the user would 
>> have indicated. I seem to get completely lost in FileField and FieldFile 
>> and connected methods 
>>
>> Question 2: how do I find the indicated path and filename from the user?
>>
>> Regards,
>> Bob
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
 

-- 
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.




Re: Newbie: do I need to upload in order to access data?

2013-08-11 Thread Bob Aalsma
Thanks Nigel.

OK, at least this has stopped me running around in circles and I can continue 
from here.

I would think you can do stuff client side, but this is probably more Python 
and less Django - to be solved in future releases ;)

Regards,
Bob

Op 11 aug. 2013, om 00:10 heeft Nigel Legg  het volgende 
geschreven:

> The file is uploaded - ie it is copied onto the server drive.  
> I don't think you can do stuff client side with Django - beyond my knowledge. 
> 
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
> 
> 
> 
> On 10 August 2013 18:04, Bob Aalsma  wrote:
> Thanks Nigel, this looks very promising ;)
> 
> If I interpret your text correctly, this is based on the upload/save example 
> I mentioned.
> I'm really interested in the meaning of parts your closing paragraph:
> "This saves the file in 'media/documents/2013/08/10/datafile.csv'." - I think 
> this means the contents of the file is copied from the user disk to my disk, 
> right? 
> "pointing them to the correct directory and file." - could I not simply point 
> to the original directory and file (on the user's machine) and read the 
> contents from that location?
> 
> Regards,
> Bob
> 
> Op zaterdag 10 augustus 2013 18:39:38 UTC+2 schreef Nigel Legg:
> I've based my process a minimal file upload - I think based on the answer to 
> the link above.  I use:
> models.py:
> class Document(models.Model):
> docfile = models.FileField(upload_to='documents/%Y/%m/%d')
> 
> views.py:
> def list(request):
> # Handle file uploadf
> if request.method == 'POST':
> form = DocumentForm(request.POST, request.FILES)
> if form.is_valid():
> newdoc = Document(docfile = request.FILES['docfile'])
> newdoc.save()
> 
> # Redirect to the document list after POST
> return HttpResponseRedirect(reverse('myproject.myapp.views.list'))
> else:
> form = DocumentForm() # A empty, unbound form
> 
> # Load documents for the list page
> documents = Document.objects.all()
> 
> # Render list page with the documents and the form
> return render_to_response(
> 'myapp/list.html',
> {'documents': documents, 'form': form},
> context_instance=RequestContext(request)
> )
> 
> forms.py:
> class DocumentForm(forms.Form):
> docfile = forms.FileField(
> label='Select a file',
> help_text='max. 42 megabytes'
> )
> 
> This saves the file in 'media/documents/2013/08/10/datafile.csv'.  You can 
> then access this using the normal open() and read() functions, pointing them 
> to the correct directory and file.  As far as I can see, the data remains in 
> the file you upload, but the location and name are stored in the database - 
> in this case, "documents/2013/10/08/datafile.csv". 
> 
> Hope this helps 
> 
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
> 
> 
> 
> On 10 August 2013 15:52, Bob Aalsma  wrote:
> Hi,
> 
> I'm trying to achieve the following:
> user indicates a file on his/her machine 
> the program opens the file, reads the data and acts on that
> 
> So far, I can find examples of indicating the file on the user's machine, but 
> this is always combined with saving to database (which I don't want); the 
> clearest example I could find is 
> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
> 
> Question 1: is it really necessary to store the data in my database?
> 
> If not, I've not been able to find how to actually open and read the file.
> I've been trying out variations on reading, based on what I could find in the 
> Tutorials and Managing files 
> (https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem to 
> understand how to actually find the path and filename the user would have 
> indicated. I seem to get completely lost in FileField and FieldFile and 
> connected methods 
> 
> Question 2: how do I find the indicated path and filename from the user?
> 
> Regards,
> Bob
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
> To post to this group, send email to django

Re: Newbie: do I need to upload in order to access data?

2013-08-11 Thread Bob Aalsma
Hi Tom,

OK, thanks.

The file I'd want to read is a parameter file which contains user specific 
information. I just need to know the data to guide the actions, no need to 
store or keep it.
So I'll just accept the upload, extract the data and then delete the upload.
Oh well ;)

Regards,
Bob

-- 
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.


Getting NoReverseMatch and can't find the mistake

2015-11-17 Thread Bob Aalsma
Sorry, can't seem to find what's wrong here, please help: what am I 
missing???

I'm seeing
NoReverseMatch at /zoekopdrachten/4/resultaat/

Reverse for 'resultaat' with arguments '('',)' and keyword arguments '{}' not 
found. 1 pattern(s) tried: 
[u'zoekopdrachten/(?P[0-9]+)/resultaat/$']

Request Method:GETRequest URL:
http://127.0.0.1:8000/zoekopdrachten/4/resultaat/Django Version:1.8.5Exception 
Type:NoReverseMatchException Value:

Reverse for 'resultaat' with arguments '('',)' and keyword arguments '{}' not 
found. 1 pattern(s) tried: 
[u'zoekopdrachten/(?P[0-9]+)/resultaat/$']

Exception 
Location:/Library/Python/2.7/site-packages/django/core/urlresolvers.py 
in _reverse_with_prefix, line 495Python Executable:/usr/bin/pythonPython 
Version:2.7.10


with *views.py*:
"""
zoekopdrachten: views.py

"""

from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.core.urlresolvers import reverse

from .models import KlantOrganisatie, ZoekVraag, ZoekVraagLocatie

#
#   Index - overzicht van opdrachtgever, contactpersonen en zoekvragen
def index(request):
organisatie_lijst = 
KlantOrganisatie.objects.order_by('klant_organisatie_naam')
context = {'organisatie_lijst': organisatie_lijst}
return render(request, 'zoekopdrachten/index.html', context)


#
#   Klantverwerking - contactpersoon noteert oordeel en motivatie bij 
aangeboden zoekresultaten
def klantverwerking(request, zoekvraag_id):
vraag = get_object_or_404(ZoekVraag, pk=zoekvraag_id)
return render(request, 'zoekopdrachten/klantverwerking.html', {'vraag': 
vraag})


#
#   Resultaat - inlezen zoekresultaten en opnemen in database bij 
ZoekVraagResultaat
def resultaat(request, zoekvraag_id):
vraag = get_object_or_404(ZoekVraag, pk=zoekvraag_id)
try:
keuze = 
vraag.zoekvraaglocatie_set.get(pk=request.POST['zoekvraaglocatie'])
except (KeyError, ZoekVraagLocatie.DoesNotExist):
return render(request, 'zoekopdrachten/vraag.html', {
'vraag': vraag,
'error_message': 'Ongeldige keuze of zoiets',
})
else:
keuze.zoek_vraag_locatie = 'kippenfarm'
keuze.save()
return 
HttpResponseRedirect(reverse('zoekopdrachten:zelfverwerking.html', 
args=(vraag.id,)))


#
#   Vraag - details van de zoekvraag
def vraag(request, zoekvraag_id):
vraag = get_object_or_404(ZoekVraag, pk=zoekvraag_id)
return render(request, 'zoekopdrachten/vraag.html', {'vraag': vraag})


#
#   Zelfverwerking - opnemen zoekresultaten in databsae plus eigen 
beoordeling
def zelfverwerking(request, zoekvraag_id):
vraag = get_object_or_404(ZoekVraag, pk=zoekvraag_id)
return render(request, 'zoekopdrachten/zelfverwerking.html', {'vraag': 
vraag})

and *urls.py*:
""" 
zoekopdrachten: urls.py

"""

from django.conf.urls import url

from . import views

urlpatterns = [
# ex: /zoekopdrachten/
url(r'^$', views.index, name='index'),
# ex: /zoekopdrachten/5/
url(r'^(?P[0-9]+)/$', views.vraag, name='vraag'),
# ex: /zoekopdrachten/5/zelfverwerking/
url(r'^(?P[0-9]+)/zelfverwerking/$', 
views.zelfverwerking, name='zelfverwerking'),
# ex: /zoekopdrachten/5/klantverwerking/
url(r'^(?P[0-9]+)/klantverwerking/$', 
views.klantverwerking, name='klantverwerking'),
# ex: /zoekopdrachten/5/resultaat/
url(r'^(?P[0-9]+)/resultaat/$', views.resultaat, 
name='resultaat'),
]


and *vraag.html*:
Zoekvraag "{{ vraag.zoekvraag_id }}"

{% if error_message %}
{{ error_message }}

{% endif %}

Verzamelen resultaten

{% csrf_token %}
{% for term in vraag.zoekvraagterm_set.all %}

1
{% endfor %}












-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d6e5eb3f-c7bc-4890-8c31-c5622f6a9bb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting NoReverseMatch and can't find the mistake

2015-11-19 Thread Bob Aalsma
Really sorry Tom, I've been looking at your text and thinking about it for 
most of today, but no penny dropping. 
I'm rather unsure which bits go where, I'm trying to understand this by 
rebuilding the tutorial.

I can't seem to get my head around this 'reverse()' part: the reverse() as 
such is used in the HttpResponseRedirect statement whereas the error seems 
to be caused by the form statement in vraag.html - how do these things 
connect?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/59230d07-badd-4c1c-b664-f0b26db9a68b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting NoReverseMatch and can't find the mistake

2015-11-19 Thread Bob Aalsma
Umm, one of the things I've found difficult is to determine the logic in 
the translation of the class names in models.py to other variables.

And I'm sorry to have not included the models.py. This is the part of 
ZoekVraag:

class ZoekVraag(models.Model):
vrager = models.ForeignKey(KlantContactPersoon)
vraag_naam = models.CharField("naam vraag", max_length=200)
vraag_omschrijving = models.TextField("omschrijving vraag", blank = 
True)
vraag_taktiek = models.TextField("taktiek oplossing vraag", blank = 
True)

def __unicode__(self):
return self.vraag_naam

class Meta:
verbose_name = 'zoekvraag'
verbose_name_plural = 'zoekvragen'

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7990e791-d7fa-404f-a776-5bde2522a7a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting NoReverseMatch and can't find the mistake

2015-11-20 Thread Bob Aalsma
Cheers Daniel, I'll review, modify and try again!

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/191e8384-4c40-401f-8e3b-385bb2d42bb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting NoReverseMatch and can't find the mistake

2015-11-20 Thread Bob Aalsma
How big can a smile be?

Works! 
Thanks!

Bob

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/33464546-fd1d-4b5f-8b66-2e65d8844fff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


testing newbie - help requested: app works, tests give errors

2023-05-10 Thread 'Bob Aalsma' via Django users
I'm trying to test a django-admin command and don't understand why the 
tests give errors on the code while the code works as expected.

I'm under the impression that the *raise CommandError* is ignored by the 
test, but don't understand why this would be.

Please help.

Running the code shows:

(.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
populate_source 0

*CommandError: Alleen hele getallen > 0 toegestaan*

(.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
populate_source 1

*Teksten zijn gegenereerd voor tekstlengte 1*

(.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
populate_source 1

*CommandError: Teksten voor nummer 1 zijn al eerder gegenereerd*

(.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
populate_source 7

*CommandError: Opgegeven sleutel 7 niet gevonden*

Running the tests shows

(.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py test 
tests.test_sources_app_command_populate

Found 3 test(s).

Creating test database for alias 'default'...

System check identified no issues (0 silenced).

EEE

==

ERROR: test_command_output_been_there 
(tests.test_sources_app_command_populate.PopulateSourceTests.test_command_output_been_there)

Test for failure: in_use = True.

--

Traceback (most recent call last):

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/utils.py",
 
line 89, in _execute

return self.cursor.execute(sql, params)

   

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py",
 
line 328, in execute

return super().execute(query, params)

   ^^

sqlite3.IntegrityError: NOT NULL constraint failed: 
domain_sources_app_characternumber.number_of_combinations


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


Traceback (most recent call last):

  File 
"/Users/werker/Projects/domain_reader/tests/test_sources_app_command_populate.py",
 
line 30, in test_command_output_been_there

thingy.save()

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
 
line 814, in save

self.save_base(

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
 
line 877, in save_base

updated = self._save_table(

  ^

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
 
line 1020, in _save_table

results = self._do_insert(

  

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
 
line 1061, in _do_insert

return manager._insert(

   

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/manager.py",
 
line 87, in manager_method

return getattr(self.get_queryset(), name)(*args, **kwargs)

   ^^^

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/query.py",
 
line 1805, in _insert

return query.get_compiler(using=using).execute_sql(returning_fields)

   ^

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/sql/compiler.py",
 
line 1820, in execute_sql

cursor.execute(sql, params)

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/utils.py",
 
line 67, in execute

return self._execute_with_wrappers(

   

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/utils.py",
 
line 80, in _execute_with_wrappers

return executor(sql, params, many, context)

   

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/utils.py",
 
line 84, in _execute

with self.db.wrap_database_errors:

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/utils.py",
 
line 91, in __exit__

raise dj_exc_value.with_traceback(traceback) from exc_value

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/utils.py",
 
line 89, in _execute

return self.cursor.execute(sql, params)

   

  File 
"/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py",
 
line 328, in execute

return super().execute(query, para

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread 'Bob Aalsma' via Django users
Sorry Vishesh, thanks for the quick answer but I have no idea what you mean.

On Wednesday, May 10, 2023 at 2:00:51 PM UTC+2 Vishesh Mangla wrote:

> False or True check for yourself.
>
> On Wed, 10 May, 2023, 17:29 Vishesh Mangla,  wrote:
>
>> It looks like you are passing a null but null=False is not set
>>
>> On Wed, 10 May, 2023, 17:27 'Bob Aalsma' via Django users, <
>> django...@googlegroups.com> wrote:
>>
>>> I'm trying to test a django-admin command and don't understand why the 
>>> tests give errors on the code while the code works as expected.
>>>
>>> I'm under the impression that the *raise CommandError* is ignored by 
>>> the test, but don't understand why this would be.
>>>
>>> Please help.
>>>
>>> Running the code shows:
>>>
>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>> populate_source 0
>>>
>>> *CommandError: Alleen hele getallen > 0 toegestaan*
>>>
>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>> populate_source 1
>>>
>>> *Teksten zijn gegenereerd voor tekstlengte 1*
>>>
>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>> populate_source 1
>>>
>>> *CommandError: Teksten voor nummer 1 zijn al eerder gegenereerd*
>>>
>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>> populate_source 7
>>>
>>> *CommandError: Opgegeven sleutel 7 niet gevonden*
>>>
>>> Running the tests shows
>>>
>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py test 
>>> tests.test_sources_app_command_populate
>>>
>>> Found 3 test(s).
>>>
>>> Creating test database for alias 'default'...
>>>
>>> System check identified no issues (0 silenced).
>>>
>>> EEE
>>>
>>> ==
>>>
>>> ERROR: test_command_output_been_there 
>>> (tests.test_sources_app_command_populate.PopulateSourceTests.test_command_output_been_there)
>>>
>>> Test for failure: in_use = True.
>>>
>>> --
>>>
>>> Traceback (most recent call last):
>>>
>>>   File 
>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/utils.py",
>>>  
>>> line 89, in _execute
>>>
>>> return self.cursor.execute(sql, params)
>>>
>>>
>>>
>>>   File 
>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py",
>>>  
>>> line 328, in execute
>>>
>>> return super().execute(query, params)
>>>
>>>^^
>>>
>>> sqlite3.IntegrityError: NOT NULL constraint failed: 
>>> domain_sources_app_characternumber.number_of_combinations
>>>
>>>
>>> The above exception was the direct cause of the following exception:
>>>
>>>
>>> Traceback (most recent call last):
>>>
>>>   File 
>>> "/Users/werker/Projects/domain_reader/tests/test_sources_app_command_populate.py",
>>>  
>>> line 30, in test_command_output_been_there
>>>
>>> thingy.save()
>>>
>>>   File 
>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
>>>  
>>> line 814, in save
>>>
>>> self.save_base(
>>>
>>>   File 
>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
>>>  
>>> line 877, in save_base
>>>
>>> updated = self._save_table(
>>>
>>>   ^
>>>
>>>   File 
>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
>>>  
>>> line 1020, in _save_table
>>>
>>> results = self._do_insert(
>>>
>>>   
>>>
>>>   File 
>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/models/base.py",
>>>  

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread &#x27;Bob Aalsma' via Django users
Ah, yes, thanks.

I hesitate to comment on "If I understood the error right." ;)

Umm, my problem here is that I think I'm using the exact same *code* 
"manually" without errors. 
I think I'm also using the same *values* for the manual and test runs.
So I don't understand the reason for the differences in output.

On Wednesday, May 10, 2023 at 2:18:33 PM UTC+2 Vishesh Mangla wrote:

> If I understood the error right.
>
> On Wed, May 10, 2023 at 5:47 PM Vishesh Mangla  
> wrote:
>
>> Probably this would help: 
>> https://stackoverflow.com/questions/8609192/what-is-the-difference-between-null-true-and-blank-true-in-django
>>
>> On Wed, May 10, 2023 at 5:45 PM 'Bob Aalsma' via Django users <
>> django...@googlegroups.com> wrote:
>>
>>> Sorry Vishesh, thanks for the quick answer but I have no idea what you 
>>> mean.
>>>
>>> On Wednesday, May 10, 2023 at 2:00:51 PM UTC+2 Vishesh Mangla wrote:
>>>
>>>> False or True check for yourself.
>>>>
>>>> On Wed, 10 May, 2023, 17:29 Vishesh Mangla,  
>>>> wrote:
>>>>
>>>>> It looks like you are passing a null but null=False is not set
>>>>>
>>>>> On Wed, 10 May, 2023, 17:27 'Bob Aalsma' via Django users, <
>>>>> django...@googlegroups.com> wrote:
>>>>>
>>>>>> I'm trying to test a django-admin command and don't understand why 
>>>>>> the tests give errors on the code while the code works as expected.
>>>>>>
>>>>>> I'm under the impression that the *raise CommandError* is ignored by 
>>>>>> the test, but don't understand why this would be.
>>>>>>
>>>>>> Please help.
>>>>>>
>>>>>> Running the code shows:
>>>>>>
>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>> populate_source 0
>>>>>>
>>>>>> *CommandError: Alleen hele getallen > 0 toegestaan*
>>>>>>
>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>> populate_source 1
>>>>>>
>>>>>> *Teksten zijn gegenereerd voor tekstlengte 1*
>>>>>>
>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>> populate_source 1
>>>>>>
>>>>>> *CommandError: Teksten voor nummer 1 zijn al eerder gegenereerd*
>>>>>>
>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>> populate_source 7
>>>>>>
>>>>>> *CommandError: Opgegeven sleutel 7 niet gevonden*
>>>>>>
>>>>>> Running the tests shows
>>>>>>
>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>> test tests.test_sources_app_command_populate
>>>>>>
>>>>>> Found 3 test(s).
>>>>>>
>>>>>> Creating test database for alias 'default'...
>>>>>>
>>>>>> System check identified no issues (0 silenced).
>>>>>>
>>>>>> EEE
>>>>>>
>>>>>> ==
>>>>>>
>>>>>> ERROR: test_command_output_been_there 
>>>>>> (tests.test_sources_app_command_populate.PopulateSourceTests.test_command_output_been_there)
>>>>>>
>>>>>> Test for failure: in_use = True.
>>>>>>
>>>>>> --
>>>>>>
>>>>>> Traceback (most recent call last):
>>>>>>
>>>>>>   File 
>>>>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/utils.py",
>>>>>>  
>>>>>> line 89, in _execute
>>>>>>
>>>>>> return self.cursor.execute(sql, params)
>>>>>>
>>>>>>
>>>>>>
>>>>>>   File 
>>>>>> "/Users/werker/Projects/domain_reader/.venv/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py",
>>>>>>  
&g

Re: testing newbie - help requested: app works, tests give errors

2023-05-10 Thread &#x27;Bob Aalsma' via Django users
Hmm, when I remove the raise CommandError statement and replace it with 
self.stdout.write, everything works well.

This helps me to point further studies. Thx!
On Wednesday, May 10, 2023 at 2:33:18 PM UTC+2 Bob Aalsma wrote:

> Ah, yes, thanks.
>
> I hesitate to comment on "If I understood the error right." ;)
>
> Umm, my problem here is that I think I'm using the exact same *code* 
> "manually" without errors. 
> I think I'm also using the same *values* for the manual and test runs.
> So I don't understand the reason for the differences in output.
>
> On Wednesday, May 10, 2023 at 2:18:33 PM UTC+2 Vishesh Mangla wrote:
>
>> If I understood the error right.
>>
>> On Wed, May 10, 2023 at 5:47 PM Vishesh Mangla  
>> wrote:
>>
>>> Probably this would help: 
>>> https://stackoverflow.com/questions/8609192/what-is-the-difference-between-null-true-and-blank-true-in-django
>>>
>>> On Wed, May 10, 2023 at 5:45 PM 'Bob Aalsma' via Django users <
>>> django...@googlegroups.com> wrote:
>>>
>>>> Sorry Vishesh, thanks for the quick answer but I have no idea what you 
>>>> mean.
>>>>
>>>> On Wednesday, May 10, 2023 at 2:00:51 PM UTC+2 Vishesh Mangla wrote:
>>>>
>>>>> False or True check for yourself.
>>>>>
>>>>> On Wed, 10 May, 2023, 17:29 Vishesh Mangla,  
>>>>> wrote:
>>>>>
>>>>>> It looks like you are passing a null but null=False is not set
>>>>>>
>>>>>> On Wed, 10 May, 2023, 17:27 'Bob Aalsma' via Django users, <
>>>>>> django...@googlegroups.com> wrote:
>>>>>>
>>>>>>> I'm trying to test a django-admin command and don't understand why 
>>>>>>> the tests give errors on the code while the code works as expected.
>>>>>>>
>>>>>>> I'm under the impression that the *raise CommandError* is ignored 
>>>>>>> by the test, but don't understand why this would be.
>>>>>>>
>>>>>>> Please help.
>>>>>>>
>>>>>>> Running the code shows:
>>>>>>>
>>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>>> populate_source 0
>>>>>>>
>>>>>>> *CommandError: Alleen hele getallen > 0 toegestaan*
>>>>>>>
>>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>>> populate_source 1
>>>>>>>
>>>>>>> *Teksten zijn gegenereerd voor tekstlengte 1*
>>>>>>>
>>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>>> populate_source 1
>>>>>>>
>>>>>>> *CommandError: Teksten voor nummer 1 zijn al eerder gegenereerd*
>>>>>>>
>>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>>> populate_source 7
>>>>>>>
>>>>>>> *CommandError: Opgegeven sleutel 7 niet gevonden*
>>>>>>>
>>>>>>> Running the tests shows
>>>>>>>
>>>>>>> (.venv) werker@Werkers-Mac-mini domain_reader % python3 manage.py 
>>>>>>> test tests.test_sources_app_command_populate
>>>>>>>
>>>>>>> Found 3 test(s).
>>>>>>>
>>>>>>> Creating test database for alias 'default'...
>>>>>>>
>>>>>>> System check identified no issues (0 silenced).
>>>>>>>
>>>>>>> EEE
>>>>>>>
>>>>>>>
>>>>>>> ==
>>>>>>>
>>>>>>> ERROR: test_command_output_been_there 
>>>>>>> (tests.test_sources_app_command_populate.PopulateSourceTests.test_command_output_been_there)
>>>>>>>
>>>>>>> Test for failure: in_use = True.
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>>
>>>&g