Re: circular imports error

2021-06-11 Thread Adam Stein
Glad to be of help. Sometimes it just takes a fresh pair of eyes. On Fri, 2021-06-11 at 17:33 -0500, frank dilorenzo wrote: > I hate to sound corny but you sir are my hero!.  Thanks,  it all > works now >   > frank- > > > On Fri, Jun 11, 2021 at 2:43 PM Adam Stein wrote: > > Since you said 3 se

Re: circular imports error

2021-06-11 Thread frank dilorenzo
I hate to sound corny but you sir are my hero!. Thanks, it all works now frank- On Fri, Jun 11, 2021 at 2:43 PM Adam Stein wrote: > Since you said 3 separate apps, I assume each of these classes are in a > separate file. However, you have the line: > > from .models import Supplier > > which

Re: circular imports error

2021-06-11 Thread Adam Stein
Since you said 3 separate apps, I assume each of these classes are in a separate file. However, you have the line: from .models import Supplier which would make it seem that Supplier is defined in the same file as Shipment. Shipment should be in ".models" and if Supplier is also defined in the s

circular imports error

2021-06-11 Thread frank dilorenzo
Hello, I have 3 separate app as follow: from django.db import models # Create your models here. # Supplier can have many shipments class Supplier(models.Model): name = models.CharField(max_length=120, null=True) phone = models.CharField(max_length=15, null=True) email = models.CharField(max_leng

Re: Manually running a script that imports a Django model

2020-02-13 Thread maninder singh Kumar
u >> wrote: > >> So I am trying to access one of my models created in views.py in another >> script. This second script is the one I would like manually run. It imports >> the model without any errors; however, when I try to run it using PyCharm, I >> get this error

Re: Manually running a script that imports a Django model

2020-02-13 Thread onlinejudge95
On Thu, Feb 13, 2020 at 6:34 PM Sourish Kundu wrote: > So I am trying to access one of my models created in views.py in another > script. This second script is the one I would like manually run. It imports > the model without any errors; however, when I try to run it using PyCharm, >

Re: Manually running a script that imports a Django model

2020-02-13 Thread Adam Mičuda
u are want. ;) Regards. Adam čt 13. 2. 2020 v 14:03 odesílatel Sourish Kundu napsal: > So I am trying to access one of my models created in views.py in another > script. This second script is the one I would like manually run. It imports > the model without any errors; however, when I try to r

Manually running a script that imports a Django model

2020-02-13 Thread Sourish Kundu
So I am trying to access one of my models created in views.py in another script. This second script is the one I would like manually run. It imports the model without any errors; however, when I try to run it using PyCharm, I get this error: *django.core.exceptions.ImproperlyConfigured

Re: wrong imports channel ?

2018-04-12 Thread Andrew Godwin
Channels 2 has different objects and import paths - code from Channels 1 (like you have there) isn't compatible. Andrew On Thu, Apr 12, 2018 at 12:37 AM, Jules LE BRIS wrote: > Hi, > > I would like to do something like this in views.py : > > message = {"message":msg} > Channel('chat').send(mess

Re: wrong imports channel ?

2018-04-12 Thread N. Srinivasan
Thank you Sir! On Thu, Apr 12, 2018 at 3:37 AM, Jules LE BRIS wrote: > Hi, > > I would like to do something like this in views.py : > > message = {"message":msg} > Channel('chat').send(message, immediately=True) > > but the import : from channels import Channel doen't work. I'm using > channels=

wrong imports channel ?

2018-04-12 Thread Jules LE BRIS
Hi, I would like to do something like this in views.py : message = {"message":msg} Channel('chat').send(message, immediately=True) but the import : from channels import Channel doen't work. I'm using channels==2.0.2. -- You received this message because you are subscribed to the Google Groups

Re: Problem Django.19 upgrade and circular imports

2016-03-08 Thread Andres Osinski
ious versions of Django have advised that the 'apps' subdirectory should be included in the system path; we have never done this before and thus far things have worked well, however I don't know if this was suppored behavior. The negative to doing that is that I'd have to rename al

Re: Problem Django.19 upgrade and circular imports

2016-03-04 Thread Andres Osinski
latest versions of 1.7 and 1.8. I'll try with older versions in 1.8 and report back. On Thu, Mar 3, 2016 at 10:11 PM, James Schneider wrote: > On Thu, Mar 3, 2016 at 3:28 PM, Andres Osinski > wrote: > >> Hi everyone! I'm having an issue with circular imports in Django 1.9 th

Re: Problem Django.19 upgrade and circular imports

2016-03-03 Thread James Schneider
On Thu, Mar 3, 2016 at 3:28 PM, Andres Osinski wrote: > Hi everyone! I'm having an issue with circular imports in Django 1.9 that > I have not seen in my app, which had been running 1.7 before. > > I have a Django app in apps.common, which has its associated > apps.common.mo

Re: Problem Django.19 upgrade and circular imports

2016-03-03 Thread Tim Graham
gt; Hi everyone! I'm having an issue with circular imports in Django 1.9 that > I have not seen in my app, which had been running 1.7 before. > > I have a Django app in apps.common, which has its associated > apps.common.models too. No imports on __init__.py or anything of the s

Problem Django.19 upgrade and circular imports

2016-03-03 Thread Andres Osinski
Hi everyone! I'm having an issue with circular imports in Django 1.9 that I have not seen in my app, which had been running 1.7 before. I have a Django app in apps.common, which has its associated apps.common.models too. No imports on __init__.py or anything of the sort. When I my a

Re: Django imports models for apps that aren't enabled?

2016-01-05 Thread Stodge
file > should be imported is a) because it's listed in INSTALLED_APPS, or b) > because something else that is imported imports it (possibly also c) an > installed model has an FK linking to it with a string reference?). > > My first guess would be that you're see

Re: Django imports models for apps that aren't enabled?

2016-01-05 Thread Carl Meyer
gt; expecting it. Thanks Django shouldn't do that on its own. AFAIK the only reason a models file should be imported is a) because it's listed in INSTALLED_APPS, or b) because something else that is imported imports it (possibly also c) an installed model has an FK linking to it with a st

Django imports models for apps that aren't enabled?

2016-01-05 Thread Stodge
I'm using Django 1.6.9. When the dev server (and hence Apache) starts, is Django supposed to import models for apps that exist on disk, but aren't enabled in the settings? I'm seeing this behaviour and I wasn't expecting it. Thanks -- You received this message because you are subscribed to the

Re: finding information on modules, imports, etc.

2015-11-09 Thread Gary Roach
rote: I can't seem to find a "dictionary" of modules? or what ever on the use of: import os or other possible imports from django.contrib import admin Maybe I'm using the wrong terminology but after a gazillion searches, I still haven't found a

Re: finding information on modules, imports, etc.

2015-11-08 Thread Gergely Polonkai
It's a bit unclear what you want to do. Could you write a use case? I'm afraid of an XY problem here… On 8 Nov 2015 18:25, "Gary Roach" wrote: > I can't seem to find a "dictionary" of modules? or what ever on the use of: > > import os or other poss

finding information on modules, imports, etc.

2015-11-08 Thread Gary Roach
I can't seem to find a "dictionary" of modules? or what ever on the use of: import os or other possible imports from django.contrib import admin possibilities.> Maybe I'm using the wrong terminology but after a gazillion searches, I still haven't found a decent r

Re: Does imports of related models affect cascade deletion?

2015-07-30 Thread Markus Amalthea Magnuson
I will fetch the actual piece of code and build a small test case out of it, will reply again in this thread when I have some more info. On Thu, Jul 30, 2015 at 6:39 PM, Marc Aymerich wrote: > On Thu, Jul 30, 2015 at 3:38 PM, Markus Amalthea Magnuson > wrote: > > Hey, > > > > I stumbled upon a

Re: Does imports of related models affect cascade deletion?

2015-07-30 Thread Marc Aymerich
On Thu, Jul 30, 2015 at 3:38 PM, Markus Amalthea Magnuson wrote: > Hey, > > I stumbled upon a piece of code and a comment that says this: > > Deleting a model object that has related objects will only cascade delete > those objects if their models have been imported. > > Is this true? I have not f

Re: Does imports of related models affect cascade deletion?

2015-07-30 Thread Tim Graham
No, import of related models shouldn't affect cascade deletion. Please open a bug report with steps to reproduce if that's actually the case. Possibly it could be a bug that's fixed by the app loading refactor in 1.7. On Thursday, July 30, 2015 at 9:38:09 AM UTC-4, Markus Amalthea Magnuson wrot

Does imports of related models affect cascade deletion?

2015-07-30 Thread Markus Amalthea Magnuson
Hey, I stumbled upon a piece of code and a comment that says this: Deleting a model object that has related objects will only cascade delete those objects if their models have been imported. Is this true? I have not found it in the documentation and would like to add a reference to the code co

broken imports in python3.3 + django 1.5

2013-04-26 Thread danny
Howdy, In python 3.3 you no longer need __init__.py in directories to be interpreted as package namespaces. In my source I have the following tree src /apps /index /mapping I removed the __init__.py files as I should be able to, but imports broke. Specifically: /opt/python3.3.1/lib

Re: Django in Eclipse+PyDev, lot's of functions and imports are undefined/unresolved

2012-10-26 Thread Chris Pagnutti
I basically just rebuilt the >>> whole project from scratch by copying and pasting all the source code. I'm >>> pretty sure I set up my python interpreter fine. I'm using django-trunk in >>> a virtual env. >>> >>> When I open the conso

Re: Django in Eclipse+PyDev, lot's of functions and imports are undefined/unresolved

2012-10-26 Thread Andrew McHarg
all the source code. I'm >> pretty sure I set up my python interpreter fine. I'm using django-trunk in >> a virtual env. >> >> When I open the console in Eclipse, and can import django and it prints >> the correct version number. But my project, which worked

Re: Django in Eclipse+PyDev, lot's of functions and imports are undefined/unresolved

2012-10-26 Thread Chris Pagnutti
unk in > a virtual env. > > When I open the console in Eclipse, and can import django and it prints > the correct version number. But my project, which worked fine in eric4, > makes Eclipse complain about unresolved imports and undefined variables. > Here a list of a few

Re: Django in Eclipse+PyDev, lot's of functions and imports are undefined/unresolved

2012-10-26 Thread Nick Santos
n interpreter fine. I'm using django-trunk in > a virtual env. > > When I open the console in Eclipse, and can import django and it prints > the correct version number. But my project, which worked fine in eric4, > makes Eclipse complain about unresolved imports and undefined variab

Django in Eclipse+PyDev, lot's of functions and imports are undefined/unresolved

2012-10-26 Thread Chris Pagnutti
ng django-trunk in a virtual env. When I open the console in Eclipse, and can import django and it prints the correct version number. But my project, which worked fine in eric4, makes Eclipse complain about unresolved imports and undefined variables. Here a list of a few that might give

Re: A single file that contains common django imports

2012-07-06 Thread Russell Keith-Magee
ommon_imports import * > > > This saves me from having to retype all the django imports repeatedly atop > my files. That and I can never remember the paths so I'm always hitting the > docs looking up where to import stuff from. > > I'm just looking for the downside of t

A single file that contains common django imports

2012-07-06 Thread Scott Woodall
render_to_response Then in any other file I need to import django stuff into, I just import my common_imports.py views.py === from my_project.common_imports import * This saves me from having to retype all the django imports repeatedly atop my files. That and I can never remember the

Re: Django Snippet imports?

2012-02-03 Thread msbuck
Yes you need to put register = template.Library() in your module. See https://docs.djangoproject.com/en/1.3/howto/custom-template-tags/ for more info on where this code should reside. On Feb 3, 9:17 am, Jesramz wrote: > source:http://djangosnippets.org/snippets/847/ > > from django.contrib.auth.m

Re: Django Snippet imports?

2012-02-03 Thread Jesramz
source: http://djangosnippets.org/snippets/847/ from django.contrib.auth.models import User, Group from django.utils.encoding import force_unicode from django import template Missing anything? Would I have to use 'register = template.Library()' ? -- You received this message because you are s

Django Snippet imports?

2012-02-02 Thread Jesramz
What would I have to import to use the following snippet (source: http://djangosnippets.org/snippets/847/)? @register.filter def in_group(user, groups): """Returns a boolean if the user is in the given group, or comma- separated list of groups. Usage:: {% if user|in_group:"Fr

RE: Question about imports..Python Dejango and Models

2011-08-06 Thread Hayyan Rafiq
Thanks guys ... for clarifying that up.. > Date: Sat, 6 Aug 2011 01:50:21 -0700 > Subject: Re: Question about imports..Python Dejango and Models > From: andrew.mark.sc...@gmail.com > To: django-users@googlegroups.com > > Hi, > > models.Model is django.db.models.base

Re: Question about imports..Python Dejango and Models

2011-08-06 Thread Andrew
;     publisher = models.ForeignKey(Publisher) >     publication_date = models.DateField() > >  "I meant Models is defined inside models.py. ??" .. still not clear > > Date: Fri, 5 Aug 2011 21:33:26 -0400 > Subject: Re: RE: Question about imports..Python Dejango and Models

Re: Question about imports..Python Dejango and Models

2011-08-06 Thread Shawn Milochik
2011/8/6 Rafael Durán Castañeda : > I'm not a django expert but I think you are wrong. Checking my django > installation: > Yep, you're right. https://code.djangoproject.com/browser/django/trunk/django/db/models/base.py -- You received this message because you are subscribed to the Google Gro

Re: Question about imports..Python Dejango and Models

2011-08-06 Thread bruno desthuilliers
y file and you'll find out that the Model base class is defined in django/db/models/base.py. > I have checked a couple of sites on python tutorial and they dont > cover imports in that much detail You obviously forgot to start with the official tutorial. This is covered in "

Re: Question about imports..Python Dejango and Models

2011-08-06 Thread Rafael Durán Castañeda
I'm not a django expert but I think you are wrong. Checking my django installation: - models is package not a python module - __init__.py from this file contains: from django.conf import settings from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured from django.db import co

RE: Question about imports..Python Dejango and Models

2011-08-05 Thread Hayyan Rafiq
not clear Date: Fri, 5 Aug 2011 21:33:26 -0400 Subject: Re: RE: Question about imports..Python Dejango and Models From: sh...@milochik.com To: django-users@googlegroups.com Sorry, typo. I meant Models is defined inside models.py. -- You received this message because you are subscribed to

Re: RE: Question about imports..Python Dejango and Models

2011-08-05 Thread Shawn Milochik
Sorry, typo. I meant Models is defined inside models.py. -- 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...@

RE: Question about imports..Python Dejango and Models

2011-08-05 Thread Hayyan Rafiq
= models.CharField(max_length=30) country = models.CharField(max_length=50) website = models.URLField() I need Models.py where is that?? Date: Fri, 5 Aug 2011 21:15:01 -0400 Subject: Re: Question about imports..Python Dejango and Models From: sh...@milochik.com To: django-users

Re: Question about imports..Python Dejango and Models

2011-08-05 Thread Shawn Milochik
The model class is defined *inside* Models.py. -- 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...@googlegrou

Question about imports..Python Dejango and Models

2011-08-05 Thread Adam Zedan
d they dont cover imports in that much detail -- 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+unsubsc

Re: Question about using imports within functions/methods

2011-06-02 Thread Cal Leeming [Simplicity Media Ltd]
On Thu, Jun 2, 2011 at 4:46 PM, Shawn Milochik wrote: > On 06/02/2011 11:09 AM, Cal Leeming [Simplicity Media Ltd] wrote: > >> >> Pretty shameful that after almost 6 years of (fairly advanced) Python >> coding, I still finding myself not knowing some of the basic 101 stuff.. >> Slightly off topic

Re: Question about using imports within functions/methods

2011-06-02 Thread Shawn Milochik
On 06/02/2011 11:09 AM, Cal Leeming [Simplicity Media Ltd] wrote: Pretty shameful that after almost 6 years of (fairly advanced) Python coding, I still finding myself not knowing some of the basic 101 stuff.. Slightly off topic but, does anyone else have that issue when coding? (i.e. doing re

Re: Question about using imports within functions/methods

2011-06-02 Thread Cal Leeming [Simplicity Media Ltd]
Thanks to Tom / Matias / Brian for taking the time to reply, and for providing some good links, this was *exactly* what I needed. In regards to circular import issues, this is pretty much the main reason I've put imports inside function/method before, and I agree that most of the time it c

Re: Question about using imports within functions/methods

2011-06-02 Thread Matías Aguirre
Imports are cached by python that way things get imported only the first time. Try this simple test, create a file a.py with this content: print "Importing a.py" Then create b.py with this other content: import a Then create c.py with this other content: def x():

Re: Question about using imports within functions/methods

2011-06-02 Thread Tom Evans
On Thu, Jun 2, 2011 at 3:39 PM, Cal Leeming [Simplicity Media Ltd] wrote: > Hey guys, > > This is more of a python question, than a Django specific one, but it's been > bugging me for years now lol. > > I'm trying to figure out if it is better to do imports at the top

Re: Question about using imports within functions/methods

2011-06-02 Thread Brian Bouterse
Yes relative imports are explicitly discouraged in PEP 8<http://www.python.org/dev/peps/pep-0008/>. Look for the imports section. I do not recommend importing at runtime which is what you are doing when you put imports inside function/methods. There are performance problems when calling i

Question about using imports within functions/methods

2011-06-02 Thread Cal Leeming [Simplicity Media Ltd]
Hey guys, This is more of a python question, than a Django specific one, but it's been bugging me for years now lol. I'm trying to figure out if it is better to do imports at the top of the file, or within the function/methods themselves. I guess the questions I'm asking are:

Re: mutual imports - how to do it?

2011-04-18 Thread Kenneth Gonsalves
On Tue, 2011-04-19 at 09:46 +0530, Kenneth Gonsalves wrote: > > from django.db.models import get_model > > > > Product = get_model('products', 'Product') > > Something = get_model('incident', 'Something') > > that simple? will try. worked. Thanks. -- regards KG http://lawgon.livejournal.com C

Re: mutual imports - how to do it?

2011-04-18 Thread Kenneth Gonsalves
On Tue, 2011-04-19 at 00:36 -0300, Fabian Ezequiel Gallina wrote: > > In incident I can do: from products.models import Product > > but in products if I do: > > from incident.import Something - this fails and django says cannot > > import Something. > > > > Is there any way around this? > > from d

Re: mutual imports - how to do it?

2011-04-18 Thread Fabian Ezequiel Gallina
2011/4/18 Kenneth Gonsalves : > hi, > > I have two models.py files in two applications. Say, products.models and > incident.models. > > In incident I can do: from products.models import Product > but in products if I do: > from incident.import Something - this fails and django says cannot > import

mutual imports - how to do it?

2011-04-18 Thread Kenneth Gonsalves
hi, I have two models.py files in two applications. Say, products.models and incident.models. In incident I can do: from products.models import Product but in products if I do: from incident.import Something - this fails and django says cannot import Something. Is there any way around this? --

Re: celery tasks and circular imports

2011-03-08 Thread Bill Freeman
need them.  I don't think there is > anything wrong with this approach the from a Python perspective other than > possibly these: > * imports are parsed at runtime and thus an import occurs for each time the > code is run    <=== performance problem > * import errors aren&#x

Re: celery tasks and circular imports

2011-03-07 Thread Brian Bouterse
I too "protect" code from being interpreted at import time by putting import statements directly in the tasks that need them. I don't think there is anything wrong with this approach the from a Python perspective other than possibly these: * imports are parsed at runtime and

Re: celery tasks and circular imports

2011-03-07 Thread Shawn Milochik
If there's a "correct" way to do this I'd love to hear it also. At present I do the model imports in tasks.py within the task that requires the model. This is because in my models.py I import tasks from tasks.py. Shawn -- You received this message because you are subs

celery tasks and circular imports

2011-03-07 Thread cerberos
I have tasks.py that imports models to access the managers. I also want to import a task in a custom save method of one of my models but can't as this creates a circular import. I'm happy to use signals instead hover I don't really know where to register them apart from models.

lazy imports for cyclic imports prevention

2010-02-23 Thread Itay Donenhirsch
Hi folks, in order to prevent cyclic import problems i've written this class: class lazy_import: def __init__(self, module, method = None ): if method: self.module = module self.method = method else: tokens = module.split('.')

Re: Imports, works from directory but not from file

2009-11-12 Thread Bill Freeman
On Thu, Nov 12, 2009 at 10:33 AM, andreas schmid wrote: >> > im on a unix system and i can import it on the django shell but it makes > troubles when running the django server which doesnt make sense It may be that it won't be recognized as an app because the app directory doesn't have a models.

Re: Imports, works from directory but not from file

2009-11-12 Thread rebus_
ething else Also you can keep your models in models/__init__.py and don't need to change any imports, like: app/ models/ __init__.py <- this is where your keep your models On the other hand you can have app/ models/ other_models.py <- this is where the models are for

Re: Imports, works from directory but not from file

2009-11-12 Thread andreas schmid
Bill Freeman wrote: > If that wasn't a typo, I suspect that you're going to have trouble > with having a directory > named "views.py". yes it was a typo... my dir is called 'views' > I don't know how you import anything from it unless > it is directly on > your path. > > When you say "my app is i

Re: Imports, works from directory but not from file

2009-11-12 Thread Bill Freeman
If that wasn't a typo, I suspect that you're going to have trouble with having a directory named "views.py". I don't know how you import anything from it unless it is directly on your path. When you say "my app is in the pythonpath of the environment": 1. Which directory is in the python path?

Re: Imports, works from directory but not from file

2009-11-11 Thread andreas schmid
Bill Freeman wrote: > Does your project root (I'm assuming that's the directory containing > the sub directory "app") have an __init__.py file. Does the app > directory? I'm assuming that the one you mention below is in > app/models/ . All three are required, if what you have on your > sys.path

Re: Imports, works from directory but not from file

2009-11-11 Thread Bill Freeman
Does your project root (I'm assuming that's the directory containing the sub directory "app") have an __init__.py file. Does the app directory? I'm assuming that the one you mention below is in app/models/ . All three are required, if what you have on your sys.path is just the project root. Do

Re: Imports, works from directory but not from file

2009-11-11 Thread andreas schmid
im experiencing the same problem. i started with a simple app and the modules.py was at the root of the app package, so everything was fine. now i extended the app and restructured the files in it by making a subfolder app/models and inside an __init__.py and the mymodel.py in the urls.py which i

Re: Imports, works from directory but not from file

2009-11-11 Thread Bill Freeman
I had another couple of thoughts. In the manage.py shell, try: from openid.yadis import xri xri The output will include from where it got xri. Make sure that it's coming from your lib directory, and not from some old system wide installation of openid. Instead of: from openid.as

Re: Imports, works from directory but not from file

2009-11-10 Thread Bill Freeman
Did you really mean "init.py", rather than the required "__init__.py". If so, that's wrong. I presume that the names of the files and directories are all lower case and contain no spaces or accented characters. I presume that you've checked and rechecked the spelling of the file name against th

Re: Imports, works from directory but not from file

2009-11-10 Thread When ideas fail
I used this in my settings.py to add the open id folder on my path sys.path.append(os.path.join(FILE_ROOT, 'lib', 'openid')) and on my path it say: 'C:\\TheAbeonaFile\\Python26\\Lib\\idlelib\\lib\\openid' And both the yadis file and openid file have an init.py On 10 Nov, 22:18, Bill Freeman wr

Re: Imports, works from directory but not from file

2009-11-10 Thread Bill Freeman
Which all of these directories are on your python path, and which of them have __init__.py files? Bill [Hint to answer first question: from pprint import pprint as pp import sys pp(sys.path) ] On Tue, Nov 10, 2009 at 5:12 PM, When ideas fail wrote: > > I have a folder called lib on my path a

Imports, works from directory but not from file

2009-11-10 Thread When ideas fail
I have a folder called lib on my path and in there I have a folder called openid. If i want to import things from openid i have a problem. For example if I have these 2 import statements: from openid.yadis import xri from openid.association import Association as OIDAssociation yadis is a direc

Re: Circular imports problem

2009-07-08 Thread Ryan K
> > > I am creating an application that uses the dispatcher in Django. In > > the apps models.py file I connect the post_save of two models to > > functions in a signals.py file. The problem is that I need to use > > several models in models.py and that leads to a ci

Re: Circular imports problem

2009-07-08 Thread Alex Gaynor
els.py and that leads to a circular import. What > is the best way to solve this problem? > > Cheers, > Ryan > > > Depending on how you're using these other models you can a) do imports inside of functions, or b) http://docs.djangoproject.com/en/dev/ref/models/fields/#lazy-rela

Circular imports problem

2009-07-08 Thread Ryan K
I am creating an application that uses the dispatcher in Django. In the apps models.py file I connect the post_save of two models to functions in a signals.py file. The problem is that I need to use several models in models.py and that leads to a circular import. What is the best way to solve this

Re: Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread greatlemer
On Jun 15, 10:47 pm, Alex Gaynor wrote: > On Mon, Jun 15, 2009 at 4:39 PM, greatlemer wrote: > > > > > > > Hi everyone, > > > I was creating some custom template tags and attempted to import my > > models through the following import at the top of the file: > > > from ..models import * > > > Unfo

Re: Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread Alex Gaynor
On Mon, Jun 15, 2009 at 4:39 PM, greatlemer wrote: > > Hi everyone, > > I was creating some custom template tags and attempted to import my > models through the following import at the top of the file: > > from ..models import * > > Unfortunately this seems to be attempting to import from django.m

Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread greatlemer
Hi everyone, I was creating some custom template tags and attempted to import my models through the following import at the top of the file: from ..models import * Unfortunately this seems to be attempting to import from django.models (which doesn't exist) rather than myapp.models and therefore

Re: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread codecowboy
Doug, Thank you so much. I completely missed that detail while ripping through the django docs. I've got it all working now. Ramiro, thanks again for your help. For anyone else who is trying to do this and stumbles upon this thread, here is my full final solution. --- Overview --- I've got t

Re: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread Doug B
Take a look at this part of the documentation: http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread codecowboy
 am, Ramiro Morales wrote: > On Sun, Apr 5, 2009 at 11:43 AM, codecowboy wrote: > > > Hi Everyone, > > > I'm new to the Django community and I am having trouble with circular > > imports.  I've read every article that I can find about the issue > > includi

Re: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread Ramiro Morales
On Sun, Apr 5, 2009 at 11:43 AM, codecowboy wrote: > > Hi Everyone, > > I'm new to the Django community and I am having trouble with circular > imports.  I've read every article that I can find about the issue > including posts on this group.  I'm going to pas

Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread codecowboy
Hi Everyone, I'm new to the Django community and I am having trouble with circular imports. I've read every article that I can find about the issue including posts on this group. I'm going to paste my model files and the stack trace. I'm sure that this must be an issue tha

Re: Circular imports between managers and models

2009-01-06 Thread Malcolm Tredinnick
On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote: > Hi, > Suppose I have two classes in "models.py", namely A and B. And there > is the manager for B as BManager in "managers.py". BManager makes use > of clas A. > > This situation leads to circ

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
ple, well-known and idiomatic solution to circular imports. The "correct" solution would be to turn models.py into a package, split its content in submodules (with class A and B in distinct submodules, each with their own manager), and use the package's __init__.py to expose the sub

Re: Circular imports between managers and models

2009-01-06 Thread Ben Eliott
Not that pretty/efficient but you could use contenttype contrib temporarily. IF ClassB has a ForeignKey to Class A could you extract the Class A model from a foreign key via Class B's .meta? Or the Class B could have a callable method which returned the instance of the model you want... No

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
on 6 jan, 14:54, Polat Tuzla wrote: (snip) > The reason why I need to separate models and managers into different > files is that they have simply grown to thousands of lines. > It's indeed a very compelling reason !-) But (simple suggestion - I know nothing about your project...) don't you see

Re: Circular imports between managers and models

2009-01-06 Thread Polat Tuzla
6 jan, 14:08, Lee Braiden wrote: > > > > > On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote: > > > Hi, > > > Suppose I have two classes in "models.py", namely A and B. And there > > > is the manager for B as BManager in "managers.py". BMan

Re: Circular imports between managers and models

2009-01-06 Thread Polat Tuzla
Thank you very much for both of your responses. Local imports solved my problem. I had previously tried this without success, apparently there was another mistake in the code. Upon Bruno's suggestion I gave it another try, and it worked! The reason why I need to separate models and managers

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
; > of clas A. > > > This situation leads to circular imports between "managers.py" and > > "models.py" for which I can't find a solution. > > > Assuming that I need to separate models and manager into different > > files, so merging them is

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
On 6 jan, 13:42, Polat Tuzla wrote: > Hi, > Suppose I have two classes in "models.py", namely A and B. And there > is the manager for B as BManager in "managers.py". BManager makes use > of clas A. > > This situation leads to circular imports between "

Re: Circular imports between managers and models

2009-01-06 Thread Lee Braiden
On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote: > Hi, > Suppose I have two classes in "models.py", namely A and B. And there > is the manager for B as BManager in "managers.py". BManager makes use > of clas A. > > This situation leads to circ

Circular imports between managers and models

2009-01-06 Thread Polat Tuzla
Hi, Suppose I have two classes in "models.py", namely A and B. And there is the manager for B as BManager in "managers.py". BManager makes use of clas A. This situation leads to circular imports between "managers.py" and "models.py" for which I can

Re: When should I do my imports, in views.py?

2008-10-27 Thread Horst Gutmann
According to the Python Coding Guidelines you should always put the imports at the top of a file simply because it makes the file more readable. Performance-wise there are AFAIK some small speed-ramifications (negative ones) when putting imports into a function instead of having them at the

Re: When should I do my imports, in views.py?

2008-10-27 Thread Steve Holden
. Or must I put my imports within the view fuctions that require > them? > > It's OK, and indeed that's the normal way of programming. > Does it depend on how many functions require I certain import? And if > so, how many imports justifies a global import at the top of th

When should I do my imports, in views.py?

2008-10-27 Thread 7timesTom
I have a large number of view functions which require various python, django and other import statements. My question is: is it ok to put ALL my import statements at the top of views.py and then not have to worry about which view fuction uses what. Or must I put my imports within the view

Re: Persistent Global Imports

2008-09-14 Thread Graham Dumpleton
On Sep 15, 1:50 pm, "Chris Spencer" <[EMAIL PROTECTED]> wrote: > One minor question. I'd like to test multiple mod_wsgi Django apps > locally, each accessed like localhost/app*. Can I simply use the above > directives for each app in httpd.conf without using a VirtualHost for > each app? Not qu

  1   2   >