Re: "Building you first Django app, Part 1" example not working

2008-12-21 Thread mrtot

Hi Chris,

maybe it's the best to just do what the error message suggest:

"Please fill out DATABASE_NAME in the settings module before using the
database. "

Put in something like '/home/chris/projects/django-tutorial/db/db.db'

You can create your own name. Django just wants to know where it
should store the database.
No need to install MySQL for your local sandboxes :)

Greets,
Martin

On 21 Dez., 12:40, Chris  wrote:
> Okay... I'm on part two of the tut now and I am attemping to use
> Python's built-in SQLite Database just to get a feel for Django.
> However, the tutorial confuses me in part one when it defines
> DATABASE_NAME, "The name of your database. If you're using SQLite, the
> database will be a file on your computer; in that case, DATABASE_NAME
> should be the full absolute path, including filename, of that file. If
> the file doesn't exist, it will automatically be created when you
> synchronize the database for the first time (see below)."
>
> It say, "see below," but all that is below is the reference, "If
> you're using SQLite, you don't need to create anything beforehand -
> the database file will be created automatically when it is needed."
> which is wonderful, but I recieve the error shown below when I try to
> run the admin interface, as I haven't specified the DATABASE_NAME. How
> can I if I don't know where it was created?
>
> Anyway, here's my error. Running almost any other command at the promt
> gives me an error ending with "ImproperlyConfigured: Please fill out
> DATABASE_NAME in the settings module before using the database.", but
> the error shown when I try to run the admin is included below...
>
> ---
>
> Traceback (most recent call last):
>
>   File "/Library/Python/2.5/site-packages/django/core/servers/
> basehttp.py", line 278, in run
>     self.result = application(self.environ, self.start_response)
>
>   File "/Library/Python/2.5/site-packages/django/core/servers/
> basehttp.py", line 635, in __call__
>     return self.application(environ, start_response)
>
>   File "/Library/Python/2.5/site-packages/django/core/handlers/
> wsgi.py", line 243, in __call__
>     response = middleware_method(request, response)
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> middleware.py", line 35, in process_response
>     request.session.save()
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/db.py", line 52, in save
>     session_key = self.session_key,
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/base.py", line 152, in _get_session_key
>     self._session_key = self._get_new_session_key()
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/base.py", line 144, in _get_new_session_key
>     if not self.exists(session_key):
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/db.py", line 25, in exists
>     Session.objects.get(session_key=session_key)
>
>   File "/Library/Python/2.5/site-packages/django/db/models/
> manager.py", line 93, in get
>     return self.get_query_set().get(*args, **kwargs)
>
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 304, in get
>     num = len(clone)
>
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 160, in __len__
>     self._result_cache = list(self.iterator())
>
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 275, in iterator
>     for row in self.query.results_iter():
>
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 206, in results_iter
>     for rows in self.execute_sql(MULTI):
>
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 1733, in execute_sql
>     cursor = self.connection.cursor()
>
>   File "/Library/Python/2.5/site-packages/django/db/backends/
> __init__.py", line 56, in cursor
>     cursor = self._cursor(settings)
>
>   File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 139, in _cursor
>     raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> settings module before using the database."
>
> ImproperlyConfigured: Please fill out DATABASE_NAME in the settings
> module before using the database.
>
> ---
>
> Pretty much the same as the errors I'm getting at the command line...
> Any insight would be appreciated - I think I'll just install MySQL
> locally and use that, as SQLite sounds like a limiting pain in the
> ass... Verification on this? Anyway, any help is greatly appreciated -
> you Django people are awesome.
>
> Best,
>
> Chris
>
> On Dec 21, 2:20 am, Chris  wrote:
>
> > Thanks Jeff - I've figured it out no

Re: invalid literal for int() with base 10 trying to access uploaded image

2008-10-01 Thread mrtot

Hi Kelvin,

I just ran into that problem, too.
However the hint to MEDIA_URL was correct!

You must add the following to the very bottom of your urls.py:

if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': 'd:sites/sgms/media'}),
)

This is described here:
http://docs.djangoproject.com/en/dev/howto/static-files/

Greetz,
M

On 20 Sep., 16:07, "kelvin pompey" <[EMAIL PROTECTED]> wrote:
> ok I've set the MEDIA_URL and MEDIA_ROOT, but when I click the link I get
> the 404 file not found error message. If i set ADMIN_MEDIA_PREFIX to a blank
> string then I can access the link. But there is a problem, when I try to
> change the image through the form I get a page does not exist error
> message.
> My current settings are
>
> MEDIA_ROOT = 'd:sites/sgms/media/'
> MEDIA_URL = 'http://localhost:8000/media/'
> ADMIN_MEDIA_PREFIX = '/media/'
>
> and the model
>
> class Student(models.Model):
>     photo = models.ImageField(upload_to='photos')
>
> I am using the automatic admin site.
>
> On Sat, Sep 20, 2008 at 7:22 AM, Srik <[EMAIL PROTECTED]> wrote:
>
> > Make sure you have MEDIA_URL set :)
>
> > Run into similar error, setting MEDIA_URL resolved it :)
>
> > On Sep 18, 1:17 pm, "silk.odyssey" <[EMAIL PROTECTED]> wrote:
> > > I am using an imagefield from the admin interface. I can upload images
> > > without problems but when I click the link to view the image, I get
> > > the following error.
>
> > > invalid literal for int() with base 10: '1/photos/desktop.png'
>
> > > Any idea what's wrong? I am using django 1.0.
>
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---