Re: How to load data to auth_permissions from initial_data.json when the auth_groups is also loaded from fixture?

2011-11-08 Thread Jason
I'm investigating this as well. I just read that using the natural
keys dumpdata option might help.

https://docs.djangoproject.com/en/dev/topics/serialization/#topics-serialization-natural-keys

On Oct 28, 9:48 am, ycseattle  wrote:
> Hi,
>
> In my application, I have fixed groups (like admin, staff, subscribers)
> etc, and this data in auth_groups is not intended to change in the program,
> so I am loading them in initial_data.json. I also want to load data into
> auth_group_permissions as the application is not expected to change it. The
> problem is that I noticed the table auth_permissions is generated by
> Django, so the permissions IDs will be dynamic (especially when I add new
> models as it seems the permissions are ordered by the model names). Is
> there a way to load my definition of group permissions through
> initial_data.json, or am I stuck with running a piece of code to do this?
>
> Thanks,
> Yi

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



How to load data to auth_permissions from initial_data.json when the auth_groups is also loaded from fixture?

2011-10-28 Thread ycseattle
Hi, 

In my application, I have fixed groups (like admin, staff, subscribers) 
etc, and this data in auth_groups is not intended to change in the program, 
so I am loading them in initial_data.json. I also want to load data into 
auth_group_permissions as the application is not expected to change it. The 
problem is that I noticed the table auth_permissions is generated by 
Django, so the permissions IDs will be dynamic (especially when I add new 
models as it seems the permissions are ordered by the model names). Is 
there a way to load my definition of group permissions through 
initial_data.json, or am I stuck with running a piece of code to do this? 

Thanks,
Yi

-- 
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/-/D1x0zXQVzAcJ.
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: How to load data from local static path in templates (security error)

2011-08-18 Thread Tom Evans
On Wed, Aug 17, 2011 at 8:39 PM, Daniel Roseman  wrote:
> On Wednesday, 17 August 2011 19:00:13 UTC+1, Adam Zedan wrote:
>>
>> Hi it seems I cant access data from local static paths such as
>> c:\\somefolder\somefile.gif in my templates when I enter the url
>> the code for my template is simplified to something like this
>>
>> 
>> 
>>     
>>         
>>         Demo
>>     
>>     
>>     
>>     
>> 
>>
>> The title change to Demo. which shows that the page has loaded but
>> I get the error in firefox saying:
>> Security Error: Content at http://127.0.0.1:8000/db/ may not load or link
>> to file:///c://bender.gif
>
>
> No, you can't do that. Why would you want to? Your users aren't going to
> have that file on their machines, so what's the point of referencing a local
> file path?
> You serve the content through your webserver, with an http:// protocol. In
> development, you can do this through Django's development server:
> https://docs.djangoproject.com/en/1.3/howto/static-files/
> --
> DR.
>

The OP clearly doesn't understand why though, see his other thread on
this topic.

Your browser is a careful beast. It won't allow a webpage loaded from
the internet zone to load things from the local zone, as That Would Be
Bad. When you 'double click' the file and 'it works', what is actually
happening is that the webpage is loaded from the local zone, and so
access is allowed.

Also, Django is a web app. This means that most users who use your
site will not be using it from your desktop, so they would not be able
to access files on your local machine. Therefore, you need to provide
a way to serve these files over HTTP, so that other users can access
them. See the link in Daniel's reply on how to do this.

Cheers

Tom

-- 
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: How to load data from local static path in templates (security error)

2011-08-17 Thread Daniel Roseman
On Wednesday, 17 August 2011 19:00:13 UTC+1, Adam Zedan wrote:
>
> Hi it seems I cant access data from local static paths such as 
> c:\\somefolder\somefile.gif in my templates when I enter the url
> the code for my template is simplified to something like this
>
> 
> 
> 
> 
> Demo
> 
> 
> 
> 
> 
>
> The title change to Demo. which shows that the page has loaded but 
> I get the error in firefox saying:
> Security Error: Content at http://127.0.0.1:8000/db/ may not load or link 
> to file:///c://bender.gif
>


No, you can't do that. Why would you want to? Your users aren't going to 
have that file on their machines, so what's the point of referencing a local 
file path?

You serve the content through your webserver, with an http:// protocol. In 
development, you can do this through Django's development server:
https://docs.djangoproject.com/en/1.3/howto/static-files/
--
DR. 

-- 
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/-/HtvmZxg0QJ4J.
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: how to load data?

2009-05-23 Thread Reiner

Fields seperated with \t sounds a bit like a CSV export right? I
needed to import CSV too, so I used the csv module to parse the file
and then django models to store it in the database, no custom sql
needed.

# set up django environment
[ ... ]
import csv
reader = csv.reader(open('file.csv', 'r'), delimiter=r'\t',
quotechar='"')
for row in reader:
   myapp.mymodel.objects.create(
  pk=row[0],
  title=row[1],
  ...
   )

On May 23, 4:04 am, Herta <herta...@gmail.com> wrote:
> The input file is a plain txt file with \t, I just want to know if
> there is a function to import data from the existing file, if i don't
> write a script with a sql='insert into table values(...) '
>
> On May 23, 8:43 am, George Song <geo...@damacy.net> wrote:
>
> > On 5/22/2009 5:07 PM, Herta wrote:
>
> > > I want to load data to database (sqlite3 ) from file. I have already
> > > connect django and my database, and build the tables but how can i
> > > load data from file?
>
> > What kind of files are these? If they are existing legacy data files,
> > you'll have to write some sort of de-serializer to translate them to fit
> > your model(s).
>
> > If the file happens to be one of the serialization formats that Django
> > already knows how to deal with, you might be able to use Django's
> > serialization somehow.
>
> > But some more specifics on your data format will allow us to help you more.
>
> > --
> > George
--~--~-~--~~~---~--~~
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: how to load data?

2009-05-22 Thread Alex Gaynor
On Fri, May 22, 2009 at 7:43 PM, George Song <geo...@damacy.net> wrote:

>
> On 5/22/2009 5:07 PM, Herta wrote:
> > I want to load data to database (sqlite3 ) from file. I have already
> > connect django and my database, and build the tables but how can i
> > load data from file?
>
> What kind of files are these? If they are existing legacy data files,
> you'll have to write some sort of de-serializer to translate them to fit
> your model(s).
>
> If the file happens to be one of the serialization formats that Django
> already knows how to deal with, you might be able to use Django's
> serialization somehow.
>
> But some more specifics on your data format will allow us to help you more.
>
> --
> George
>
> >
>
If it's an actual db dumb (aka SQL) you can just give it strait to the db.
Otherwise you'll probably need to write a script to parse it and create
objects and save them.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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: how to load data?

2009-05-22 Thread George Song

On 5/22/2009 5:07 PM, Herta wrote:
> I want to load data to database (sqlite3 ) from file. I have already
> connect django and my database, and build the tables but how can i
> load data from file?

What kind of files are these? If they are existing legacy data files, 
you'll have to write some sort of de-serializer to translate them to fit 
your model(s).

If the file happens to be one of the serialization formats that Django 
already knows how to deal with, you might be able to use Django's 
serialization somehow.

But some more specifics on your data format will allow us to help you more.

-- 
George

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



how to load data?

2009-05-22 Thread Herta

Hi, everyone,

I want to load data to database (sqlite3 ) from file. I have already
connect django and my database, and build the tables but how can i
load data from file?
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
-~--~~~~--~~--~--~---