How to edit django_openid_auth login template

2013-04-26 Thread surya
I am using https://launchpad.net/django-openid-auth for openid! this is 
pretty amazing to a lot of extent.. 

This app provides /openid/login url where users need to signin! this 
template is very basic and I want to make some changes in it.. 

Probably, I want to include this in my home page..

I can possibly create django_openid_auth/templates/login.html in my django 
project and overwrite it.. but is that the right way? how exactly it should 
be done?

Besides I also want to include "Google", "Yahoo" icons to sign in via 
respective openids. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




bitcoin payment processing

2013-04-26 Thread sebastián serrano
Hi,
  I'm building a bitcoin payment gateway and would like to know the 
interest into develop a plugin for python/django projects and if you are 
interested for which package (satchmo, django-shop, etc)
  Please fill this form only 1 field is required!
  
https://docs.google.com/forms/d/1UftZRMI4UQW3hsFWvp-WDO077oBzWBcPZxahzZCO19U/viewform

Thanks in advance, Sebastian!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




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/python3.3/site-packages/django/utils/translation/trans_real.py(155)_fetch()
154 app = import_module(appname)
2-> 155 apppath =
os.path.join(os.path.dirname(upath(app.__file__)), 'locale')

notice the app.__file__. In python 3.3 modules are not required to have a
__file__ attribute. 

So in particular, I was not able to execute
python3.3 manage.py shell because of the cryptic
*** AttributeError: 'module' object has no attribute '__file__'
which I traced to this line in the Django source.

I don't know if it appears anywhere else, but module.__file__ is no longer
robust in python 3.3.

The poor man's fix is to put the __init__.py's back in. 
src
  /apps
/index
  __init__.py
/mapping
  __init__.py

works just fine, but shouldn't be required.

This is on RHEL5.8, but I doubt that matters.

thanks,
Danny


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: check genre and insert

2013-04-26 Thread Andrew Boltachev
Hi. May be you need

if not line["IdGenre"] in genres: 

instead?


On Friday, April 26, 2013 9:04:42 PM UTC+4, Hélio Miranda wrote:
>
> I am having a problem which is as follows:
> I have to insert a csv file of movies in bd, but I can not enter the name 
> of the genre of the film directly. I have to insert the id of the genre.
>
> So I'm trying to pick the genres to a dictionary, and then verify that the 
> genre exists, if yes, get the id of that genre and enters the film, if 
> there is the genre enters the genre in the table of genres.
>
> But I am not able to give me the following error:
> KeyError at /
> 'Comedy'
>
> This line: if (genres [line ["IdGenre"]] == 0):
> What am I doing wrong?
>
> I'm trying this:
> Código (Python):
> def csv_upload(request):
> if request.method == 'POST':
>   
> genres = {}
> gen = Genre.objects.all()
>   
> for obj in gen:
> genres[obj.GenreType] = obj.id
> print genres[obj.GenreType]
>   
> file = csv.DictReader(request.FILES['file'], delimiter=','
> , quotechar='"')
>
> for line in file:
>
> report = Movie()
>   
> if (genres[line["IdGenre"]] == 0):
> print genres[line["IdGenre"]]
> rep = Genre()
>   
> rep.GenreType = line["IdGenre"]
> print rep.GenreType
>   
> else:
> report.MovieTitle = line["MovieTitle"]
> print report.MovieTitle
> #report.IdGenre = line["genres[obj.GenreType]"]
> report.MovieYear = line["MovieYear"]
> report.MovieDuration = line[
> "MovieDuration"]
> report.save()
> #file.close()
> return render_to_response('index.html', {},
>   context_instance
> =RequestContext(request))
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




check genre and insert

2013-04-26 Thread Hélio Miranda
I am having a problem which is as follows:
I have to insert a csv file of movies in bd, but I can not enter the name 
of the genre of the film directly. I have to insert the id of the genre.

So I'm trying to pick the genres to a dictionary, and then verify that the 
genre exists, if yes, get the id of that genre and enters the film, if 
there is the genre enters the genre in the table of genres.

But I am not able to give me the following error:
KeyError at /
'Comedy'

This line: if (genres [line ["IdGenre"]] == 0):
What am I doing wrong?

I'm trying this:
Código (Python):
def csv_upload(request):
if request.method == 'POST':
  
genres = {}
gen = Genre.objects.all()
  
for obj in gen:
genres[obj.GenreType] = obj.id
print genres[obj.GenreType]
  
file = csv.DictReader(request.FILES['file'], delimiter=',',
 quotechar='"')

for line in file:
   
report = Movie()
  
if (genres[line["IdGenre"]] == 0):
print genres[line["IdGenre"]]
rep = Genre()
  
rep.GenreType = line["IdGenre"]
print rep.GenreType
  
else:
report.MovieTitle = line["MovieTitle"]
print report.MovieTitle
#report.IdGenre = line["genres[obj.GenreType]"]
report.MovieYear = line["MovieYear"]
report.MovieDuration = line["MovieDuration"]
report.save()
#file.close()
return render_to_response('index.html', {},
  context_instance=
RequestContext(request))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Template Caching with Messages

2013-04-26 Thread Venkatraman S
I find testing in dev server(runserver) using a filebased cache is the
easiest and quickest way to test. One can delete the files and check if and
when new entries are created in the folder.

-V

On Fri, Apr 26, 2013 at 6:58 PM, Chris Lawlor wrote:

> V,
>
> You're exactly correct - make sure you only cache what you actually want
> cached : ) Anything that should only be visible for one page view isn't a
> good candidate for caching. If your page has any sort of content that is
> specific to the current user - login state, etc., you probably don't want
> to cache that part of the page either, if there's a chance that a user with
> a different state can hit the same template.
>
> Caching bugs can be subtle. I'd suggest writing some comprehensive
> integration tests for anything more than the most trivial caching
> strategies.
>
> Chris
>
>
> On Wednesday, 24 April 2013 04:02:15 UTC-4, Venkatraman.S. wrote:
>>
>>
>> It looks to me that when i use a file based caching, and if append
>> messages in my templates(based on user action), that particular page(with
>> message) also gets cached. Since 'these' pages would never be created
>> again, what is the best possible option? (Well, i just used file-based
>> cache to quickly see what was happening, but i guess the same happens for
>> any other cache mode too)
>>
>> One thing that i could think of is use cache-fragments for the rest of
>> the sections in the template and leave out the 'div' which displays the
>> messages.
>>
>> Any other solutions or comments?
>>
>> -V
>> @venkasub 
>>
>>   --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [django_tables2] Expected table or queryset, not 'str'.

2013-04-26 Thread Binith Babu
I am sorry I coud not find a solution in this thread

Did you mean I am using an older version of django tables2 ?
In that case I am not, I am using the latest version installed with pip.
May be its my mistake, I am still trying to figure whether I am doing 
something wrong.
WIll post back if I find something.

Thanks
binith



On Friday, 26 April 2013 06:53:06 UTC-7, Tom Evans wrote:
>
> On Fri, Apr 26, 2013 at 2:30 PM, Binith Babu  
> wrote: 
> > 
> > I got the same error today, anybody know a solution? 
> > 
>
> Apart from the solution I already posted to the list in this thread? 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Upload data in csv file to bd

2013-04-26 Thread Hélio Miranda
But when I do this:
Código (Python):
for obj in gen:
  genres [obj.GenreType] = obj.id
  print genres [obj.GenreType]

Prints the id of the genre, so it is wrong right?

Now I am not going to achieve is check if the genre that I have the csv is 
in the dictionary and if it gets the id, but inserts the genre in the table 
of genres

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




I need help doing a linked lookup in admin

2013-04-26 Thread Richard E. Cooke
I used the *django-contacts *project as my starting point for a company 
contact database.  Its really cool, it keeps "addresses", "phone numbers", 
etc in seperate db table so you can associate as many as you need to each 
company or person record.  It uses *django.contrib.contenttype*s for its 
relations.  Which is also pretty cool since that lets you attach comments 
to any other record!

Anyway, I want to build on this by adding an Inventory and Purchasing 
system.

In my Inventory model I have a field for supplier:

  supplier = models.ForeignKey('contacts.Company', blank=True, null=True)

Which works perfect, you get a pop-up list to pick the lucky vendor from.  
Later I might add a filter to limit the choices to a particular type of 
company - like vendors.  But this is fine for now.

A company record can (and will) have multiple "StreetAddresses" records 
associated with it through a GenericRelation.  For the PO I want to be able 
to select one out of that set of addresses.

So for a test, I tried:

  ship_to = models.ForeignKey('contacts.StreetAddress', 
limit_choices_to={'content_type':27, 'object_id':1, 'location':'shipto'}, 
blank=True, null=True)

"content_type", "object_id" are the content types fields used to control 
the Generic Relation.  And those values correspond to pk=1 for records of 
type "company".  And the "location" field indicates the type of address 
record.

This works.  I get a list of "ship to" addresses for the company (pk=1).

So, now I want to re-jig this to use the current PO record's setting for 
"supplier" to automatically limit the address selection.

There might be a way to capitalize on the fact that *supplier.street_address
*  is a *GenericRelatedObjectManager* seeded with the right values.  

In shell, I read in a PO record with *a = PO.objects.get(pk=1)*
Then I enter *a.supplier.street_address.filter(location="shipto")* I get a 
list of all the "shipto" addresses for the supplier!  Exactly the list I 
want to be able to pick one from.

But I haven't a clue how to make use of this in the Admin system.  Any 
ideas appreciated!

I tried making a ForeignKey field to the StreetAddress db, and filter it 
using values from the supplier record currently in memory:
  ship_to = models.ForeignKey('contacts.StreetAddress', 
limit_choices_to={'content_type':F('po__supplier__street_address__content_type__id'),
 
'object_id':F('po__supplier__pk'),}, blank=True, null=True)

In Admin, this returns an empty list of addresses.  

To debug, I went into shell, and tried:
b = 
StreetAddress.objects.filter(content_type=F('po__supplier__street_address__content_type__id'))
  

>>> b
[]

does "F()" write a log someplace that will tell me where this falls apart?  
Well, I don't see how it would know what PO record to get "supplier" from.  
Or maybe its better to say I don't understand how it determines where to 
get any of its data from when your walking relations.The Django manual 
entry for 1.4 is pretty vague on details. 

Or, is there a better way to do this?

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




Re: [django_tables2] Expected table or queryset, not 'str'.

2013-04-26 Thread Tom Evans
On Fri, Apr 26, 2013 at 2:30 PM, Binith Babu  wrote:
>
> I got the same error today, anybody know a solution?
>

Apart from the solution I already posted to the list in this thread?

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Upload data in csv file to bd

2013-04-26 Thread Tom Evans
On Fri, Apr 26, 2013 at 1:56 PM, Hélio Miranda  wrote:
> I am uploading a csv file with movies for bd.
> Ok, I'm getting it, but my problem is that the movie has genre, but I can
> not insert the genre, I have to insert the id of the genre, so I'm going to
> fetch the genres to put a dictionary, GenreType = id.
>
> When I want to see the insert there the genre, if so takes on the genre id
> and inserts, except inserts the genre in the table of genres.
>
> I'm trying this:
> Código (Python):
> def csv_upload(request):
> if request.method == 'POST':
>
>
> genres = {}
> gen = Genre.objects.all()
>
> for obj in gen:
> print genres[obj.GenreType]

genres is still at this point an empty dictionary, so looking up
anything in it will fail. You seem to have missed a step in
constructing your lookup dictionary, try something like this:

genres = dict(Genre.objects.all().values_list('GenreType', 'id'))

PS: When asking for help on here, and you have an exception with some
code, the traceback that follows the exception provides exact log of
how and where the exception was raised. In this case, it would have
pointed out precisely which line the KeyError occurred. In this case,
it was obvious what was wrong, in other cases it may not be so
obvious, so in future please do include the full traceback to assist
the people you are asking to help you.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [django_tables2] Expected table or queryset, not 'str'.

2013-04-26 Thread Binith Babu
I got the same error today, anybody know a solution?

On Tuesday, 9 April 2013 12:06:57 UTC-7, Tomas Pelka wrote:
>
> ValueError at /plyn
>
> Expected table or queryset, not 'str'.
>
> Request Method:GETRequest URL:http://127.0.0.1:8000/plynDjango 
> Version:1.5Exception 
> Type:ValueErrorException Value:
>
> Expected table or queryset, not 'str'.
>
> Exception 
> Location:/usr/lib/python2.7/site-packages/django_tables2-0.13.0-py2.7.egg/django_tables2/templatetags/django_tables2.py
>  
> in render, line 176Python Executable:/usr/bin/pythonPython 
> Version:2.7.3Python 
> Path:
>
> ['/home/tpelka/workspace/energie/wsgi/energie',
>  '/usr/lib/python2.7/site-packages/ropevim-0.4-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/ropemode-0.2-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/rope-0.9.4-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/mozmill-1.5.20-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/ManifestDestiny-0.2.2-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/mozrunner-2.5.14-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/jsbridge-2.4.16-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/virtualenv-1.9.1-py2.7.egg',
>  '/usr/lib/python2.7/site-packages/django_tables2-0.13.0-py2.7.egg',
>  '/usr/share/qa-tools/python-modules',
>  '/usr/lib64/python27.zip',
>  '/usr/lib64/python2.7',
>  '/usr/lib64/python2.7/plat-linux2',
>  '/usr/lib64/python2.7/lib-tk',
>  '/usr/lib64/python2.7/lib-old',
>  '/usr/lib64/python2.7/lib-dynload',
>  '/usr/lib64/python2.7/site-packages',
>  '/usr/lib64/python2.7/site-packages/gst-0.10',
>  '/usr/lib64/python2.7/site-packages/gtk-2.0',
>  '/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode',
>  '/usr/lib/python2.7/site-packages',
>  '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
>
> Server time:út, 9 Dub 2013 20:55:56 +0200
>
>
> Any clue why this error happen. Sources attached.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Template Caching with Messages

2013-04-26 Thread Chris Lawlor
V,

You're exactly correct - make sure you only cache what you actually want 
cached : ) Anything that should only be visible for one page view isn't a 
good candidate for caching. If your page has any sort of content that is 
specific to the current user - login state, etc., you probably don't want 
to cache that part of the page either, if there's a chance that a user with 
a different state can hit the same template.

Caching bugs can be subtle. I'd suggest writing some comprehensive 
integration tests for anything more than the most trivial caching 
strategies.

Chris


On Wednesday, 24 April 2013 04:02:15 UTC-4, Venkatraman.S. wrote:
>
>
> It looks to me that when i use a file based caching, and if append 
> messages in my templates(based on user action), that particular page(with 
> message) also gets cached. Since 'these' pages would never be created 
> again, what is the best possible option? (Well, i just used file-based 
> cache to quickly see what was happening, but i guess the same happens for 
> any other cache mode too)
>
> One thing that i could think of is use cache-fragments for the rest of the 
> sections in the template and leave out the 'div' which displays the 
> messages.
>
> Any other solutions or comments?
>
> -V
> @venkasub 
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django development server timeout too quick

2013-04-26 Thread Chris Lawlor
Hadi,

What is your SESSION_COOKIE_AGE set to? This setting controls session 
expiry. The default is 2 weeks. If you are not setting SESSION_COOKIE_AGE, 
check that your code is not calling request.session.set_expiry() anywhere.

For light use, the default session backend (db) should meet your needs. 
Have a look at the warning 
here: 
https://docs.djangoproject.com/en/dev/topics/http/sessions/#using-cached-sessions
 
(Note link to dev version of docs). Using the cached_db session engine with 
a file based cache isn't buying you anything but extra complexity.

On Wednesday, 24 April 2013 02:27:20 UTC-4, Hadi Sunyoto wrote:
>
> The problem is like this:
>
> i am using django admin, and in several forms, it might take around 10-20 
> minutes to fill up.
> By the time save button is pressed, i am always redirected to login page.
>
> The question is: how can i make the timeout longer (or maybe last forever)
>
> I set the cache to file and session_engine to db
>
> CACHES = {
> 'default': {
> 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
> 'LOCATION': 'some/path',
> 'TIMEOUT': 10,
> }
> }
> SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
>
> What else am i missing here? any direction will be much appreciated
>
> i also have tried to set --noreload in runserver so that file changed does 
> not get reloaded, but i still get the same problem.
>
> i don't plan on using apache/ngix/etc because this is only for my personal 
> use
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Calling Jquery or javascript function based on an if condition

2013-04-26 Thread Chris Lawlor
A slight variation of this approach is to map some Django template context 
info to Javascript variables in one of your templates, making that data 
accessible to your compressed / minified JS code:

# in a template, "base.html" perhaps..


window.DjangoContext = {
  userLoggedIn: {{ user.is_authenticated|yesno:"true,false" }}
}


Note the use of the 'yesno' filter to convert "True" to "true" to match JS 
syntax.

Now you can access DjangoContext.userLoggedIn anywhere in your JS.


** It's important to note that users can modify any JS variable they wish, 
so don't rely on something like this for security **

On Tuesday, 23 April 2013 16:45:20 UTC-4, Сергей Костюченко wrote:
>
>  {% if condition %}
>
> 
>
> some_function(params);
>
> 
>
> {% endif %}
>
> Sarfraz ahmad wrote at 23 апреля 2013 13:30:38:
>
> Guys, is it possible to call a javascript function in django templates 
> based on an if condition...?? What i want to do is that in 
> django templates if a given if condition is true i want to call a 
> javascript function automatically
>
> tell me guys if it is possible or not
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Upload data in csv file to bd

2013-04-26 Thread Hélio Miranda
I am uploading a csv file with movies for bd.
Ok, I'm getting it, but my problem is that the movie has genre, but I can 
not insert the genre, I have to insert the id of the genre, so I'm going to 
fetch the genres to put a dictionary, GenreType = id.

When I want to see the insert there the genre, if so takes on the genre id 
and inserts, except inserts the genre in the table of genres.

I'm trying this:
Código (Python):
def csv_upload(request):
if request.method == 'POST':

  
genres = {}
gen = Genre.objects.all()
  
for obj in gen:
print genres[obj.GenreType]
  
file = csv.DictReader(request.FILES['file'], delimiter=',',
 quotechar='"')
#data = csv.DictReader(request.FILES['file'])
for line in file:
report = Movie()
  
if (genres[line["IdGenre"]] == 0):
print genres[line["IdGenre"]]
rep = Genre()
  
rep.GenreType = line["IdGenre"]
print rep.GenreType
  
else:
report.MovieTitle = line["MovieTitle"]
print report.MovieTitle
#report.IdGenre = line["genres[obj.GenreType]"]
report.MovieYear = line["MovieYear"]
report.MovieDuration = line["MovieDuration"]
report.save()

But it gives the following error: 
KeyError at / 

'Comedia'


Comedia is the genre again.
Does anyone know what I'm doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How can I completely remove Django and reinstall it - I've broken something

2013-04-26 Thread ashwoods
run pip uninstall 
several times just in case :)

then reinstall django.

take a look at virtualenv. lets you make isolated python environments. 
makes life a lot easier: 
https://jamiecurle.co.uk/blog/installing-pip-virtualenv-and-virtualenvwrapper-on-os-x/


On Friday, April 26, 2013 2:00:28 AM UTC+2, Garry Pettet wrote:
>
> I'm a complete newcomer to Python and the Django framework so please be 
> gentle.
>
> I'm on a Mac 10.8 and MAMP. I was following the tutorial and installed the 
> latest stable version (1.5) of Django using pip thanks to the instructions 
> on this 
> page.
>  
> For some reason, I decided immediately after this to install instead the 
> development version (1.6dev) by cloning the git repository using these 
> instructions.
>  
> At this point, everything was OK and running the following code:
>
> >>> import django
> >>> print(django.get_version())
>
>
> printed out version 1.6dev-blahblahblah.
>
> I then tried to create my first project with this command:
>
> django-admin.py startproject mysite
>
>
> It worked. Here's where I did something stupid. I changed my mind at this 
> point and thought it might be better to stick with the stable development 
> version rather than the bleeding edge version and so I tried to remove the 
> development version. All I did was delete the django folder found after 
> typing this command:
>
> python -c "import sys; sys.path = sys.path[1:]; import django; 
> print(django.__path__)"
>
>
> I then reran pip and it said everything was installed correctly. When I 
> get the version number from the Python interpreter I get this output:
>
> >>> import django
> >>> print(django.get_version())
> 1.5.1
>
>
> However, when I try to create a new project I get the following error:
>
> django-admin.py startproject mysite
> Traceback (most recent call last):
>   File "/usr/local/bin/django-admin.py", line 4, in 
> from pkg_resources import require; 
> require('Django==1.6.dev20130425172216')
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py",
>  
> line 2607, in 
> parse_requirements(__requires__), Environment()
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py",
>  
> line 565, in resolve
> raise DistributionNotFound(req)  # XXX put more info here
> pkg_resources.DistributionNotFound: Django==1.6.dev20130425172216
> Garrys-MacBook-Air-2:~ Garry$ 
>
> Sorry for being stupid but how can I fix this??
>
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.