Re: Change label/title from an application added to django admin

2012-12-23 Thread donarb


On Sunday, December 23, 2012 6:02:45 PM UTC-8, Ankush Chadda wrote:
>
> Hi,
> Look at the Meta options verbose_name and verbose_name_plural
>
> Using these you can change the display name in admin.
>
>

Those are for the displaying the model names, not the app name.
 

-- 
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/-/PtzRhZ7Me50J.
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: Trouble Accessing An Image through ImageField

2012-12-23 Thread Ankush
Hi,

I think , first of all, you should have  tags around the url. .

if you are able to get the image if you direct your browser to
http://192.0.0.1:8000/images/photo.jpg ? if yes, then the above is the
solution .
If not then you should set your image files to be served as setatic files.

This might help . https://docs.djangoproject.com/en/1.2/howto/static-files/

Cheers,



On Mon, Dec 24, 2012 at 12:07 AM, That guy  wrote:

> Hi there,
>
> I'm trying to create a photo gallery by storing photos in a gallery
> database and pulling them out when appropriate.
>
> However, I ran into the problem of how to publicly expose the pictures in
> urls. In my template, I return a the url of the photo which turns out to be
> images/photo.jpg. However in my development server, when I put in the url
> 192.0.0.1:8000/images/photo.jpg, I can't view the image. Is there any way
> to make the url/image accessible through the url provided by the object
> without manually tampering with urls.py? If not, why does Django provide
> the .url field? Is this the only a recommended url field then?
>
> My View:
>
> def gallery(request):
> base_gallery = gall.objects.get(name="base")
> base_list = base_gallery.photos.all()
> return render_to_response('gallery.html',
> {'list_of_images':base_list},
> context_instance = RequestContext(request),
> )
>
> Template:
>
> {% extends "index.html" %}{% block body_content %}
> {% for photo in list_of_images %}
> {{ photo.image.url }}{% endfor %}{% endblock %}
>
> Model:
>
> from django.db import models
> class photo(models.Model):
> name = models.CharField(max_length=50,blank=True,null=True)
> source_descr = models.CharField(max_length=100,blank=True,null=True)
> image = models.ImageField(upload_to='images')
>
> class gallery(models.Model):
> name = models.CharField(max_length=50)
> photos = models.ManyToManyField(photo)
>
>  --
> 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/-/crmJYuBCBfgJ.
> 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.
>



-- 
With Regards,
Ankush Chadda

-- 
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: Change label/title from an application added to django admin

2012-12-23 Thread ankush . chadda
Hi,
Look at the Meta options verbose_name and verbose_name_plural

Using these you can change the display name in admin.

Cheers,
Ankush Chadda
Sent from BlackBerry® on Airtel

-Original Message-
From: Emiliano Dalla Verde Marcozzi <65647...@gmail.com>
Sender: django-users@googlegroups.com
Date: Sun, 23 Dec 2012 14:02:21 
To: 
Reply-To: django-users@googlegroups.com
Subject: Change label/title from an application added to django admin

Hello,
I created an app called 'emp' with the command: django-admin.py startapp 
emp.
Then, i edited my models.py, added an admin.py file to register my 
clases/models
in the django admin. Now, when i login into the django admin, i have a list 
of
Applications, and it says 'Emp' in that list. I want to change 'Emp' for 
another word,
for example, 'Employee', how can i do that in django 1.4 ? 
Thanks in advance,
Emiliano.

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


-- 
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: Django asset management and dynamically created databases

2012-12-23 Thread Chad Vernon
Yes the single database was my original and preferred design. I will
try to push for that design. I think there was concern about
reliability and performance of everything in one database but I don't
think that will be an issue given our needs.

Thanks,
Chad

From: Mike Dewhirst
Sent: 12/23/2012 4:59 PM
To: django-users@googlegroups.com
Subject: Re: Django asset management and dynamically created databases
On 24/12/2012 8:10am, Chad Vernon wrote:
> Hi there,
> I'm designing a database for an animation studio to track assets across
> multiple shows.  We potentially would want each show to have its own
> database, however we would want functionality to search for assets
> across all shows.

It would *much* simpler to put it all in a single database. In my
personal opinion, there would need to be a strong business case for
multiple databases to justify the added complexity.

I am exploring the use of django as the main
> framework for this system as it would provide a nice front and back end
> interface that is easy to build upon.  Is it possible in django to
> dynamically create a new show database when a new show is created in the
> admin interface of the main database?  How would I then get the
> settings.py to pick this up dynamically?

Yes it is possible and indeed easy provided you don't want a separate
database per show. Much easier to add a separate record in a "show" table.

>
> The only reference I've found is this which seems to go against the
> advice of the django devs:
> http://stackoverflow.com/questions/6585373/django-multiple-and-dynamic-databases

Always go with the flow rather than try and make something work against
the design.

Good luck

Mike

>
> Is django appropriate for this purpose?  Am I approaching this all
> wrong?  Thanks for your help and please forgive my limited django knowledge.
>
> Chad
>
> --
> 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/-/z58OGDKAXCoJ.
> 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.

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

-- 
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: Django asset management and dynamically created databases

2012-12-23 Thread Mike Dewhirst

On 24/12/2012 8:10am, Chad Vernon wrote:

Hi there,
I'm designing a database for an animation studio to track assets across
multiple shows.  We potentially would want each show to have its own
database, however we would want functionality to search for assets
across all shows.


It would *much* simpler to put it all in a single database. In my 
personal opinion, there would need to be a strong business case for 
multiple databases to justify the added complexity.


I am exploring the use of django as the main

framework for this system as it would provide a nice front and back end
interface that is easy to build upon.  Is it possible in django to
dynamically create a new show database when a new show is created in the
admin interface of the main database?  How would I then get the
settings.py to pick this up dynamically?


Yes it is possible and indeed easy provided you don't want a separate 
database per show. Much easier to add a separate record in a "show" table.




The only reference I've found is this which seems to go against the
advice of the django devs:
http://stackoverflow.com/questions/6585373/django-multiple-and-dynamic-databases


Always go with the flow rather than try and make something work against 
the design.


Good luck

Mike



Is django appropriate for this purpose?  Am I approaching this all
wrong?  Thanks for your help and please forgive my limited django knowledge.

Chad

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


--
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: Change label/title from an application added to django admin

2012-12-23 Thread Mike Dewhirst

On 24/12/2012 9:02am, Emiliano Dalla Verde Marcozzi wrote:

Hello, I created an app called 'emp' with the command:
django-admin.py startapp emp. Then, i edited my models.py, added an
admin.py file to register my clases/models in the django admin. Now,
when i login into the django admin, i have a list of Applications,
and it says 'Emp' in that list. I want to change 'Emp' for another
word, for example, 'Employee', how can i do that in django 1.4 ?
Thanks in advance, Emiliano.


The software is easy but the database might be a bit harder. In the 
database the tablenames all begin with the app name followed by an 
underscore and then the model name.


If it was me (and not knowing any better) I would replicate emp as 
employee right alongside and change the source to nominate employee as 
the app name. Add employee as another app and manage.py syncdb again.


That would give you a second app alongside emp in the admin.

Depending on how much data you have, you could dump from emp and load 
into employee or simply re-enter your data.


When everything is working, drop emp.

Mike



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


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



Change label/title from an application added to django admin

2012-12-23 Thread Emiliano Dalla Verde Marcozzi
Hello,
I created an app called 'emp' with the command: django-admin.py startapp 
emp.
Then, i edited my models.py, added an admin.py file to register my 
clases/models
in the django admin. Now, when i login into the django admin, i have a list 
of
Applications, and it says 'Emp' in that list. I want to change 'Emp' for 
another word,
for example, 'Employee', how can i do that in django 1.4 ? 
Thanks in advance,
Emiliano.

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



Trouble Accessing An Image through ImageField

2012-12-23 Thread That guy
 

Hi there,

I'm trying to create a photo gallery by storing photos in a gallery 
database and pulling them out when appropriate.

However, I ran into the problem of how to publicly expose the pictures in 
urls. In my template, I return a the url of the photo which turns out to be 
images/photo.jpg. However in my development server, when I put in the url 
192.0.0.1:8000/images/photo.jpg, I can't view the image. Is there any way 
to make the url/image accessible through the url provided by the object 
without manually tampering with urls.py? If not, why does Django provide 
the .url field? Is this the only a recommended url field then?

My View:

def gallery(request):
base_gallery = gall.objects.get(name="base")
base_list = base_gallery.photos.all()
return render_to_response('gallery.html',
{'list_of_images':base_list},
context_instance = RequestContext(request),
)

Template:

{% extends "index.html" %}{% block body_content %}
{% for photo in list_of_images %}
{{ photo.image.url }}{% endfor %}{% endblock %}

Model:

from django.db import models
class photo(models.Model):
name = models.CharField(max_length=50,blank=True,null=True)
source_descr = models.CharField(max_length=100,blank=True,null=True)
image = models.ImageField(upload_to='images')

class gallery(models.Model):
name = models.CharField(max_length=50)
photos = models.ManyToManyField(photo)

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



Very Odd Query problem

2012-12-23 Thread Gerald Klein
Hi all, I have a custom model mapped to a view, a join between a
UserContact model which carries contacts for users and UserContactEmail
which is the emails for the contacts. Very simple join.

select concat(`t1`.`id`,'-',`t2`.`id`) AS `id`,
`t2`.`usercontact_id` AS `usercontact_id`,
`t1`.`user_id` AS `user_id`,
`t1`.`first_name` AS `first_name`,
`t1`.`last_name` AS `last_name`,
`t1`.`is_locked` AS `is_locked`,
`t1`.`manual_enter` AS `manual_enter`,
`t1`.`is_trusted_contact` AS `is_trusted_contact`,
`t1`.`is_admin` AS `is_admin`,
`t2`.`email` AS `email`
from (`auththis_usercontact` `t1` join `auththis_usercontactemail` `t2`
on((`t1`.`id` = `t2`.`usercontact_id`)))$$

The Corresponding model is

class View_UserContactEmail(models.Model):
id = models.CharField(max_length=23, primary_key=True)
usercontact_id = models.IntegerField()
user_id = models.IntegerField()
first_name = models.CharField('First name', max_length=30, blank=True)
last_name = models.CharField('Last name', max_length=30, blank=True)
is_locked = models.BooleanField("Locked", default=False)
manual_enter = models.BooleanField("Hand Entered", default=False)
is_trusted_contact = models.BooleanField("Trusted contact",
default=False)
is_admin = models.BooleanField("Admin", default=False)
email = models.EmailField("Email", max_length=75,unique=True)
class Meta:
verbose_name = "User Contact Email"
verbose_name_plural = "User Contact Emails"
db_table = 'view_usercontactemail'
def __unicode__(self):
return "{0}: {1} {2} {3}".format(self.user, self.first_name,
self.last_name, self.email)

The django query:

usercontactemails = View_UserContactEmail.objects.filter(user_id=user.pk
).filter(email='first_na...@firstname1.com')
django result:

first_na...@firstname1.com 1 firstname1 last_name1
first_na...@firstname1.com 3 first_name3 last_name3

the above columns are email, first name, last name



Mysql: Turns back 1 row as it should but django turns back 2 rows 1 with
false data

mysql> select * from view_usercontactemail where email='
first_na...@firstname2.com' and user_id=1;
+-++-+-++---+--++--++
| id  | usercontact_id | user_id | first_name  | last_name  | is_locked |
manual_enter | is_trusted_contact | is_admin | email  |
+-++-+-++---+--++--++
| 2-3 |  2 |   1 | first_name2 | last_name2 | 0 |
 1 |  1 |0 | first_na...@firstname2.com |
+-++-+-++---+--++--++


Mysql is correct so maybe I am wrong, can someone please take a look and
see if they see something.

PS the weird id column in the view is to accommodate django's need for a
primary key

thanks



--jerry



Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580

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



Django asset management and dynamically created databases

2012-12-23 Thread Chad Vernon
Hi there,
I'm designing a database for an animation studio to track assets across 
multiple shows.  We potentially would want each show to have its own 
database, however we would want functionality to search for assets across 
all shows.  I am exploring the use of django as the main framework for this 
system as it would provide a nice front and back end interface that is easy 
to build upon.  Is it possible in django to dynamically create a new show 
database when a new show is created in the admin interface of the main 
database?  How would I then get the settings.py to pick this up dynamically?

The only reference I've found is this which seems to go against the advice 
of the django devs:
http://stackoverflow.com/questions/6585373/django-multiple-and-dynamic-databases

Is django appropriate for this purpose?  Am I approaching this all wrong? 
 Thanks for your help and please forgive my limited django knowledge.

Chad

-- 
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/-/z58OGDKAXCoJ.
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: django.db.utils.DatabaseError: (1046, 'No database selected')

2012-12-23 Thread Praveenkumar Venkatesan
Thanks mate. This was a great reply.

-Praveen

On Sunday, December 23, 2012 8:00:51 AM UTC-8, Ramiro Morales wrote:
>
> On Sun, Dec 23, 2012 at 12:59 PM, Ramiro Morales 
>  
> wrote: 
> > On Sun, Dec 23, 2012 at 6:45 AM, Praveenkumar Venkatesan 
> >  wrote: 
> >> Hey All, 
> >> 
> >> I was walking through the tutorial part 1 on polls. When i executed 
> "python 
> >> manage.py sql polls" i got this stack trace 
> >> 
> >> Traceback (most recent call last): 
> >>  [...] 
> >> django.db.utils.DatabaseError: (1046, 'No database selected') 
> >> 
> >> I've been googling and everyone says that i don't have access to the 
> mysql 
> >> database for "polls" but i was able to access the database when i 
> entered 
> >> mysql -u root -h localhost polls 
> >> 
> >> This is how my settings.py looks like for database: 
> >> 
> >> DATABASES = { 
> >> 'default': { 
> >> 'ENGINE': 'django.db.backends.mysql', # Add 
> 'postgresql_psycopg2', 
> >> 'mysql', 'sqlite3' or 'oracle'. 
> >> 'NAME': '',  # Or path to database file if 
> using sqlite3. 
> > 
> > It sems you have correctly created a MySQL database, you've given it 
> > the name 'test' and you've verified it exist adn can be used. Good. 
> > 
> > You've also provided Django presumably the right server name (localhost) 
> > and credentials (root/empty) so it can access such database. Great. 
> > 
> > But there is a crucial link missing. You haven't told Django you want it 
> to use 
> > that database fotr this project/application. 
> > 
> > That's what the NAME setting above is for. Use it. 
>
> Forgot to say that this is clearly derscribed in the relevant tutorial 
> section: 
>
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/#database-setup 
>
> -- 
> Ramiro Morales 
>

-- 
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/-/w-6clyjn_mgJ.
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.



Setting urls from project

2012-12-23 Thread Filipe Manuel
I wish that when from accessing localhost:8000/cadastro he showed a form to 
register, but all the urls I click redirects to the same page. I wonder how 
pegging the url with the url of the application. I've Identified the error, 
all urls design guide for single views of the application, but do not know 
how to fix it.

My code: http://dpaste.com/850276/

-- 
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/-/SWL7s2TlaLUJ.
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: django.db.utils.DatabaseError: (1046, 'No database selected')

2012-12-23 Thread Ramiro Morales
On Sun, Dec 23, 2012 at 12:59 PM, Ramiro Morales  wrote:
> On Sun, Dec 23, 2012 at 6:45 AM, Praveenkumar Venkatesan
>  wrote:
>> Hey All,
>>
>> I was walking through the tutorial part 1 on polls. When i executed "python
>> manage.py sql polls" i got this stack trace
>>
>> Traceback (most recent call last):
>>  [...]
>> django.db.utils.DatabaseError: (1046, 'No database selected')
>>
>> I've been googling and everyone says that i don't have access to the mysql
>> database for "polls" but i was able to access the database when i entered
>> mysql -u root -h localhost polls
>>
>> This is how my settings.py looks like for database:
>>
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2',
>> 'mysql', 'sqlite3' or 'oracle'.
>> 'NAME': '',  # Or path to database file if using 
>> sqlite3.
>
> It sems you have correctly created a MySQL database, you've given it
> the name 'test' and you've verified it exist adn can be used. Good.
>
> You've also provided Django presumably the right server name (localhost)
> and credentials (root/empty) so it can access such database. Great.
>
> But there is a crucial link missing. You haven't told Django you want it to 
> use
> that database fotr this project/application.
>
> That's what the NAME setting above is for. Use it.

Forgot to say that this is clearly derscribed in the relevant tutorial section:

https://docs.djangoproject.com/en/1.4/intro/tutorial01/#database-setup

-- 
Ramiro Morales

-- 
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: django.db.utils.DatabaseError: (1046, 'No database selected')

2012-12-23 Thread Ramiro Morales
On Sun, Dec 23, 2012 at 6:45 AM, Praveenkumar Venkatesan
 wrote:
> Hey All,
>
> I was walking through the tutorial part 1 on polls. When i executed "python
> manage.py sql polls" i got this stack trace
>
> Traceback (most recent call last):
>  [...]
> django.db.utils.DatabaseError: (1046, 'No database selected')
>
> I've been googling and everyone says that i don't have access to the mysql
> database for "polls" but i was able to access the database when i entered
> mysql -u root -h localhost polls
>
> This is how my settings.py looks like for database:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2',
> 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': '',  # Or path to database file if using 
> sqlite3.

It sems you have correctly created a MySQL database, you've given it
the name 'test' and you've verified it exist adn can be used. Good.

You've also provided Django presumably the right server name (localhost)
and credentials (root/empty) so it can access such database. Great.

But there is a crucial link missing. You haven't told Django you want it to use
that database fotr this project/application.

That's what the NAME setting above is for. Use it.

The eror message isn't as clear as one would wish, I think it's generated by
the MySQL low level driver. But it points in the right direction about which
is the issue.

Good luck,

-- 
Ramiro Morales

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



django.db.utils.DatabaseError: (1046, 'No database selected')

2012-12-23 Thread Praveenkumar Venkatesan
Hey All,

I was walking through the tutorial part 1 on polls. When i executed "*python 
manage.py sql polls*" i got this stack trace
*
*
*Traceback (most recent call last):*
*  File "manage.py", line 10, 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/core/management/base.py", 
line 304, in handle*
*app_output = self.handle_app(app, **options)*
*  File 
"/Library/Python/2.7/site-packages/django/core/management/commands/sql.py", 
line 19, in handle_app*
*return u'\n'.join(sql_create(app, self.style, 
connections[options.get('database')])).encode('utf-8')*
*  File "/Library/Python/2.7/site-packages/django/core/management/sql.py", 
line 26, in sql_create*
*tables = connection.introspection.table_names()*
*  File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", 
line 910, in table_names*
*return self.get_table_list(cursor)*
*  File 
"/Library/Python/2.7/site-packages/django/db/backends/mysql/introspection.py", 
line 33, in get_table_list*
*cursor.execute("SHOW TABLES")*
*  File "/Library/Python/2.7/site-packages/django/db/backends/util.py", 
line 40, in execute*
*return self.cursor.execute(sql, params)*
*  File 
"/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 
114, in execute*
*return self.cursor.execute(query, args)*
*  File 
"/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/cursors.py",
 
line 202, in execute*
*self.errorhandler(self, exc, value)*
*  File 
"/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/connections.py",
 
line 36, in defaulterrorhandler*
*raise errorclass, errorvalue*
*django.db.utils.DatabaseError: (1046, 'No database selected')*

I've been googling and everyone says that i don't have access to the mysql 
database for "polls" but i was able to access the database when i entered 
*mysql 
-u root -h localhost polls*

This is how my settings.py looks like for database:

*DATABASES = {*
*'default': {*
*'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 
'mysql', 'sqlite3' or 'oracle'.*
*'NAME': '',  # Or path to database file if 
using sqlite3.*
*'USER': 'root',  # Not used with sqlite3.*
*'PASSWORD': '',  # Not used with sqlite3.*
*'HOST': 'localhost',  # Set to empty string 
for localhost. Not used with sqlite3.*
*'PORT': '',  # Set to empty string for 
default. Not used with sqlite3.*
*}*
*}*

Also, here is to show that i actually selected the database

*mysql> use test*
*Database changed*
*mysql> GRANT ALL ON test.* TO 'testuser'@'localhost';*
*Query OK, 0 rows affected (0.08 sec)*
*
*
*mysql> quit*
*Bye*

my mac has been finicky with databases on RoR and so i am trying to switch 
to django. Does anyone know where the problem is?

-Praveen

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