Chris Czub | 1 May 02:40 2010
Picon

Re: newbie problem -- cant import library

Are you running that command from the interactive shell invoked by  
running 'python manage.py shell'?

Invoking the interactive shell that way should set up all your python  
library settings properly for your Django app.

On Apr 30, 2010, at 5:44 PM, Mark Serva <ServaM <at> lerner.udel.edu> wrote:

> I am running django 1.1.1 under ubuntu, and am going through jeff
> forcier's book on django development.  I have a new project called
> mysite, which contains an app called blog.  The problem I am having is
> getting the shell to recognize mysite.  I would like to query my
> database and follow the examples in the book, but when I try to enter:
>
> from mysite.blog.models import BlogPost
>
> the shell gives me the following error:
>
> Traceback (most recent call last):
>  File "<pyshell#15>", line 1, in <module>
>    from mysite.blog import BlogPost
> ImportError: No module named mysite.blog
>
> It seems like there is something wrong with the configuration, but I
> cant pin down what it is.  Many thanks for any help.
>
> Mark
>
> -- 
> You received this message because you are subscribed to the Google  
(Continue reading)

Chris Czub | 1 May 02:41 2010
Picon

Re: newbie problem -- cant import library

Oh... Actually looking at the error that was spit out, it looks like you made a typo. 

Your error says you typed  'from mysite.blog import BlogPost'. 


On Apr 30, 2010, at 5:44 PM, Mark Serva <ServaM <at> lerner.udel.edu> wrote:

from mysite.blog import BlogPost

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

Continuation | 1 May 03:16 2010
Picon

Re: Is it safe to alter Django generated tables in MySQL to have composite PK?


On Apr 29, 1:56 pm, Leo <leovi... <at> gmail.com> wrote:
> In Django, the best current option I know of is:
>
> from django.db import models
> class AuctionBid(models.Model):
>

Your response seems to have been cut off.

Could you re-post? Thanks.

--

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

Nick Arnett | 1 May 03:42 2010
Picon

Re: Is it safe to alter Django generated tables in MySQL to have composite PK?



On Wed, Apr 28, 2010 at 8:09 PM, Continuation <selforganized <at> gmail.com> wrote:
I'm using MySQL with Django.

MySQL uses clustered index. I have a class AuctionBid for which the
"natural" PK is (user_id, auction_id).

I'd like to set (user_id, aucton_id) as the PK so that it'll be the
clustered index. I understand that Django doesn't support composite
PK. But what if after syncdb I just ALTER TABLE to make (user_id,
aucton_id) the PK. Would that work with Django or would that introduce
some unwanted behavior under the hood?

If you don't have data in the table, just drop it and use "unique_together" in models.py to define your composite key.  You'll find that in the Django docs.  Then do syncdb and Django will create the table with your composite key.

Otherwise, you can make the change in models.py, as above, and change the PK manually.

If there are FKs involved, you might also want to make the appropriate changes if you're not re-creating all the involved tables with syncdb.

One other route, if you have data, is to rename the existing tables (can be tricky with FKs), then syncdb and then copy your data... or, even easier, create a whole new database with syncdb and copy your data into it.

Nick

--
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
kandee | 1 May 04:16 2010
Picon

i need help with this...

I just got this new phone, and was trying to download some sound
affects, from a download Page, but an error page came on and said that
I needed to go on my django setting file and change it to false so it
can display 500 pages...but I didn't find it anywhere, so I Googled it
amd it brang me here... and I was trying to download django, but it
wouldn't let me...I really want to look at those sound affects. ..can
you help me...?..

--

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

Karen Tracey | 1 May 04:36 2010
Picon

Re: Unique set of fields in a model

On Fri, Apr 30, 2010 at 5:08 PM, cornflake <ilya.kogan <at> gmail.com> wrote:

Hello,
I'm looking for a way to define uniquness for a set of more than one
field in a model.
For example:

class Item(models.Model):
       order = models.ForeignKey(Order)
       number = models.IntegerField()
       ...

I want the number to be unique per order, and not unique throughout
the table.
How do I define that the combination <order, number> should be unique?

--
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Dj Gilcrease | 1 May 05:00 2010
Picon

Re: django_audit 0.0.2

On Fri, Apr 30, 2010 at 9:28 AM, Gustavo Narea
<gnarea <at> tech.2degreesnetwork.com> wrote:
> Sorry, but did you know there's already a project with that name?
> https://launchpad.net/django-audit

Ya I saw the announcement on it the day I pushed my code to google,
hence my remark about not being tied to a "NoSQL" solution. I had
already created the project name by the time I saw the announcement so
just went with it

--

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

Ilya Kogan | 1 May 07:15 2010
Picon

Re: Unique set of fields in a model

Thank you very much, this is just what I needed!

2010/5/1 Karen Tracey <kmtracey <at> gmail.com>
On Fri, Apr 30, 2010 at 5:08 PM, cornflake <ilya.kogan <at> gmail.com> wrote:
Hello,
I'm looking for a way to define uniquness for a set of more than one
field in a model.
For example:

class Item(models.Model):
       order = models.ForeignKey(Order)
       number = models.IntegerField()
       ...

I want the number to be unique per order, and not unique throughout
the table.
How do I define that the combination <order, number> should be unique?

--
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> 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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
akonsu | 1 May 07:45 2010
Picon

models as a package

hello,

i would like to replace my models.py with a package that has a
hierarchical directory structure. in __init__.py i want to define my
base models, and the other files would contain models that inherit the
base models.

in particular i am trying to define proxy models for my models and put
them in to separate files.

the problem is that the user admin system's "change user" screen does
not list the permissions for proxies if they are located in separate
files. if i put proxy classes in to __init__.py and re-run syncdb,
then the permissions get listed. otherwise not. i tried creating
__all__ array in my __init__.py that includes the proxy files, and i
tried importing the files in to __init__.py to no avail.

how can this be done?

thanks
konstantin

--

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

zayatzz | 1 May 08:51 2010
Picon

Re: Problem with letters like ÄÖÕÜ in django admin

Hi

On Apr 30, 6:54 pm, Bill Freeman <ke1g... <at> gmail.com> wrote:
> Just to be clear, the entity coding exists in the database?  It's a unicode
> or byte string containing sequences beginning with ampersand, ending
> with semi colon, having just lowercase English letters between them?

Actually my mistake here. The stuff that went into database via
tinymce was with &otilde;'s and so on.

The Grill P\xc3\xb5rsas Meremeeste moodi from pastebin page is name of
one Retsept and is in database like this:Grill Põrsas Meremeeste
moodi.

Retsept model was this:
lass Retsept(models.Model):
        name = models.CharField(max_length=100,
verbose_name=_("Name"), blank=False, null=False)
        user = models.ForeignKey(User)
        image = RemovableImageField(upload_to=content_file_name,
blank=True, null=True, verbose_name=_("Image"))
        about = tinymce_models.HTMLField(verbose_name=_("Enter the
description of the food"),blank=False, null=False)
        rating = models.DecimalField(max_digits=4, decimal_places=2,
default=0)
        views = models.PositiveIntegerField(default=0)
        tags = TagField()
        published = models.BooleanField(default=False)
        visible = models.BooleanField(default=True)
        def __unicode__(self):
                return self.name

and form, that saves it was this:
class RetseptForm(ModelForm):
        about = forms.CharField(widget=TinyMCE(attrs={'style': 'width:
370px', 'rows': 15, 'theme':"simple"}), label = _("text here"),
required=False)
        tags = TagField(label = _("tags"),
widget=TagAutocomplete(attrs={'class':'required'}))
        name = forms.CharField(label = _("Name"),
widget=forms.TextInput(attrs={'class':'required'}))
        class Meta:
                model = Retsept
                fields = ('name', 'about', 'image', 'tags',)
                widgets = {
                        'name': TextInput(attrs={'class':
'required' })
                }
>
> Because, if so, by the time it gets to items_for_result() (I think) in
> /usr/local/lib/python2.6/dist-packages/django/contrib/admin/templatetags/ad min_list.py
> those entities have been converted to UTF-8 encodings of Unicode code points.
> If my decoding is correct, that sequence "\xc3\xb5" translates to 0x00F5, which
> is "latin small letter o with tilde".

Yep, you were correct.

>
> If you're comfortable driving pdb,

Nope, i guess, since i know what pdb stands for :P I ran a google
search and now i know what you were talking about

> I'd like to know what you find if you place a
> conditional breakpoint in that function and poke around.  I presume that you
> know the attribute name of the field containing that data.  I'll use
> 'foo' below,
> replace it with the actual attribute name.   Between these two lines:
>
>                 if field_val is not None:
>                     result_repr = escape(getattr(result, f.name))
>
> (lines 180 and 181 in the version of the file I have handy) put:
>
>                     if f.attname == 'foo':
>                         import pdb; pdb.set_trace()

Im having trouble figuring out where i should put this pdb stuff. I
downloaded last trunk of django 1.2beta and my admin_list.py is
somewhat different than the one you have. lines 180, 181 there are :

    if form:
        yield mark_safe(u'<td>%s</td>' %
force_unicode(form[cl.model._meta.pk.name]))

I can find the lines you mention in the old django, but stuff in new
admin_list.py is :
            else:
                if value is None:
                    result_repr = EMPTY_CHANGELIST_VALUE
                if isinstance(f.rel, models.ManyToOneRel):
                    result_repr = escape(getattr(result, f.name))
                else:
                    result_repr = display_for_field(value, f)
                if isinstance(f, models.DateField) or isinstance(f,
models.TimeField):
                    row_class = ' class="nowrap"'

So i guess i should enter your lines after  if isinstance(f.rel,
models.ManyToOneRel): ?

>
> You are, I'm assuming, using manage.py runserver.  

Nope, im using mod_wsgi, but in order to test what you suggest i could
use it.

> It will restart when you
> save the file, or if not, kill it and restart it.  Then refresh the page in the
> browser.  That should make pdb come up on the terminal where you started
> the server.  Then try the following command:
>
> p getattr(result, f.name)
>
> Do you get the entities?  If so, we need to look down in escape.  If you get
> the UTF-8 encodings, then we need to look higher up the stack.
>
> result should be one of your Vote object instances.  You might do a by hand
> query for this on in manage.py shell (using id__exact as a selector, perhaps)
> and see if the value is bad there.  If bad, the problem looks to be in the ORM.
>
> I can't tell more from the stacktrace, since the relevant variable values are
> objects, and the strings are inside them and not displayed in the
> frame varables.
>
> And, of course, I can't easily reproduce this, so you may be on your own to
> debug this.
>
> Bill

--

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


Gmane