Wednesday, November 2, 2011

Re: "python manage.py runserver" creates not tables (tutorial)

Sorry, title is supposed to be "python manage.py runserver" creates no
tables (tutorial)

On Nov 2, 10:42 am, angelika <angelika.ols...@gmail.com> wrote:
> I've started the Django tutorial and I get as far as running python
> manage.py runserver, but when I do, nothing happens. I get no messages
> and the database connected to the project is still empty. The database
> exists and I've made no modifications to any of the files created,
> accept for the info to connect to the database. My settings.py has
> this snippet in it:
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
>     # Uncomment the next line to enable the admin:
>     # 'django.contrib.admin',
>     # Uncomment the next line to enable admin documentation:
>     # 'django.contrib.admindocs',
> )
>
> If django is not able to find or connect to the database, I would
> expect there to be at least an error message, right? Is there a
> command I can run make sure? Any other ideas?
>
> /Angelika

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: "python manage.py runserver" creates not tables (tutorial)

did u do a syncdb ?
On 02-Nov-2011, at 3:12 PM, angelika wrote:

> I've started the Django tutorial and I get as far as running python
> manage.py runserver, but when I do, nothing happens. I get no messages
> and the database connected to the project is still empty. The database
> exists and I've made no modifications to any of the files created,
> accept for the info to connect to the database. My settings.py has
> this snippet in it:
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> # 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> # 'django.contrib.admindocs',
> )
>
> If django is not able to find or connect to the database, I would
> expect there to be at least an error message, right? Is there a
> command I can run make sure? Any other ideas?
>
> /Angelika
>
> --
> 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+unsubscribe@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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

"python manage.py runserver" creates not tables (tutorial)

I've started the Django tutorial and I get as far as running python
manage.py runserver, but when I do, nothing happens. I get no messages
and the database connected to the project is still empty. The database
exists and I've made no modifications to any of the files created,
accept for the info to connect to the database. My settings.py has
this snippet in it:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)

If django is not able to find or connect to the database, I would
expect there to be at least an error message, right? Is there a
command I can run make sure? Any other ideas?

/Angelika

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Calling Python from JavaScript

I will explain what i'm trying to achieve, I'm using Dajaxice with
Django.

I created modelformset which consist of multiple forms. Each form has
dropdown field on which I'm calling dajaxice function, that function
will takes the value of the dropdown field and calls another python
function which calculates the total sum of all the values of dropdown
fields. Here my formset has initial values. So I want to call that
python function (which calculates result ) in javascript code (This
javascript function is for dajaxice )


Regards

Asif

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: tutorial error

On Wednesday, 2 November 2011 07:24:39 UTC, rihad wrote:
It says at the end of part 3 of the Django tutorial:

"The idea behind include() and URLconf decoupling is to make it easy
to plug-and-play URLs. Now that polls are in their own URLconf, they
can be placed under "/polls/", or under "/fun_polls/", or under "/
content/polls/", or any other path root, and the app will still work."

It's actually not that simple. Simply changing the project-wide
URLconf prefix from '^polls/' to '^fun_polls/' will not work, because
the code referencing templates still has polls in its path:
render_to_response('polls/detail.html', {'poll': p})
or in URLs:
<a href="/polls/{{ poll.id }}/">{{ poll.question }}</a>

Your first point is simply not true. Changing the urlconf prefix does not in any way affect how you reference the template path. You could prefix the polls URLs with 'foobar', but the template path would still be 'polls'.

The second point is made irrelevant by something that's not covered in the tutorial, but is mentioned in the actual documentation for URLs: you should never hard-code URLs, you should use the `{% url %}` tag in templates or the `reverse()` function in views - for precisely this reason.
--
DR.

--
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/-/rgGqV4vyzw0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

tutorial error

It says at the end of part 3 of the Django tutorial:

"The idea behind include() and URLconf decoupling is to make it easy
to plug-and-play URLs. Now that polls are in their own URLconf, they
can be placed under "/polls/", or under "/fun_polls/", or under "/
content/polls/", or any other path root, and the app will still work."

It's actually not that simple. Simply changing the project-wide
URLconf prefix from '^polls/' to '^fun_polls/' will not work, because
the code referencing templates still has polls in its path:
render_to_response('polls/detail.html', {'poll': p})
or in URLs:
<a href="/polls/{{ poll.id }}/">{{ poll.question }}</a>

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Tuesday, November 1, 2011

Re: Image Model, Form and View -> Easily change "upload_to" path from form.save()?

I'm not sure if there's a better solution, but here's one I kind of
came up with after reading into the documentation and some other
Discussions. Let me know if there's a better solution out there.
Hopefully this will help someone else out as well.

from django.db import models
from django.contrib.auth.models import User

# Provides the Path for User Images
def user_image_folder(instance = None, filename = None):
return 'uploaded/' + instance.user.username + '/images/' +
filename

class Image(models.Model):

date_created = models.DateField(auto_now_add = True)
user = models.ForeignKey(User)
# Note: upload_to is referencing the above function in the same
file.
data = models.ImageField(upload_to = user_image_folder)

On Nov 1, 10:55 pm, Kurtis <kurtis.mull...@gmail.com> wrote:
> Hey,
>
> I've got a very simple setup for a sample application. Basically, I
> have a Model w/ an ImageField. I have a ModelForm using that Model.
> Finally, I have a FormView for using that Form.
>
> In my View, I call my form's .save() method and pass along the request
> user. I'd like to manipulate where this file is stored.
>
> Here's what I tried so far but it did *not* work -- the thing just
> uses the preset upload_to variable.
>
> ImageForm.save(self, user):
>
>     # Grab Model Instance
>     m = super(ImageForm, self).save(commit = False)
>
>     # Try to Change "upload_to" Value
>     # Note: "data" is the name of my ImageField
>     m.data.upload_to = 'some_other_folder'
>
>     # Save the Model
>     m.save()
>
>     # Done
>     return m

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.