Re: Problems with psycopg2 on Windows 7 64 bit

2014-09-27 Thread Mike Dewhirst

On 28/09/2014 1:47 AM, Daniel Grace wrote:

I got around this particular problem.  The Windows installer for psycopg
(at http://www.stickpeople.com/projects/python/win-psycopg/
)
installs for the global instance of Python,
not the virtualenv.  I copied the psycopg folder and the "egg-info" file
to the virtualenv and the "No module named..." error disappeared.


Another solution is to download the appropriate psycopg2 binary from 
http://www.lfd.uci.edu/~gohlke/pythonlibs/ to a local download dir and 
use easy_install to install it from there. Quite useful for virtualenv 
setups.


I have tried the local compilation road and won't bother ever again 
while Chris Gohlke lives!


Cheers

Mike




--
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/d3d5f9c6-8309-4105-bcd8-e94c0afbc16d%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.


--
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/54278BAC.2040400%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Switching from Linux to Windows for development of Django applications

2014-09-27 Thread Mike Dewhirst

On 28/09/2014 3:09 AM, Some Developer wrote:


If anyone can post information on their Windows development work flows
I'd be very grateful since I'm pretty new to Windows development work.



* This goes against Microsoft recommendations but I install Python2.x 
and Python3.x in the root of drive C: so I'm not forced to use a 
admin-privileged cmd shell.


* I put the following dirs on the Windows path ...

C:\Users\mike\bin and C:\Users\mike\bat

* I write batch files rather than virtualenvwrapper because it wasn't 
available to me when I started using virtualenv.


* My favourite batch file in development is run.bat which launches 
manage.py in various guises ... see below


* I use subversion running on my Ubuntu staging server plus buildbot on 
the same machine. When I commit changes to the repo, buildbot blows the 
staging site away completely and starts again from scratch and runs all 
the tests. I know its not git but I like it.


* I use a plain text editor with syntax highlighting because I haven't 
installed Pycharm. I've downloaded it but haven't had time to think 
about it. I should.


Good luck

Mike

# run.bat
@echo off
echo  .
echo  .
echo  .
echo Should be running in virtualenv
echo  .
echo  .
echo  .
pause

if %1xx==xx (
..\Scripts\python manage.py runserver --settings=ssds.settings.dev
goto end
)

if %2xx==xx (
set apps=common company refer substance workplace
) else (
set apps=%2
)

if %1==dumpdata (
set file=%2
goto dumpdata
)

if %1==syncdb (
set file=%2
goto syncdb
)

if %1==test (

copy substance\fixtures\test_data.json 
substance\fixtures\initial_data.json /Y


..\Scripts\python manage.py test --settings=ssds.settings.test 
--verbosity=1 %apps%


)

if %1==cover (

copy substance\fixtures\test_data.json 
substance\fixtures\initial_data.json /Y


coverage run manage.py test --settings=ssds.settings.test --verbosity=1 
%apps%


coverage html
)

goto end

:syncdb

..\Scripts\python manage.py syncdb


goto end

:dumpdata

if %2xx==xx set file=fixtures\initial_data-x.json

..\Scripts\python manage.py dumpdata --settings=ssds.settings.production 
--indent=2 --verbosity=0 --natural --exclude=contenttypes 
--exclude=auth.permission --exclude=admin.logentry 
--exclude=sessions.session --exclude=company.userprofile project tables>...  --exclude=south.migrationhistory > %file%


:end

set json=fixtures\initial_data.json

if exist %json% (del %json%)


--
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/542788C5.7020805%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Switching from Linux to Windows for development of Django applications

2014-09-27 Thread Mike Dewhirst

On 28/09/2014 5:18 AM, Avraham Serour wrote:

some packages that requires compilation could be a headache, the easier
path is to get a binary and use easy_install to install inside the venv



Chris Gohlke is your very best friend ...

http://www.lfd.uci.edu/~gohlke/pythonlibs/

... makes Windows development sustainable.

Mike

--
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/54278210.8030703%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 and Python 2.6

2014-09-27 Thread Russell Keith-Magee
Out of the box, it won't work - but if maintaining an internal fork that
adds Python 2.6 compatibility back in shouldn't be *too* difficult.

When we drop support for a Python version, we don't go out of our way to
break compatibility with that version. It's more like a gradual process
where language features incompatible with older versions of Python slowly
drift into the codebase.

The two sources of problems you'll hit are:

 1) Using language features available in 2.7 that weren't in 2.6. Set
literals, dictionary/set comprehensions, and multiple context managers are
the new features that are most likely to cause problems.

 2) Relying on compatibility shims that are no longer required in 2.7, and
so were removed. The native OrderedDictionary type will be the complication
here. We previously shipped a shim for older Python versions; that shim was
removed in Django 1.7.

If you're absolutely stuck on 2.6, and you can't use a virutalenv or docker
container to isolate your Python requirements (as suggested by others in
this thread), then a back port might be an option.

The ultimate test - Can you run Django's own test suite? Once the test
suite runs, you shouldn't have any problems.

Yours
Russ Magee %-)

On Sun, Sep 28, 2014 at 2:54 AM, François Schiettecatte <
fschietteca...@gmail.com> wrote:

> Hi
>
> I know that Django 1.7 does not officially run on Python 2.6:
>
>
> https://docs.djangoproject.com/en/1.7/releases/1.7/#python-compatibility
>
> Unfortunately I am stuck with Python 2.6 on a number of servers but would
> like to migrate to Django 1.7. Does anyone run that configuration? Is there
> anything in Django 1.7 which explicitly prevents it from running on Python
> 2.6? Or is this a "great if it runs, but don't care if it doesn't"
> situation.
>
> Cheers
>
> François
>
>
> --
> 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/04A8E7D2-35CD-429A-873F-FF20C4D3D492%40gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAJxq84-MEYEN_fX6f2Sj%3DguLB-jp%3D9GKvw36o9CRbG4GDSX_aQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 and Python 2.6

2014-09-27 Thread phil...@bailey.st

Hello there,

docker might do the job.

Cheers,

Phillip


On 27/09/14 20:42, Babatunde Akinyanmi wrote:
> Hi,
> If you can download in your server then you can install python 2.7+ into
> your virtenv.
> 
> On 27 Sep 2014 19:54, "François Schiettecatte"  > wrote:
> 
> Hi

-- 
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/54271FDF.6090201%40bailey.st.
For more options, visit https://groups.google.com/d/optout.


Django Locale

2014-09-27 Thread Anderson
Hi there,

For some reason my locale file is not loading when I switch the language.
This is pretty much what I did


locale ->
  pt_BR->
 LC_MESSAGES->
   django.mo
   django.po

 en->
 LC_MESSAGES->
   django.mo
   django.po

no settings

LANGUAGES = (
   ('en', _('English')),
('pt-br', _('Portuguese')),
)






-- 
Anderson Dias Borges
Senior Analyst Developer

Tu cumprirás o desejo do meu coração se eu Te buscar...
I can't see but I'll take my chances
To hear You call my name

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


Re: Django 1.7 and Python 2.6

2014-09-27 Thread Babatunde Akinyanmi
Hi,
If you can download in your server then you can install python 2.7+ into
your virtenv.
On 27 Sep 2014 19:54, "François Schiettecatte" 
wrote:

> Hi
>
> I know that Django 1.7 does not officially run on Python 2.6:
>
>
> https://docs.djangoproject.com/en/1.7/releases/1.7/#python-compatibility
>
> Unfortunately I am stuck with Python 2.6 on a number of servers but would
> like to migrate to Django 1.7. Does anyone run that configuration? Is there
> anything in Django 1.7 which explicitly prevents it from running on Python
> 2.6? Or is this a "great if it runs, but don't care if it doesn't"
> situation.
>
> Cheers
>
> François
>
>
> --
> 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/04A8E7D2-35CD-429A-873F-FF20C4D3D492%40gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Switching from Linux to Windows for development of Django applications

2014-09-27 Thread Avraham Serour
are you doing python or windows development?

python development on windows shouldn't be much different, you have
virtualenv and the same pycharm

some packages that requires compilation could be a headache, the easier
path is to get a binary and use easy_install to install inside the venv

On Sat, Sep 27, 2014 at 8:09 PM, Some Developer 
wrote:

> Hi,
>
> For reasons outside of my control I have to switch from Linux to Windows
> for Django development and was wondering if any Windows developers had any
> tips?
>
> On Linux I make heavy use of pip and virtualenv to make sure that my
> packages are kept separate from the system packages. I'm thinking about
> moving all my development to Python 3.4 which includes a version of
> virtualenv. How does this work on Windows? Do you just install packages
> normally using the command line into these environments using pip as you
> would on Linux?
>
> I'm also thinking about using PyCharm for my development since I can get a
> student license for it which seems like a good deal to me. Does that also
> support Python 3.4 virtualenvs?
>
> If anyone can post information on their Windows development work flows I'd
> be very grateful since I'm pretty new to Windows development work.
>
> Thanks in advance.
>
> --
> 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/5426EF5A.2040705%40googlemail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Django 1.7 and Python 2.6

2014-09-27 Thread François Schiettecatte
Hi

I know that Django 1.7 does not officially run on Python 2.6:

https://docs.djangoproject.com/en/1.7/releases/1.7/#python-compatibility

Unfortunately I am stuck with Python 2.6 on a number of servers but would like 
to migrate to Django 1.7. Does anyone run that configuration? Is there anything 
in Django 1.7 which explicitly prevents it from running on Python 2.6? Or is 
this a "great if it runs, but don't care if it doesn't" situation.

Cheers

François


-- 
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/04A8E7D2-35CD-429A-873F-FF20C4D3D492%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading Django (to 1.7)

2014-09-27 Thread Andrew Pinkham
Hi Bob,
Thank you!

I spend a lot of Part II talking about schema and data migrations in both South 
and native Django 1.7 migrations. When building data migrations, you should be 
using historical models. In Django 1.7, you can request these models directly 
from the app registry built on the fly by the migration system and passed to 
the methods specified in the `RunPython` operation. This avoids using the 
models as they exist in the `models.py` file. This is similar to South's 
requirement you use the `orm` variable to interact with models, as Fred 
mentions.

If you would like more depth on the topic, then Part II is for you. If you 
would like to explore the topic before Wednesday, this is material available in 
the video. The code in the slides and github repo may be quite helpful as well.

afrg.co/updj17

Data migrations and schema migrations should play very well with each other. As 
I mentioned to Sabine, the only instance I had any difficulty was when I 
squashed migrations. As I had been alternating systematically between schema 
migrations and data migrations, the automatic squash tool was unhelpful. 
Thankfully, as the migration files are now easy to edit, I had absolutely no 
issue modifying the squash migration file myself.

Unfortunately, I do not go into detail about this in the article. Hopefully, 
the number of times we directly modify the migration files will allow people to 
figure this out for themselves. If that is not the case, and enough people ask, 
I will happily write a short article about the process.

If you have any questions about data migrations after reading Part II, please 
ask them here!

Andrew

-- 
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/27F0C6E5-1DEC-4C79-A3AD-59005A801B1A%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.


Switching from Linux to Windows for development of Django applications

2014-09-27 Thread Some Developer

Hi,

For reasons outside of my control I have to switch from Linux to Windows 
for Django development and was wondering if any Windows developers had 
any tips?


On Linux I make heavy use of pip and virtualenv to make sure that my 
packages are kept separate from the system packages. I'm thinking about 
moving all my development to Python 3.4 which includes a version of 
virtualenv. How does this work on Windows? Do you just install packages 
normally using the command line into these environments using pip as you 
would on Linux?


I'm also thinking about using PyCharm for my development since I can get 
a student license for it which seems like a good deal to me. Does that 
also support Python 3.4 virtualenvs?


If anyone can post information on their Windows development work flows 
I'd be very grateful since I'm pretty new to Windows development work.


Thanks in advance.

--
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/5426EF5A.2040705%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading Django (to 1.7)

2014-09-27 Thread Andrew Pinkham
Benjamin,
Thank you!

The next two parts of the article will focus on why certain changes were made. 
Please let me know if you think there were changes that I should have written 
about. Depending on my schedule and feedback, I would be willing to consider 
adding to the material if I've missed anything.

I'm happy to expand on my opinion if desired, but I don't think the 
documentation should have history/background sections. The documentation is 
already an enormous amount of work, and I like the fact that is sticks to being 
reference documentation.

However, I think the emails from Aymeric Augustin, Russell Keith-Magee, and 
Christopher Medrela documenting their work are incredibly helpful. Andrew 
Godwin even kept a blog! I would love it if people continued this trend. I will 
be linking to their work in Part III because of how useful and interesting the 
emails/blog-posts are. I think we owe them all a huge thank you for the effort.

Finally, the wiki contains some historical/background documents. I would not be 
averse to more pages like that, nor would I be averse to the release notes 
pointing to the emails mentioned above.

Andrew

-- 
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/5CF92E59-DDCB-4C82-B395-A619C9AD9912%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problems with psycopg2 on Windows 7 64 bit

2014-09-27 Thread Daniel Grace
I got around this particular problem.  The Windows installer for psycopg 
(at http://www.stickpeople.com/projects/python/win-psycopg/ 
)
 
installs for the global instance of Python,
not the virtualenv.  I copied the psycopg folder and the "egg-info" file to 
the virtualenv and the "No module named..." error disappeared.

-- 
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/d3d5f9c6-8309-4105-bcd8-e94c0afbc16d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Fwd: Re: Upgrading Django (to 1.7)

2014-09-27 Thread Fred Stluka

Bob,

Are you referring directly to the models by name in the data
migrations?  That could be the problem, because yes, the migration
would be using the latest models at the time that the migration is
executed, not the models as they stood at the time that the
migration was written.

There's a warning in a comment in the boilerplate code generated
for each data migration by the command:
% manage datamigration  

It says:

def forwards(self, orm):
"Write your forwards methods here."
# Note: Don't use "from appname.models import ModelName".
# Use orm.ModelName to refer to models in this application,
# and orm['appname.ModelName'] for models in other applications.

and there is a dictionary of the models as they existed at that
time shown later in the same file.

If you always follow this advice and manipulate orm.ModelName
instead of appname.models.ModelName, it should solve exactly
the problem you are describing.

Hope this helps,
--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 9/27/14 10:00 AM, bobhaugen wrote:
The problem we ran into was not with the order of migrations, it was 
that all of the migrations were running with the latest models.py 
code. The data migration was trying to move data from one model field 
to another model field, and the "from" field had been deleted from 
models.py.


This was awhile ago, and my memory might be faulty. Do the latest 
migrations give you any way to deal with that situation? I mean, do 
they migrate the models in models.py in sync with the the database 
schema migrations?


I can see where a data migration might work in a schema migration 
sequence if you expressed it all in SQL, just dealing with the 
database alone, but we of course wrote in Python using the Django ORM.


On Friday, September 26, 2014 10:04:49 AM UTC-5, Fred Stluka wrote:

Bob,

You can control the order in which migrations run.

For South, see "depends_on" and "needed_by":
- http://south.readthedocs.org/en/latest/dependencies.html


For Django 1.7 migrations, see "dependencies":
-
https://docs.djangoproject.com/en/dev/topics/migrations/#dependencies


--Fred






--
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/5426C996.4050001%40bristle.com.
For more options, visit https://groups.google.com/d/optout.


Problems with psycopg2 on Windows 7 64 bit

2014-09-27 Thread Daniel Grace
I have installed Python 3.4, Django 1.7, Postgresql 9.3 and psycopg2-2.5.4 
(using the Windows installer 
at http://www.stickpeople.com/projects/python/win-psycopg/)

When I try a syncdb command from my virtualenv I get the following error:

(landy) C:\landy\cresta>python manage.py syncdb
Traceback (most recent call last):
  File 
"C:\landy\lib\site-packages\django\db\backends\postgresql_psycopg2\base.p
y", line 23, in 
import psycopg2 as Database
ImportError: No module named 'psycopg2'

I am not sure if I needed to do:
> pip install psycopg2

...which gives the following:

error: Unable to find vcvarsall.bat

I have Visual Studio 2012 installed if that helps?  Any other ideas?

Thanks.

-- 
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/6774474d-95c7-4fa1-b476-4369081abc0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading Django (to 1.7)

2014-09-27 Thread bobhaugen
The problem we ran into was not with the order of migrations, it was that 
all of the migrations were running with the latest models.py code. The data 
migration was trying to move data from one model field to another model 
field, and the "from" field had been deleted from models.py.  

This was awhile ago, and my memory might be faulty. Do the latest 
migrations give you any way to deal with that situation? I mean, do they 
migrate the models in models.py in sync with the the database schema 
migrations? 

I can see where a data migration might work in a schema migration sequence 
if you expressed it all in SQL, just dealing with the database alone, but 
we of course wrote in Python using the Django ORM.

On Friday, September 26, 2014 10:04:49 AM UTC-5, Fred Stluka wrote:
>
>  Bob,
>
> You can control the order in which migrations run.
>
> For South, see "depends_on" and "needed_by":
> - http://south.readthedocs.org/en/latest/dependencies.html
>
> For Django 1.7 migrations, see "dependencies":
> - https://docs.djangoproject.com/en/dev/topics/migrations/#dependencies
>
> --Fred 
> --
>
>  

-- 
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/418bd491-1068-4688-af2a-9754802b988c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to use a 'all' QuerySet as a dict with id first

2014-09-27 Thread tkdchen


On Saturday, September 27, 2014 9:06:58 PM UTC+8, aRkadeFR wrote:
>
> @James Brewer: 
> If I change my code, I can have this user_ids list. 
> btw, it's filter and not get if you're searching multiple objects (the 
> user_ids). 
>
> @Alejandro Varas G.: 
> That doesn't change the fact that 'User.objects.get(id=X)' will hit the 
> database everytime. 
>
> Right now, the problem is solved, by creating the AllUserSet, but I think 
> my 
> code is pretty ugly, and it seems strange to me that the ORM can't handle 
> that 
> built-in, by caching the .all() or .filter(id__in=users_ids) 
>
>
Django actually caches all objects fetched when it evaluates .all or 
.filter method. The problem you are facing is that how to reuse the cached 
objects efficiently to avoid hitting database with unnecessary SQL queries. 
James gave you a good solution. Based on his solution, you don't need to 
call the `get' method each time getting user by id. Just iterate users 
object and find the right one by comparing id.


 

> The ideally solution would be something like: 
>
> AllUser = User.objects.all() 
>
> for i in user_id: 
> AllUser.get(id=i) 
>
>
This piece of code would be changed to

AllUser = User.objects.all()
for i in user_id:
for user in AllUser:
if user.pk == i:
print 'find the user'

or, even you may construct AllUser to dict to simplify the search

AllUser = dict((user.pk, user) for user in User.objects.all()) # Here, hit 
db, only once
for i in user_id:
user = AllUser.get(i, None) # search by id in memory
if user is not None:
print 'find the user'

Hope, this could help you. 

But this code hits the database every time the 'get' is called. 
>
>
> On 26/09/14 12:36, James Brewer wrote: 
> > Do you have a single list of the IDs you want? If so, you can do 
> something 
> > like `User.objects.get(id__in=user_ids)`. This will fetch all Users 
> whose 
> > `id` is in some list `user_ids`. 
> > 
> > Does that help? 
> > 
> > Happy hacking! 
> > 
> > James 
> > 
> > On Fri, Sep 26, 2014 at 11:43 AM, Alejandro Varas G.  > 
> > wrote: 
> > 
> > > Hi, 
> > > 
> > > You should use User.objects.get(id=X) 
> > > 
> > > Best 
> > > El 26/09/2014 15:28, "aRkadeFR"  
> escribió: 
> > > 
> > > > 
> > > > Hey! 
> > > > 
> > > > I'm having a hard time trying to reduce the number of SQL queries on 
> a 
> > > view. 
> > > > 
> > > > Basically, I'm fetching all my User, with User.objects.all(), and 
> save 
> > > this 
> > > > queryset as AllUser. 
> > > > 
> > > > Then every time I need to get the user with the id = X , I'm calling 
> a 
> > > function 
> > > > 'get_user_from_id', that iterate over the AllUser queryset variable, 
> and 
> > > when 
> > > > it finds the id, returns it. 
> > > > 
> > > > I considerably reduced the number of SQL queries, but I would like 
> to 
> > > know if 
> > > > you think of a better way? 
> > > > 
> > > > Thank you 
> > > > 
> > > > -- 
> > > > 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...@googlegroups.com . 
> > > > To post to this group, send email to django...@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/20140926182939.GA26744%40rkade-thinkpad
>  
> > > . 
> > > > For more options, visit https://groups.google.com/d/optout. 
> > > 
> > >  -- 
> > > 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...@googlegroups.com . 
> > > To post to this group, send email to django...@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/CAL60nj%2BBtqs9CXu8drOiWPoJ7aUkAKjLqXKCxmR_TMTeOOH%3DGw%40mail.gmail.com
>  
> > > <
> https://groups.google.com/d/msgid/django-users/CAL60nj%2BBtqs9CXu8drOiWPoJ7aUkAKjLqXKCxmR_TMTeOOH%3DGw%40mail.gmail.com?utm_medium=email_source=footer>
>  
>
> > > . 
> > > 
> > > For more options, visit https://groups.google.com/d/optout. 
> > > 
> > 
> > 
> > 
> > -- 
> > James Brewer 
> > jamesbrewer.io 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> 

Re: Error installing psycopg2-2.5.4 on Windows 7

2014-09-27 Thread Daniel Grace
I solved this.  I was using the wrong version of psycopg2, I needed the 64 
bit version.

On Saturday, 27 September 2014 14:35:43 UTC+1, Daniel Grace wrote:
>
> Hi,
> I have Python 3.4, Django 1.7 and Postgresql 9.3 installed.  I get the 
> following error when installing pscyopg2-2.5.4 on Windows 7:
>
> Python version 3.4 required, which was not found in the registry.
>
> Any ideas?
>
> Thanks.
>

-- 
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/bf647890-a259-4131-b831-3c737698d59e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Error installing psycopg2-2.5.4 on Windows 7

2014-09-27 Thread Daniel Grace
Hi,
I have Python 3.4, Django 1.7 and Postgresql 9.3 installed.  I get the 
following error when installing pscyopg2-2.5.4 on Windows 7:

Python version 3.4 required, which was not found in the registry.

Any ideas?

Thanks.

-- 
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/fde5eb81-a5dc-4285-8b74-3e77b7fd9e6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to use a 'all' QuerySet as a dict with id first

2014-09-27 Thread aRkadeFR
@James Brewer:
If I change my code, I can have this user_ids list.
btw, it's filter and not get if you're searching multiple objects (the
user_ids).

@Alejandro Varas G.:
That doesn't change the fact that 'User.objects.get(id=X)' will hit the
database everytime.

Right now, the problem is solved, by creating the AllUserSet, but I think my
code is pretty ugly, and it seems strange to me that the ORM can't handle that
built-in, by caching the .all() or .filter(id__in=users_ids)

The ideally solution would be something like:

AllUser = User.objects.all()

for i in user_id:
AllUser.get(id=i)

But this code hits the database every time the 'get' is called.


On 26/09/14 12:36, James Brewer wrote:
> Do you have a single list of the IDs you want? If so, you can do something
> like `User.objects.get(id__in=user_ids)`. This will fetch all Users whose
> `id` is in some list `user_ids`.
> 
> Does that help?
> 
> Happy hacking!
> 
> James
> 
> On Fri, Sep 26, 2014 at 11:43 AM, Alejandro Varas G. 
> wrote:
> 
> > Hi,
> >
> > You should use User.objects.get(id=X)
> >
> > Best
> > El 26/09/2014 15:28, "aRkadeFR"  escribió:
> >
> > >
> > > Hey!
> > >
> > > I'm having a hard time trying to reduce the number of SQL queries on a
> > view.
> > >
> > > Basically, I'm fetching all my User, with User.objects.all(), and save
> > this
> > > queryset as AllUser.
> > >
> > > Then every time I need to get the user with the id = X , I'm calling a
> > function
> > > 'get_user_from_id', that iterate over the AllUser queryset variable, and
> > when
> > > it finds the id, returns it.
> > >
> > > I considerably reduced the number of SQL queries, but I would like to
> > know if
> > > you think of a better way?
> > >
> > > Thank you
> > >
> > > --
> > > 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/20140926182939.GA26744%40rkade-thinkpad
> > .
> > > For more options, visit https://groups.google.com/d/optout.
> >
> >  --
> > 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/CAL60nj%2BBtqs9CXu8drOiWPoJ7aUkAKjLqXKCxmR_TMTeOOH%3DGw%40mail.gmail.com
> > 
> > .
> >
> > For more options, visit https://groups.google.com/d/optout.
> >
> 
> 
> 
> -- 
> James Brewer
> jamesbrewer.io
> 
> -- 
> 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/CAKj8pVpqBgpFDQ0BruHXLWe2q1CRURMEejokhMKpD5bfs9hGGA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/20140927130809.GA3104%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Re: syncdb error with Mysql database on Windows 7

2014-09-27 Thread Daniel Grace
For the record I solved this, I was mistaken there was no "mydb" schema in 
MySQL.  I created this schema and ran the "syncdb" command without any 
problems.

-- 
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/88715e60-0ed6-443b-b23e-5a2767cf92d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Rendering XML using XSLT

2014-09-27 Thread Timothy W. Cook
On Sat, Sep 27, 2014 at 9:02 AM, John  wrote:

>  Do you have a URL conf that matches the /get_xsd/ccd-description.xsl
>  stylesheet? You
> have to match and serve that as well.
>


> Taking a step back though. It looks like you are serving static files that
> would be best served from a webserver, perhaps with some symlinks, so that
> the overhead of Django is not required at all.
>
> John
>


​This gave me the hint in a solution. The overhead isn't a big deal in this
use case so using Django is easier and more portable (I think). ​

​I created a URL:  ​url(r'^get_xsd/ccd-description.xsl',
"ccdgen.views.get_xsl")

and the associated view:
def get_xsl(request):

CWD = os.getcwd()
if CWD == '/':# Live site
xslfile = "/home/ccdgen/ccdlib/ccd-description.xsl"
else: # development
xslfile = "ccdlib/ccd-description.xsl"
xsl = open(xslfile,encoding='utf-8')

response = HttpResponse(mimetype="text/xsl")
for line in xsl:
response.write(line)
xsl.close()

return response


​ ​
​Thanks for the nudge in the right direction. ​







>
>
> On 27/09/14 12:37, Timothy W. Cook wrote:
>
>  Some details I forgot are that this is Django 1.6.4, Python 3.4.1.
> The 404 error is on http://192.168.1.9:8080/get_xsd/ccd-description.xsl
>
> On Sat, Sep 27, 2014 at 8:10 AM, Timothy W. Cook  wrote:
>
>>  I have a view that opens an XML file (it happens to be a schema but
>> that doesn't matter) that specifies a stylesheet.
>> It works as expected when opening the XML file locally.
>>
>>  ​The stylesheet isn't applied when viewing the file via Django and I
>> see in Firebug that I am getting a 404 on the stylesheet. The stylesheet is
>> in the same directory as the XML file.
>>
>>  So how do I setup a view or add this file to my existing view so it is
>> found?
>>
>>  The view:
>> ​def get_ccddetails(request, id):
>>
>>  ccd = CCD.objects.get(pk=id)
>> ccdid= ccd.ct_id
>>
>>  CWD = os.getcwd()
>> if CWD == '/':# Live site
>> frm_dir = "/home/ccdgen/ccdlib/CCD_"+ ccdid
>> else: # development
>> frm_dir = "ccdlib/CCD_"+ ccdid
>>
>>  filename = frm_dir+"/ccd-"+ccdid+".xsd"
>> if os.path.isfile(filename):
>> response = HttpResponse(mimetype="application/xml; charset=utf-8")
>> f = open(filename, encoding="utf-8")
>> for line in f:
>> response.write(line)
>> f.close()
>> else:
>> response = HttpResponseNotFound("XSD: "+filename+" was not
>> found.")
>> return response
>>
>>  ​The URL:
>> ​url(r'^get_xsd/(?P\d+)$', "ccdgen.views.get_ccddetails",
>> name='getxsd'),
>>
>>
>>
>>  ​ Thanks,
>> Tim ​
>>
>>
>>
>>
>>
>>
>>
>> 
>> Timothy Cook
>> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
>> MLHIM http://www.mlhim.org
>>
>>
>
>
>  --
>
> 
> Timothy Cook
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> MLHIM http://www.mlhim.org
>
>   --
> 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/CA%2B%3DOU3VLaAHC8bv-S9sQfKLY8efgZOrQjnq4LPUKfB3r%3D3e0_g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> 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/5426A746.3090605%40martinhome.org.uk
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

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

Re: Rendering XML using XSLT

2014-09-27 Thread John
Do you have a URL conf that matches the /get_xsd/ccd-description.xsl
 stylesheet? You
have to match and serve that as well.

Taking a step back though. It looks like you are serving static files
that would be best served from a webserver, perhaps with some symlinks,
so that the overhead of Django is not required at all.

John

On 27/09/14 12:37, Timothy W. Cook wrote:
> Some details I forgot are that this is Django 1.6.4, Python 3.4.1.
> The 404 error is on http://192.168.1.9:8080/get_xsd/ccd-description.xsl 
>
> On Sat, Sep 27, 2014 at 8:10 AM, Timothy W. Cook  > wrote:
>
> I have a view that opens an XML file (it happens to be a schema
> but that doesn't matter) that specifies a stylesheet.
> It works as expected when opening the XML file locally.
>
> ​The stylesheet isn't applied when viewing the file via Django and
> I see in Firebug that I am getting a 404 on the stylesheet. The
> stylesheet is in the same directory as the XML file.
>
> So how do I setup a view or add this file to my existing view so
> it is found? 
>
> The view:
> ​def get_ccddetails(request, id):
>
> ccd = CCD.objects.get(pk=id)
> ccdid= ccd.ct_id
>
> CWD = os.getcwd()
> if CWD == '/':# Live site
> frm_dir = "/home/ccdgen/ccdlib/CCD_"+ ccdid
> else: # development
> frm_dir = "ccdlib/CCD_"+ ccdid
>
> filename = frm_dir+"/ccd-"+ccdid+".xsd"
> if os.path.isfile(filename):
> response = HttpResponse(mimetype="application/xml;
> charset=utf-8")
> f = open(filename, encoding="utf-8")
> for line in f:
> response.write(line)
> f.close()
> else:
> response = HttpResponseNotFound("XSD: "+filename+" was
> not found.")
> return response
>
> ​The URL:
> ​url(r'^get_xsd/(?P\d+)$', "ccdgen.views.get_ccddetails",
> name='getxsd'),
>
>
>
> ​ Thanks,
> Tim ​
>
>
>
>
>
>  
>
> 
> Timothy Cook
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> MLHIM http://www.mlhim.org 
>
>
>
>
> -- 
>
> 
> Timothy Cook
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> MLHIM http://www.mlhim.org 
>
> -- 
> 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/CA%2B%3DOU3VLaAHC8bv-S9sQfKLY8efgZOrQjnq4LPUKfB3r%3D3e0_g%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
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/5426A746.3090605%40martinhome.org.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Rendering XML using XSLT

2014-09-27 Thread Timothy W. Cook
Some details I forgot are that this is Django 1.6.4, Python 3.4.1.
The 404 error is on http://192.168.1.9:8080/get_xsd/ccd-description.xsl

On Sat, Sep 27, 2014 at 8:10 AM, Timothy W. Cook  wrote:

> I have a view that opens an XML file (it happens to be a schema but that
> doesn't matter) that specifies a stylesheet.
> It works as expected when opening the XML file locally.
>
> ​The stylesheet isn't applied when viewing the file via Django and I see
> in Firebug that I am getting a 404 on the stylesheet. The stylesheet is in
> the same directory as the XML file.
>
> So how do I setup a view or add this file to my existing view so it is
> found?
>
> The view:
> ​def get_ccddetails(request, id):
>
> ccd = CCD.objects.get(pk=id)
> ccdid= ccd.ct_id
>
> CWD = os.getcwd()
> if CWD == '/':# Live site
> frm_dir = "/home/ccdgen/ccdlib/CCD_"+ ccdid
> else: # development
> frm_dir = "ccdlib/CCD_"+ ccdid
>
> filename = frm_dir+"/ccd-"+ccdid+".xsd"
> if os.path.isfile(filename):
> response = HttpResponse(mimetype="application/xml; charset=utf-8")
> f = open(filename, encoding="utf-8")
> for line in f:
> response.write(line)
> f.close()
> else:
> response = HttpResponseNotFound("XSD: "+filename+" was not
> found.")
> return response
>
> ​The URL:
> ​url(r'^get_xsd/(?P\d+)$', "ccdgen.views.get_ccddetails",
> name='getxsd'),
>
>
>
> ​Thanks,
> Tim​
>
>
>
>
>
>
>
> 
> Timothy Cook
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> MLHIM http://www.mlhim.org
>
>


-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
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/CA%2B%3DOU3VLaAHC8bv-S9sQfKLY8efgZOrQjnq4LPUKfB3r%3D3e0_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Rendering XML using XSLT

2014-09-27 Thread Timothy W. Cook
I have a view that opens an XML file (it happens to be a schema but that
doesn't matter) that specifies a stylesheet.
It works as expected when opening the XML file locally.

​The stylesheet isn't applied when viewing the file via Django and I see in
Firebug that I am getting a 404 on the stylesheet. The stylesheet is in the
same directory as the XML file.

So how do I setup a view or add this file to my existing view so it is
found?

The view:
​def get_ccddetails(request, id):

ccd = CCD.objects.get(pk=id)
ccdid= ccd.ct_id

CWD = os.getcwd()
if CWD == '/':# Live site
frm_dir = "/home/ccdgen/ccdlib/CCD_"+ ccdid
else: # development
frm_dir = "ccdlib/CCD_"+ ccdid

filename = frm_dir+"/ccd-"+ccdid+".xsd"
if os.path.isfile(filename):
response = HttpResponse(mimetype="application/xml; charset=utf-8")
f = open(filename, encoding="utf-8")
for line in f:
response.write(line)
f.close()
else:
response = HttpResponseNotFound("XSD: "+filename+" was not
found.")
return response

​The URL:
​url(r'^get_xsd/(?P\d+)$', "ccdgen.views.get_ccddetails",
name='getxsd'),



​Thanks,
Tim​








Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
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/CA%2B%3DOU3WhQmz95Kv9jaYEpcCMXpxiPh4HYh%2Bo%2B33nYE3Gyt_mEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.