Re: Circular import problem

2014-04-16 Thread Johannes Schneider
You can use from foo import bar inside your method/class definitions or 
you can use import foo.bar.


bg,
Johannes

On 16.04.2014 11:37, Daniel Oźminkowski wrote:

Hello,

I recently cut my models.py into separate files and now I try to fix all
the problems with imports that showed up. I hit the wall on this one though.

Purpose of the application is to process a text file with instructions
and fit them into hierarchical structure like this:

Program <- Node <- Commands

Program has many Nodes, Nodes has many commands.

One of the possible Commands is jumping into subprogram. I want to get
url of that subprogram, so I can show it in a template.

During analysis Program calls Node to create nodes. Node then calls
Command to create Commands.

Then later Command takes the id of the subprogram and call
Program.objects.get().get_absolute_url()

How can I break this import chain?

Best regards,
Daniel


--
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/CAEW8F8Kv2GJ_f3mvP0mXhhDYj536%2BWwg6YMESd44efBec90Y3w%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.



--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
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/534E5E10.30103%40galileo-press.de.
For more options, visit https://groups.google.com/d/optout.


Circular import problem

2014-04-16 Thread Daniel Oźminkowski
Hello,

I recently cut my models.py into separate files and now I try to fix all
the problems with imports that showed up. I hit the wall on this one though.

Purpose of the application is to process a text file with instructions and
fit them into hierarchical structure like this:

Program <- Node <- Commands

Program has many Nodes, Nodes has many commands.

One of the possible Commands is jumping into subprogram. I want to get url
of that subprogram, so I can show it in a template.

During analysis Program calls Node to create nodes. Node then calls Command
to create Commands.

Then later Command takes the id of the subprogram and call
Program.objects.get().get_absolute_url()

How can I break this import chain?

Best regards,
Daniel

-- 
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/CAEW8F8Kv2GJ_f3mvP0mXhhDYj536%2BWwg6YMESd44efBec90Y3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Circular import problem

2013-04-13 Thread bubufff
Thank all, I just moved the import to the local function and it works. 
Still re-factoring the codes to overcome this issue completely 

On Friday, April 12, 2013 1:08:26 AM UTC+7, bub...@gmail.com wrote:
>
> Hi all,
>
> I have a util file, which will do some stuffs and then, update a model (so 
> i have to import the models in this file). Also, in my models file, I 
> trigger a post_save signal to call the util file file (so I have to import 
> this file in the models file). Obviously, I will get a circle import 
> problem. Therefore, what is the best practices in this situation ?
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Circular import problem

2013-04-11 Thread Nikolas Stevenson-Molnar
Circular import itself isn't a problem--Python will deal with that.
Problems arise according to the order in which classes, etc. are loaded
from each module and where the required classes are used. As the
previous poster mentioned, you can get around this by moving one of the
import statements inside a function. You can also move one of the
statements to the bottom of the file. Consider two modules:

*bar.py*

from foo import Bar

Class MyBar:
foo_cls = Foo


*and foo.py*

from bar import MyBar

class Foo:
def foo(self):
return MyBar()

This will cause a problem because foo imports from bar, but bar will
need foo.Foo because it's referenced at the top level of the MyBar
definition. However, you can move the import in foo.py to the bottom, so
that bar isn't imported until Foo has been defined.

_Nik

On 4/11/2013 11:08 AM, bubu...@gmail.com wrote:
> Hi all,
>
> I have a util file, which will do some stuffs and then, update a model
> (so i have to import the models in this file). Also, in my models
> file, I trigger a post_save signal to call the util file file (so I
> have to import this file in the models file). Obviously, I will get a
> circle import problem. Therefore, what is the best practices in this
> situation ?
> -- 
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Circular import problem

2013-04-11 Thread andres . osinski
You should always consider that circular imports may indicate problems with how 
you structured your applications and/or models, however, if you're left with no 
choice, you can have an import statement inside a function, which generally 
solves most of these issues.
Enviado desde mi BlackBerry de Movistar (http://www.movistar.com.ar) 

-Original Message-
From: bubu...@gmail.com
Sender: django-users@googlegroups.com
Date: Thu, 11 Apr 2013 11:08:26 
To: <django-users@googlegroups.com>
Reply-To: django-users@googlegroups.com
Subject: Circular import problem

Hi all,

I have a util file, which will do some stuffs and then, update a model (so 
i have to import the models in this file). Also, in my models file, I 
trigger a post_save signal to call the util file file (so I have to import 
this file in the models file). Obviously, I will get a circle import 
problem. Therefore, what is the best practices in this situation ?

-- 
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?hl=en.
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Circular import problem

2013-04-11 Thread bubufff
Hi all,

I have a util file, which will do some stuffs and then, update a model (so 
i have to import the models in this file). Also, in my models file, I 
trigger a post_save signal to call the util file file (so I have to import 
this file in the models file). Obviously, I will get a circle import 
problem. Therefore, what is the best practices in this situation ?

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: import problem

2012-02-17 Thread Furbee
Good point, Dennis. I use Apache2, and any time I modify .py files, I need
to restart the Apache2 daemon. I wish I didn't have to, but the environment
needs to be flushed. Luckily, it doesn't kill the sessions or anything
like, say ColdFusion when it restarts. I was wondering if there was
something with your environment that was using an old copy of the file
without the import, because your syntax sounded perfect. Anyway, I'm glad
you got it figured out!

Furbee

On Thu, Feb 16, 2012 at 6:33 PM, Dennis Lee Bieber wrote:

> On Thu, 16 Feb 2012 21:00:40 -0500, Scott Macri 
> wrote:
>
>
> >Do I need to close IDLE every time I modify one of my object classes
> >being accessed?  I've just been recreating the object in IDLE and not
> >closing the window.  Any thoughts on this?  Thanks.
>
> If the file needs to be imported -- doing edit file/save file/
> "import file", won't affect anything that has references to the previous
> edition of the file. Heck, just "import file" on the second import won't
> do anything -- Python will find that "file" has already been imported
> and reference that module. You have to use a reload operation to get
> changed modules to import a second time. But even this only replaces
> stuff for NEW references; any other references won't see the new
> version.
>
>This is especially true if you are testing in the interactive shell.
> You need to spawn a totally new process to ensure a clean environment
> (which is why some of us keep a command line open next to the
> environment we use for editing [PythonWin, in my case -- I never could
> get comfortable with IDLE]. We edit the file in the IDE, save it, and
> switch to the command shell to run the program cleanly.
> --
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> 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: import problem

2012-02-16 Thread Scott Macri
WEIRD.  There must have been something messed up in my environment.  I
closed IDLE, deleted the dosomething.pyc file and reran the code.  It
seems to be working now.  I didn't make any code changes so maybe
something was in memory, who knows.  I tried deleting the pyc file
before and it didn't do anything.

Do I need to close IDLE every time I modify one of my object classes
being accessed?  I've just been recreating the object in IDLE and not
closing the window.  Any thoughts on this?  Thanks.

On Thu, Feb 16, 2012 at 5:12 PM, Furbee  wrote:
> He said he would do that later tonight.
>
> Furbee
>
>
> On Thu, Feb 16, 2012 at 2:04 PM, Dennis Lee Bieber 
> wrote:
>>
>> On Thu, 16 Feb 2012 13:41:32 -0500, Scott Macri 
>> wrote:
>>
>> >I don't believe I have any circular imports in my code.  I have a
>> >simple file dosomething.py, with a simple class containing a simple
>> >function.
>>
>>        You have yet to show (at least, in the history I've seen) the exact
>> traceback of the error.
>>
>> --
>>        Wulfraed                 Dennis Lee Bieber         AF6VN
>>        wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>>
>> --
>> 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.



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

-- 
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: import problem

2012-02-16 Thread Furbee
He said he would do that later tonight.

Furbee

On Thu, Feb 16, 2012 at 2:04 PM, Dennis Lee Bieber wrote:

> On Thu, 16 Feb 2012 13:41:32 -0500, Scott Macri 
> wrote:
>
> >I don't believe I have any circular imports in my code.  I have a
> >simple file dosomething.py, with a simple class containing a simple
> >function.
>
> You have yet to show (at least, in the history I've seen) the exact
> traceback of the error.
>
> --
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> 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: import problem

2012-02-16 Thread Scott Macri
I don't believe I have any circular imports in my code.  I have a
simple file dosomething.py, with a simple class containing a simple
function.
dosomething.py
def somefunction(some_date)

At the tope of dosomething I have:
import datetime

in the somefunction def I have:
start_date = 
datetime.date(int(some_date[0:4]),int(some_date[5:7]),int(some_date[8:10]))

As soon as the code gets to the line containing start_date it fails.

On Thu, Feb 16, 2012 at 11:38 AM, DrBloodmoney  wrote:
> On Thu, Feb 16, 2012 at 9:20 AM, Scott Macri  wrote:
>> DrBloodmoney I not sure what you mean by circular imports.  datetime
>> is the only import I have in this file.
>
> Here are examples of circular import problems [1][2]
>
> I am forever getting bitten by them, so it's become one of the first
> things that I think about when weird things/bugs happen in Python.
>
> [1] http://effbot.org/zone/import-confusion.htm#circular-imports
> [2] 
> http://stackoverflow.com/questions/1556387/circular-import-dependency-in-python
>
> --
> 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.
>



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

-- 
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: import problem

2012-02-16 Thread DrBloodmoney
On Thu, Feb 16, 2012 at 9:20 AM, Scott Macri  wrote:
> DrBloodmoney I not sure what you mean by circular imports.  datetime
> is the only import I have in this file.

Here are examples of circular import problems [1][2]

I am forever getting bitten by them, so it's become one of the first
things that I think about when weird things/bugs happen in Python.

[1] http://effbot.org/zone/import-confusion.htm#circular-imports
[2] 
http://stackoverflow.com/questions/1556387/circular-import-dependency-in-python

-- 
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: import problem

2012-02-16 Thread scott macri
DrBloodmoney I not sure what you mean by circular imports.  datetime
is the only import I have in this file.

Yes Furbeenator it is a 'datetime' is not defined error.

I'll post the entire error message tonight when I get home.

My website directory is mn and my app directory is hcp.  I'm trying to
do the import on a file in the hcp app directory.  The imports of my
classes (ie from mn.hcp import something) work just fine.  The issue
seems to be with python specific imports.

Thanks.

Oh, the other thing is that if I run the exact same code in my idle
shell within the hcp app all the imports work fine.

On Wed, Feb 15, 2012 at 11:11 PM, Furbee  wrote:
> Can you reply with the actual NameError Exception? Like: NameError: global
> name 'datetime' is not defined, or whatever it is. From the module that is
> throwing this error are you importing anything else that is importing an
> overridden date method or datetime object?
>
> You can also try this (instead of "import datetime"):
>
> from datetime import date
>
> On Wed, Feb 15, 2012 at 7:48 PM, Scott  wrote:
>>
>> Hello,
>> I'm having a strange issue and have already spent an hour trying to
>> figure it out.
>>
>> I created a python app called mn.  Then I setup all my models and
>> stuff to work under mn.hcp.  Everything has been working fine until I
>> tried to use date time in a py file in the hcp directory.
>>
>> I've imported datetime, with import date time at the top of my py
>> file.  Then within the file I have a class with an internal method
>> trying to use some date functions.
>>
>> datetime.date(2003,11,11)
>>
>> For some reason I am getting a NameError on the datetime object.  I
>> don't understand why this is happening after I've imported datetime.
>> Any help would be appreciated.  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@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: import problem

2012-02-16 Thread Scott Macri
Oh, the other thing is that if I run the exact same code in my idle
shell within the hcp app all the imports work fine.

On Thu, Feb 16, 2012 at 9:20 AM, Scott Macri  wrote:
> DrBloodmoney I not sure what you mean by circular imports.  datetime
> is the only import I have in this file.
>
> Yes Furbeenator it is a 'datetime' is not defined error.
>
> I'll post the entire error message tonight when I get home.
>
> My website directory is mn and my app directory is hcp.  I'm trying to
> do the import on a file in the hcp app directory.  The imports of my
> classes (ie from mn.hcp import something) work just fine.  The issue
> seems to be with python specific imports.
>
> Thanks.
>
> On Wed, Feb 15, 2012 at 11:11 PM, Furbee  wrote:
>> Can you reply with the actual NameError Exception? Like: NameError: global
>> name 'datetime' is not defined, or whatever it is. From the module that is
>> throwing this error are you importing anything else that is importing an
>> overridden date method or datetime object?
>>
>> You can also try this (instead of "import datetime"):
>>
>> from datetime import date
>>
>> On Wed, Feb 15, 2012 at 7:48 PM, Scott  wrote:
>>>
>>> Hello,
>>> I'm having a strange issue and have already spent an hour trying to
>>> figure it out.
>>>
>>> I created a python app called mn.  Then I setup all my models and
>>> stuff to work under mn.hcp.  Everything has been working fine until I
>>> tried to use date time in a py file in the hcp directory.
>>>
>>> I've imported datetime, with import date time at the top of my py
>>> file.  Then within the file I have a class with an internal method
>>> trying to use some date functions.
>>>
>>> datetime.date(2003,11,11)
>>>
>>> For some reason I am getting a NameError on the datetime object.  I
>>> don't understand why this is happening after I've imported datetime.
>>> Any help would be appreciated.  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@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.
>
>
>
> --
> Scott A. Macri
> www.ScottMacri.com
> (571) 234-1581



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

-- 
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: import problem

2012-02-16 Thread Scott Macri
DrBloodmoney I not sure what you mean by circular imports.  datetime
is the only import I have in this file.

Yes Furbeenator it is a 'datetime' is not defined error.

I'll post the entire error message tonight when I get home.

My website directory is mn and my app directory is hcp.  I'm trying to
do the import on a file in the hcp app directory.  The imports of my
classes (ie from mn.hcp import something) work just fine.  The issue
seems to be with python specific imports.

Thanks.

On Wed, Feb 15, 2012 at 11:11 PM, Furbee  wrote:
> Can you reply with the actual NameError Exception? Like: NameError: global
> name 'datetime' is not defined, or whatever it is. From the module that is
> throwing this error are you importing anything else that is importing an
> overridden date method or datetime object?
>
> You can also try this (instead of "import datetime"):
>
> from datetime import date
>
> On Wed, Feb 15, 2012 at 7:48 PM, Scott  wrote:
>>
>> Hello,
>> I'm having a strange issue and have already spent an hour trying to
>> figure it out.
>>
>> I created a python app called mn.  Then I setup all my models and
>> stuff to work under mn.hcp.  Everything has been working fine until I
>> tried to use date time in a py file in the hcp directory.
>>
>> I've imported datetime, with import date time at the top of my py
>> file.  Then within the file I have a class with an internal method
>> trying to use some date functions.
>>
>> datetime.date(2003,11,11)
>>
>> For some reason I am getting a NameError on the datetime object.  I
>> don't understand why this is happening after I've imported datetime.
>> Any help would be appreciated.  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@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.



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

-- 
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: import problem

2012-02-15 Thread Furbee
Can you reply with the actual NameError Exception? Like: NameError: globalname
'datetime' is not defined, or whatever it is. From the module that is
throwing this error are you importing anything else that is importing an
overridden date method or datetime object?

You can also try this (instead of "import datetime"):

from datetime import date

On Wed, Feb 15, 2012 at 7:48 PM, Scott  wrote:

> Hello,
> I'm having a strange issue and have already spent an hour trying to
> figure it out.
>
> I created a python app called mn.  Then I setup all my models and
> stuff to work under mn.hcp.  Everything has been working fine until I
> tried to use date time in a py file in the hcp directory.
>
> I've imported datetime, with import date time at the top of my py
> file.  Then within the file I have a class with an internal method
> trying to use some date functions.
>
> datetime.date(2003,11,11)
>
> For some reason I am getting a NameError on the datetime object.  I
> don't understand why this is happening after I've imported datetime.
> Any help would be appreciated.  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@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: import problem

2012-02-15 Thread DrBloodmoney
On Wed, Feb 15, 2012 at 10:48 PM, Scott  wrote:
> Hello,
> I'm having a strange issue and have already spent an hour trying to
> figure it out.
>
> I created a python app called mn.  Then I setup all my models and
> stuff to work under mn.hcp.  Everything has been working fine until I
> tried to use date time in a py file in the hcp directory.
>
> I've imported datetime, with import date time at the top of my py
> file.  Then within the file I have a class with an internal method
> trying to use some date functions.
>
> datetime.date(2003,11,11)
>
> For some reason I am getting a NameError on the datetime object.  I
> don't understand why this is happening after I've imported datetime.
> Any help would be appreciated.  Thanks.

You probably have some sort of namespace collision. Look for circular
imports or import modules with the same name etc.

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



import problem

2012-02-15 Thread Scott
Hello,
I'm having a strange issue and have already spent an hour trying to
figure it out.

I created a python app called mn.  Then I setup all my models and
stuff to work under mn.hcp.  Everything has been working fine until I
tried to use date time in a py file in the hcp directory.

I've imported datetime, with import date time at the top of my py
file.  Then within the file I have a class with an internal method
trying to use some date functions.

datetime.date(2003,11,11)

For some reason I am getting a NameError on the datetime object.  I
don't understand why this is happening after I've imported datetime.
Any help would be appreciated.  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@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: Import problem

2011-08-21 Thread Jim
You are right, SleepyCal. I changed global to something else, and the import 
issue was solved.

-- 
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/-/ElDTlCgIITMJ.
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: Import problem

2011-08-21 Thread Cal Leeming [Simplicity Media Ltd]
I could be wrong but ,i dont think the word 'global' is allowed anywhere in
a file name ,import reference, class name etc.. i could be wrong tho. Try
with global2 ??
On Aug 21, 2011 2:10 PM, "Jim"  wrote:
> Hello folks,
>
> I am new to both Python and Django. And the story is a little long. So,
> please bear with me.
>
> Recently I created a site named djangoSite to practice the Django
framework.
> The first thing I want to do is to create a SQLite database to hold global

> data of the site. As simple as it sounds, the actual process I went
through
> wasn't so simple.
>
> First, I created an apps/ subdirectory under djangoSite/ to hold all
> potential applications I may have. Then, I created an empty file
__init__.pyto makeapps/a package.Then, I wanted to create an app
> global to make models for holding global data. I tried the following to do

> this.
> djangoSite/ >$ cd apps
> apps/ >$ ../manage.py startapp global
> It turns out the app global was created under djangoSite/ rather than
under
> apps/. So, here is one question. *How do I create a sub-app under apps/
with
> manage.py?* Anyway, I didn't stop there. I moved the folder global/ into
> apps/. I assumed that this would make global a subapp of apps, so that
> something like this would work under manage.py shell: import apps.global.
> However, I didn't test it right after moving the folder global/, which I
> should have. Instead, I proceeded and created a model in
> apps/global/models.py named NavItem. Then, I added
'djangoSite.apps.global'
> to settings.INSTALLED_APPS.
>
> Then, I added a SQLite3 database 'global' in settings.DATABASES, and
created
> a Python file dbrouter.py under djangoSite/, in which I created a class
> DBRouter to route the databases. Accordingly, I added DATABASE_ROUTERS =
> ['djangoSite.dbrouter.DBRouter'] to settings.py. Here is another question.

> When creating the class DBRouter, I basically copied the example (only the

> master class) in the Django documentation Multiple Databases<
https://docs.djangoproject.com/en/dev/topics/db/multi-db/#topics-db-multi-db-routing>.

> It seems to me the newly created routing class, which is DBRouter in my
> case, inherits a class named object, because of this statement: class
> DBRouter(object). However, the example in the document I mentioned earlier

> doesn't import anything at all, so the question is *where this class
> 'object' come from*?
>
> Anyway, I kept moving. Under djangoSite/, I ran ./manage.py validate,
which
> gave 0 error. Then, I ran ./manage.py syncdb. And I got a bunch of errors.
I
> suspected that the database routing may not work. So, commented out the
> DATABASE_ROUTERS settings, and ran ./manage.py syncdb again. This time, it

> went through without errors. Now I am guessing that I need to import
> something to make DBRouter work.
>
> So I started tracking down the problem. I invoked manage.py shell, and
> wanted to create an instance of NavItem. I tried the following import
> statements, but none of these worked. All of the them get a syntax error.
> Here thery are.
>
 from apps.global.models import NavItem
> File "", line 1
> from apps.global.models import NavItem
> ^
> SyntaxError: invalid syntax
 from global.models import NavItem
> File "", line 1
> from global.models import NavItem
> ^
> SyntaxError: invalid syntax
 from djangoSite.apps.global.models import NavItem
> File "", line 1
> from djangoSite.apps.global.models import NavItem
> ^
> SyntaxError: invalid syntax
 from global.models import NavItem
> File "", line 1
> from global.models import NavItem
> ^
> SyntaxError: invalid syntax
>
>
> Now I am running out of ideas about what went wrong. I know this is a bit
> long, so I really appreciate your help. Thank you very much.
>
> Jim
>
>
>
> , I also created and an subdirectory apps to hold all my django
> applications. I created an empty file __init__.py to make the folder apps
a
> package. Then, I meant to create an app named global to hold global data
of
> the site.
>
> --
> 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/-/3cTQeJLV05gJ.
> 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.



Import problem

2011-08-21 Thread Jim
Hello folks,

I am new to both Python and Django. And the story is a little long. So, 
please bear with me. 

Recently I created a site named djangoSite to practice the Django framework. 
The first thing I want to do is to create a SQLite database to hold global 
data of the site. As simple as it sounds, the actual process I went through 
wasn't so simple. 

First, I created an apps/ subdirectory under djangoSite/ to hold all 
potential applications I may have. Then, I created an empty file __init__.pyto 
makeapps/a package.Then, I wanted to create an app 
global to make models for holding global data. I tried the following to do 
this.
djangoSite/ >$ cd apps
apps/ >$ ../manage.py startapp global
It turns out the app global was created under djangoSite/ rather than under 
apps/. So, here is one question. *How do I create a sub-app under apps/ with 
manage.py?* Anyway, I didn't stop there. I moved the folder global/ into 
apps/. I assumed that this would make global a subapp of apps, so that 
something like this would work under manage.py shell: import apps.global. 
However, I didn't test it right after moving the folder global/, which I 
should have. Instead, I proceeded and created a model in 
apps/global/models.py named NavItem. Then, I added 'djangoSite.apps.global' 
to settings.INSTALLED_APPS.

Then, I added a SQLite3 database 'global' in settings.DATABASES, and created 
a Python file dbrouter.py under djangoSite/, in which I created a class 
DBRouter to route the databases. Accordingly, I added DATABASE_ROUTERS = 
['djangoSite.dbrouter.DBRouter'] to settings.py. Here is another question. 
When creating the class DBRouter, I basically copied the example (only the 
master class) in the Django documentation Multiple 
Databases.
 
It seems to me the newly created routing class, which is DBRouter in my 
case, inherits a class named object, because of this statement: class 
DBRouter(object). However, the example in the document I mentioned earlier 
doesn't import anything at all, so the question is *where this class 
'object' come from*? 

Anyway, I kept moving. Under djangoSite/, I ran ./manage.py validate, which 
gave 0 error. Then, I ran ./manage.py syncdb. And I got a bunch of errors. I 
suspected that the database routing may not work. So, commented out the 
DATABASE_ROUTERS settings, and ran ./manage.py syncdb again. This time, it 
went through without errors. Now I am guessing that I need to import 
something to make DBRouter work. 

So I started tracking down the problem. I invoked manage.py shell, and 
wanted to create an instance of NavItem. I tried the following import 
statements, but none of these worked. All of the them get a syntax error. 
Here thery are.

>>> from apps.global.models import NavItem
  File "", line 1
from apps.global.models import NavItem
   ^
SyntaxError: invalid syntax
>>> from global.models import NavItem
  File "", line 1
from global.models import NavItem
  ^
SyntaxError: invalid syntax
>>> from djangoSite.apps.global.models import NavItem
  File "", line 1
from djangoSite.apps.global.models import NavItem
  ^
SyntaxError: invalid syntax
>>> from global.models import NavItem
  File "", line 1
from global.models import NavItem
  ^
SyntaxError: invalid syntax


Now I am running out of ideas about what went wrong. I know this is a bit 
long, so I really appreciate your help. Thank you very much.

Jim



, I also created and an subdirectory apps to hold all my django 
applications. I created an empty file __init__.py to make the folder apps a 
package. Then, I meant to create an app named global to hold global data of 
the site. 

-- 
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/-/3cTQeJLV05gJ.
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: Import problem: app name cannot be the same as project name?

2011-01-22 Thread bruno desthuilliers


On 21 jan, 21:36, Edwin  wrote:
> I have an app that's called the same way as my project name

Won't work.


(let's
> name it 'blog'). My directory structure is:
>
> blog
>    apps
>       blog
>           models.py
>       books
>           management
>           models.py
>
> Everything works fine except that when i created a custom command
> inside another app, call it 'books', Django can't find it.. as it
> turns out, somehow django gets confused

A Django project is a Python package, a Django app is Python package,
so if they are named the same one is always going to shadow the other.
Read about the Python's module search path and you'll understand why.
So it's mostly a Python problem, not a Django one, even if the way
Django imports the app's models at startup doesn't help.

> I know my question is a bit all over the place here... but can anyone
> suggest what to do?

Obviously, rename your project ;)

> when I don't specify project name in settings.py, django tries to import 
> admin.py using 'apps.blog.admin' and I'm importing it using
'blog.apps.blog.admin'

You should only refer to the app's name when doing imports, ie
"blog.admin', 'books.models' etc.

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



Import problem: app name cannot be the same as project name?

2011-01-21 Thread Edwin
I have an app that's called the same way as my project name (let's
name it 'blog'). My directory structure is:

blog
   apps
  blog
  models.py
  books
  management
  models.py


Everything works fine except that when i created a custom command
inside another app, call it 'books', Django can't find it.. as it
turns out, somehow django gets confused and the project root path for
searching apps in the management tool
(django.core.management.__init__.py) becomes blog.apps.blog instead of
just blog as the project name. This results in django can't find of my
custom commands inside books app because it's searching on a wrong
path!

One thing to mention is that in my INCLUDED_APPS, i define my apps
using its project name as well:
INCLUDED_APPS = (
  'blog.apps.blog',
  'blog.apps.books',
)

This is also one reason why Django can't find my custom command i
guess... but i need to define full path (including project name) here
otherwise I get errors when my AlreadyRegistered from admin because
admin.py is imported twice with different method (when I don't specify
project name in settings.py, django tries to import admin.py using
'apps.blog.admin' and I'm importing it using
'blog.apps.blog.admin')...

My use of import is probably the root cause of everything.. I've heard
various people say that do relative import within apps so that they're
reusable but many Python devs say that always use absolute import. So
tried using absolute import all the time...

I know my question is a bit all over the place here... but can anyone
suggest what to do?

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@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: Import problem on the attempt to use {% url %}

2010-01-22 Thread Felipe
Thanks a lot Karen Tracey.

You've solved my problem.

Felipe.


On 22 jan, 01:13, Karen Tracey  wrote:
> On Thu, Jan 21, 2010 at 9:28 PM, Felipe  wrote:
> > Hello Friends,
>
> > Someone here know what this error mean?
>
> >http://www.catojo.com.br/contact/
>
> > This generally happens when I try to use something like {% url %} tag.
>
> > But I've been ensured that the view 'home.views' exists and it is
> > placed in blog.home.views directory, however, by some unknown issue
> > this error message are appearing my browser.
>
> > Someone have a tip to me fix the problem ?
>
> You've got a url pattern in your configuration that references a module
> named 'home.views', but Python cannot find any module named that. Based on
> the traceback information, /home/storage/b/fe/45/catojo/wsgi_apps is in the
> PYTHONPATH.  Apparently under that you have blog/, then home/, then a
> views.py in there?
>
> But combining what you have in your path plus home.views results in Python
> attempting to find a file named:
>
> /home/storage/b/fe/45/catojo/wsgi_apps/home/views.py
>
> not:
>
> /home/storage/b/fe/45/catojo/wsgi_apps/blog/home/views.py
>
> The blog part has to be either included in the url pattern reference or in a
> PYTHONPATH entry.  As it is, neither has it, so Python cannot find any
> module named home.views when searching through the Python path.
>
> Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Import problem on the attempt to use {% url %}

2010-01-21 Thread Karen Tracey
On Thu, Jan 21, 2010 at 9:28 PM, Felipe  wrote:

> Hello Friends,
>
> Someone here know what this error mean?
>
> http://www.catojo.com.br/contact/
>
> This generally happens when I try to use something like {% url %} tag.
>
> But I've been ensured that the view 'home.views' exists and it is
> placed in blog.home.views directory, however, by some unknown issue
> this error message are appearing my browser.
>
> Someone have a tip to me fix the problem ?
>
>
You've got a url pattern in your configuration that references a module
named 'home.views', but Python cannot find any module named that. Based on
the traceback information, /home/storage/b/fe/45/catojo/wsgi_apps is in the
PYTHONPATH.  Apparently under that you have blog/, then home/, then a
views.py in there?

But combining what you have in your path plus home.views results in Python
attempting to find a file named:

/home/storage/b/fe/45/catojo/wsgi_apps/home/views.py

not:

/home/storage/b/fe/45/catojo/wsgi_apps/blog/home/views.py

The blog part has to be either included in the url pattern reference or in a
PYTHONPATH entry.  As it is, neither has it, so Python cannot find any
module named home.views when searching through the Python path.

Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Import problem on the attempt to use {% url %}

2010-01-21 Thread Felipe
Hello Friends,

Someone here know what this error mean?

http://www.catojo.com.br/contact/

This generally happens when I try to use something like {% url %} tag.

But I've been ensured that the view 'home.views' exists and it is
placed in blog.home.views directory, however, by some unknown issue
this error message are appearing my browser.

Someone have a tip to me fix the problem ?

Thanks in advanced.

Felipe.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: import problem

2009-08-09 Thread Léon Dignòn

Thank you all! :)

On Aug 9, 9:35 pm, "J. Cliff Dyer"  wrote:
> On Sun, 2009-08-09 at 11:59 -0700, Léon Dignòn wrote:
> > In my myproject/urls.py I want to pass the class to a function.
> > Because my urls.py is full of imports, I do not want another import
> > line for this class I only use at one line, because it's easier to
> > read.
>
> > I wonder that I have to import myproject when I reference a model
> > class in an app which _is_ in the project I am currently using. For
> > that I have to ask this:
>
> > Do I really need 'import myproject' in myproject/urls.py when I'd like
> > to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???
>
> In fact, you need to import more than myproject.  You need to import
> myproject.myapp.models.  Imports happen at the module level, which is to
> say, one file at a time.  You don't need to import each class
> individually, but you do need to import each module.  
>
> If you are worried about having too many imports in your urls.py
> configuration file, see if you can break it up somewhat by giving each
> app its own urlconf with only the urls relevant to that particular app.
>
> Cheers,
> Cliff
--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread J. Cliff Dyer

On Sun, 2009-08-09 at 11:59 -0700, Léon Dignòn wrote:
> In my myproject/urls.py I want to pass the class to a function.
> Because my urls.py is full of imports, I do not want another import
> line for this class I only use at one line, because it's easier to
> read.
> 
> I wonder that I have to import myproject when I reference a model
> class in an app which _is_ in the project I am currently using. For
> that I have to ask this:
> 
> Do I really need 'import myproject' in myproject/urls.py when I'd like
> to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???
> 
> 

In fact, you need to import more than myproject.  You need to import
myproject.myapp.models.  Imports happen at the module level, which is to
say, one file at a time.  You don't need to import each class
individually, but you do need to import each module.  

If you are worried about having too many imports in your urls.py
configuration file, see if you can break it up somewhat by giving each
app its own urlconf with only the urls relevant to that particular app.

Cheers,
Cliff




--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread Daniel Roseman

On Aug 9, 7:59 pm, Léon Dignòn  wrote:
> In my myproject/urls.py I want to pass the class to a function.
> Because my urls.py is full of imports, I do not want another import
> line for this class I only use at one line, because it's easier to
> read.
>
> I wonder that I have to import myproject when I reference a model
> class in an app which _is_ in the project I am currently using. For
> that I have to ask this:
>
> Do I really need 'import myproject' in myproject/urls.py when I'd like
> to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???
>

Yes, if you want to write 'myproject.whatever' you need to import
myproject. Python doesn't magically know about namespaces unless you
tell it.

You're right that since you're in myproject you don't need to import
that - you can just import myapp and do 'myapp.models'. But you still
need to import myapp.

However, I do wonder why you have so many imports in your urls.py. I
presume you know that you can just use strings to reference the view
functions?
--
DR.
--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread Léon Dignòn

In my myproject/urls.py I want to pass the class to a function.
Because my urls.py is full of imports, I do not want another import
line for this class I only use at one line, because it's easier to
read.

I wonder that I have to import myproject when I reference a model
class in an app which _is_ in the project I am currently using. For
that I have to ask this:

Do I really need 'import myproject' in myproject/urls.py when I'd like
to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???



On Aug 9, 8:50 pm, Daniel Roseman  wrote:
> On Aug 9, 7:34 pm, Léon Dignòn  wrote:
>
>
>
>
>
> > Hello,
>
> > some times I'd like not to import a class but just write it down.
>
> > Instead of
> > from myproject.myapp.models import MyModel
>
> > I'd like to use
> > myproject.myapp.models.MyModel
>
> > But I get a NameError: name 'myproject' is not defined
>
> > Also
> > myapp.models.MyModel
> > raises a NameError: name 'myapp' is not defined
>
> > Any ideas?
>
> What are you trying to do - what do you mean by 'write it down'?
>
> If you just want to use 'myproject.myapp.models.MyModel', instead of
> just 'MyModel', when referencing a model class, that's fine - but you
> still need to import myproject.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread Daniel Roseman

On Aug 9, 7:34 pm, Léon Dignòn  wrote:
> Hello,
>
> some times I'd like not to import a class but just write it down.
>
> Instead of
> from myproject.myapp.models import MyModel
>
> I'd like to use
> myproject.myapp.models.MyModel
>
> But I get a NameError: name 'myproject' is not defined
>
> Also
> myapp.models.MyModel
> raises a NameError: name 'myapp' is not defined
>
> Any ideas?

What are you trying to do - what do you mean by 'write it down'?

If you just want to use 'myproject.myapp.models.MyModel', instead of
just 'MyModel', when referencing a model class, that's fine - but you
still need to import myproject.
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



import problem

2009-08-09 Thread Léon Dignòn

Hello,

some times I'd like not to import a class but just write it down.

Instead of
from myproject.myapp.models import MyModel

I'd like to use
myproject.myapp.models.MyModel

But I get a NameError: name 'myproject' is not defined

Also
myapp.models.MyModel
raises a NameError: name 'myapp' is not defined

Any ideas?
--~--~-~--~~~---~--~~
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: import problem

2007-05-01 Thread Michael K



On Apr 29, 6:37 pm, kamil <[EMAIL PROTECTED]> wrote:
> Hi Michael. You are right there was module named utils (coincidentally
> same name as django module) in the nesh thumbnail app.
> Problem resolved :)
> Thank You Very Much for the time You dedicate me.
> I feel in debt with U and I feel really happy to feel such a feedback
> in django community.
>

Kamil,

Glad I could help.  The community's helped me quite a bit, I figured I
should help were I could.  Maybe someday, someone will have a question
you can help with, eh?

Thanks,

Michael


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



Re: import problem

2007-04-29 Thread kamil

Hi Michael. You are right there was module named utils (coincidentally
same name as django module) in the nesh thumbnail app.
Problem resolved :)
Thank You Very Much for the time You dedicate me.
I feel in debt with U and I feel really happy to feel such a feedback
in django community.

On Apr 25, 8:50 pm, Michael K <[EMAIL PROTECTED]> wrote:
> On Apr 24, 4:19 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > Thanx Michael for your attention.
> > I'm using todays build from svn trunk.
> > I started project from the beginning to eliminate possibility that its
> > something wrong with my code.
>
> > when I run "python manage.py runserver" everything seams OK.
> > when I hit any page I got error I mentioned
> > Yes I'm runnung it as the same user as shell. I tried to run it as
> > root and it comes the same.
> > It starts to desesperate me. After tomorrow I got meeting with my
> > client to show him my project :¿
> > and I'm stacked with this.
> > Help would be greatly appreciated
>
> Kamil,
>
> I did some deeper digging, and I don't seem to have a
> django.core.utils.text at all in the trunk.  I'd check your urlconf's
> and make sure they're sane namespace-wise.  That is, if you're trying
> to import a utils.text module in your urls.py, that's the likely
> culprit.  The URLconf code can't resolve the module name for some
> reason.
>
> Do you have an app named "utils" in your project?  If so, then there
> might be something else wrong (missing __init__.py, permissions,
> etc).  If not, that's probably where your problem lies.  You just
> might have put in the urlconf information incorrectly.
>
> --
> Michael


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



Re: import problem

2007-04-25 Thread Michael K


On Apr 24, 4:19 pm, kamil <[EMAIL PROTECTED]> wrote:
> Thanx Michael for your attention.
> I'm using todays build from svn trunk.
> I started project from the beginning to eliminate possibility that its
> something wrong with my code.
>
> when I run "python manage.py runserver" everything seams OK.
> when I hit any page I got error I mentioned
> Yes I'm runnung it as the same user as shell. I tried to run it as
> root and it comes the same.
> It starts to desesperate me. After tomorrow I got meeting with my
> client to show him my project :¿
> and I'm stacked with this.
> Help would be greatly appreciated
>
>

Kamil,

I did some deeper digging, and I don't seem to have a
django.core.utils.text at all in the trunk.  I'd check your urlconf's
and make sure they're sane namespace-wise.  That is, if you're trying
to import a utils.text module in your urls.py, that's the likely
culprit.  The URLconf code can't resolve the module name for some
reason.

Do you have an app named "utils" in your project?  If so, then there
might be something else wrong (missing __init__.py, permissions,
etc).  If not, that's probably where your problem lies.  You just
might have put in the urlconf information incorrectly.

--
Michael


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



Re: import problem

2007-04-24 Thread kamil

Thanx Michael for your attention.
I'm using todays build from svn trunk.
I started project from the beginning to eliminate possibility that its
something wrong with my code.

when I run "python manage.py runserver" everything seams OK.
when I hit any page I got error I mentioned
Yes I'm runnung it as the same user as shell. I tried to run it as
root and it comes the same.
It starts to desesperate me. After tomorrow I got meeting with my
client to show him my project :¿
and I'm stacked with this.
Help would be greatly appreciated


On Apr 24, 3:34 pm, Michael K <[EMAIL PROTECTED]> wrote:
> On Apr 24, 5:41 am, kamil <[EMAIL PROTECTED]> wrote:
>
> > Hi. I'm using developement built-in django server.
> > Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) [GCC 4.1.2
> > (Ubuntu 4.1.2-0ubuntu4)] on linux2
> > on fresh Kubuntu Feisty (7.04)
>
> Kamil,
>
> I'm assuming you're just running "python manage.py runserver" for your
> command line?
>
> Are you using Django 0.96, or the svn trunk?  Sorry to add questions,
> I was hoping it would be a simple problem of too many Python binaries
> on a system. :)
>
> Are you getting an exception on the server output?
>
> And lastly, are you running the server as the same user you're running
> the python shell?
>
> Thanks,
>
> Michael


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



Re: import problem

2007-04-24 Thread Michael K



On Apr 24, 5:41 am, kamil <[EMAIL PROTECTED]> wrote:
> Hi. I'm using developement built-in django server.
> Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) [GCC 4.1.2
> (Ubuntu 4.1.2-0ubuntu4)] on linux2
> on fresh Kubuntu Feisty (7.04)
>

Kamil,

I'm assuming you're just running "python manage.py runserver" for your
command line?

Are you using Django 0.96, or the svn trunk?  Sorry to add questions,
I was hoping it would be a simple problem of too many Python binaries
on a system. :)

Are you getting an exception on the server output?

And lastly, are you running the server as the same user you're running
the python shell?

Thanks,

Michael


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



Re: import problem

2007-04-24 Thread kamil

Hi. I'm using developement built-in django server.
Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) [GCC 4.1.2
(Ubuntu 4.1.2-0ubuntu4)] on linux2
on fresh Kubuntu Feisty (7.04)

On Apr 23, 4:01 pm, Michael K <[EMAIL PROTECTED]> wrote:
> On Apr 22, 4:38 pm, kamil <[EMAIL PROTECTED]> wrote:
>
> > Hi. I installed Django on Python 2.5
> > and I receive following error on the built in server:
>
> > Exception Type: ImportError
> > Exception Value:No module named utils.text
> > Exception Location: /usr/lib/python2.5/site-packages/django/core/
> > urlresolvers.py in _get_urlconf_module, line 178
>
> > however utils.text exist in Django directory and importing in shell
> > works fine.
> > Please help.
>
> Kamil,
>
> Can you paste the header you get when you start your Python
> interpreter?
>
> This almost sounds to me like you have more than one version of Python
> installed, or your library path settings are incorrect somewhere
> (probably in your web server configuration).
>
> Are you using mod_python to host the project?
>
> Lots of details missing before we can help much.
>
> Thanks,
>
> Michael


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



Re: import problem

2007-04-23 Thread Michael K

On Apr 22, 4:38 pm, kamil <[EMAIL PROTECTED]> wrote:
> Hi. I installed Django on Python 2.5
> and I receive following error on the built in server:
>
> Exception Type: ImportError
> Exception Value:No module named utils.text
> Exception Location: /usr/lib/python2.5/site-packages/django/core/
> urlresolvers.py in _get_urlconf_module, line 178
>
> however utils.text exist in Django directory and importing in shell
> works fine.
> Please help.

Kamil,

Can you paste the header you get when you start your Python
interpreter?

This almost sounds to me like you have more than one version of Python
installed, or your library path settings are incorrect somewhere
(probably in your web server configuration).

Are you using mod_python to host the project?

Lots of details missing before we can help much.


Thanks,

Michael


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



import problem

2007-04-22 Thread kamil

Hi. I installed Django on Python 2.5
and I receive following error on the built in server:

Exception Type: ImportError
Exception Value:No module named utils.text
Exception Location: /usr/lib/python2.5/site-packages/django/core/
urlresolvers.py in _get_urlconf_module, line 178

however utils.text exist in Django directory and importing in shell
works fine.
Please help.


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



weird import problem

2006-11-17 Thread [EMAIL PROTECTED]

I'm attempting to install the nesh.thumbnails app for images with
thumbnails.

In my model, I put
from nesh.thumbnail import ImageWithThumbnailField

but that fails unless I drill down a layer deeper and put
from nesh.thumbnail.field import ImageWithThumbnailField

which then fails when it tries to import something else. So what's up?
Should I install thumbnail, utils and who knows what else as
applications in my project or is it just something awry in my python
path or something?


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



django/mod_python/apache import problem

2006-03-22 Thread abe

hi,

I'm having trouble getting django to work together with apache an
mod_python



if I try to access the admin page through my browser it displas the
following message


Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in
HandlerDispatch result = object(req)

  File

"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/handlers/modpython.py",
line 165, in handler return ModPythonHandler()(req)

  File

"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/handlers/modpython.py",
line 130, in __call__ from django.conf import settings

  File

"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/conf/settings.py",
line 34, in ? raise EnvironmentError, "Could not import %s '%s' (is
it on
sys.path?): %s %s" % (ENVIRONMENT_VARIABLE, me.SETTINGS_MODULE,
e,sys.path)

EnvironmentError: Could not import DJANGO_SETTINGS_MODULE
'myproject.settings' (is it on sys.path?):  No module named
myproject.settings ['/data1/zbdb', '/usr/lib/python23.zip',
'/usr/lib/python2.3', '/usr/lib/python2.3/plat-linux2',
'/usr/lib/python2.3/lib-tk', '/usr/lib/python2.3/lib-dynload',
'/usr/lib/python2.3/site-packages',
'/usr/lib/python2.3/site-packages/PIL',
'/usr/lib/python2.3/site-packages/setuptools-0.6a9-py2.3.egg',
'/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg',
'/usr/lib/python2.3/site-packages/gtk-2.0']


I added the printing of sys.path to
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/conf/settings.py"
to see if the path is correct

myproject.setting can't be imported  but it should be on the sys.path
because /data1/zbdb is in sys.path and
/data1/zbdb/myproject/settings.py
exists

ls  -lst /data1/zbdb/myproject/settings.py
8 -rw-r--r--  1 root root 2601 Mar 22 20:32
/data1/zbdb/myproject/settings.py

this is in my httpd.conf

SetHandler python-program
PythonPath "['/data1/zbdb'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonDebug On
PythonAutoReload On





Any idea what am I doing wrong? 

thanks, E


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