Re: Blog writen by django?

2013-04-27 Thread Shawn Milochik
Do a Google search. There are thousands.

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




Blog writen by django?

2013-04-27 Thread 宣铭艺
Is there any blog system writen by django like wordpress writen by php
except mezzanine?

-- 
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: ManyToMany relationship and raw sql queries

2013-04-27 Thread Marc R
did you use Bookmark.objetcs.all().select_related() ?

As this will create a join query... at least for your model you show in the 
message I have found that for very complex joins, you need to use raw 
query and not a Model.

On Thursday, April 25, 2013 10:44:28 AM UTC-4, Matthieu Bouron wrote:
>
> On Thursday, April 11, 2013 5:39:57 PM UTC+2, Tom Evans wrote:
>>
>> On Thu, Apr 11, 2013 at 3:42 PM, Matthieu Bouron 
>>  wrote: 
>> > Hello, 
>> > 
>> > Is there a way to handle many-to-many relationship with raw sql queries 
>> ? 
>> > I have the following model: 
>> > 
>> > from django.db import models 
>> > 
>> > class Tag(models.Model): 
>> > name = models.CharField(max_length=512, unique=True) 
>> > 
>> > class Bookmark(models.Model): 
>> > link = models.CharField(max_length=512) 
>> > title = models.CharField(max_length=512) 
>> > tags = models.ManyToManyField(Tag) 
>> > added_at = models.DateField() 
>> > 
>> > Using Bookmark.objetcs.all() will result in a subquery for each row of 
>> the 
>> > bookmark table which is not acceptable for performance reasons. 
>> > First question is there a way to fetch all the content with a single 
>> query ? 
>> > Second question is it possible to use raw sql queries. I tried the 
>> > following: 
>> > 
>> > bookmarks = Bookmark.objects.raw( 
>> > 'SELECT * FROM bookmarkmanager_bookmark b ' 
>> > 'LEFT JOIN bookmarkmanager_bookmark_tags bt ON (
>> b.id = 
>> > bt.bookmark_id) ' 
>> > 'LEFT JOIN bookmarkmanager_tag t ON (bt.tag_id = 
>> t.id)' 
>> > ) 
>> > 
>> > But when i tried to access the tags attribute on a bookmark i get the 
>> > following exception: 
>> > 
>> > ValueError: "" needs to have a value for 
>> field 
>> > "bookmark" before this many-to-many relationship can be used. 
>> > 
>> > Thanks in advance, 
>> > Matthieu 
>> > 
>>
>> Are you tied to raw SQL queries? Django itself supports traversing M2M 
>> relationships in a sane manner if you tell it to do so: 
>>
>>
>> https://docs.djangoproject.com/en/1.5/ref/models/querysets/#prefetch-related 
>>
>
> Thanks.
> Another problem remains ... performances are horrible even if i use 
> values().
> I have 1000 rows in base, executing from a script (db sqlite):
>   - 800ms to fetch all the objects (traversing m2m with prefetch_related).
>   - 200ms to fetch all the row from bookmark table without traversing the 
> m2m relationship).
>
> Are my results expected ?
> Are there any plan on improving django orm performance ?
>
> Matthieu
>

-- 
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-27 Thread Felipe Coelho
2013/4/27 Hélio Miranda 

> Made the proposed change, but what happens is that when will insert the
> movie with a genre that already exists to get the id of that genre, gives
> the following error: ObjectId ('517b15658774a7177cb1280d ') as the id that
> comes from this comes mongodb form.
>
> When the genre does not exist and must enter the new genus, is not to
> enter.
>
> Does anyone know what I'm doing wrong?
>  (snip)
>

I don't know what your issue really is, but here's a quick debugging tip:
add the following lines somewhere in your view:

import code
code.interact(local=locals())

A Python interpreter will open in the same terminal where you're running
the development server and you'll be able to do anything you want, inspect
variables, query the database, you name it. Quit the interpreter (CTRL+D,
don't use exit()) and the view will finish processing normally. It should
help you finding where your assumptions are failing

-- 
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 Admin - BooleanField issue

2013-04-27 Thread Marc R
That seems to have worked... I used 1 and 0 as the database is set for a 
tinyint to store the value (so needs to be 1 or 0).  That said, 
django/python seems to figure that out when saving the value.

Thanks; wouldn't have thought to try that.

On Saturday, 27 April 2013 14:46:14 UTC-4, Andrew Boltachev wrote:
>
> Hi. May be you need
>
> active = models.BooleanField(choices=((True,'yes'),(False,'no')))
>
> ?
>
> - With regards, Andrei
>
>
> 2013/4/27 Marc R 
>
>> I've setup a boolean field and get it to display correctly using this in 
>> my model:
>> active = models.BooleanField(choices=((1,'yes'),(0,'no')))
>>
>> However, when I edit a record in the Django Admin, the select field 
>> always shows "yes" regardless of the database value.
>>
>> Saving "yes" or "no" stores the correct 1 or 0; is there a bug in the 
>> edit form?  Or did I miss a setting?
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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 Admin - BooleanField issue

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

active = models.BooleanField(choices=((True,'yes'),(False,'no')))

?

- With regards, Andrei


2013/4/27 Marc R 

> I've setup a boolean field and get it to display correctly using this in
> my model:
> active = models.BooleanField(choices=((1,'yes'),(0,'no')))
>
> However, when I edit a record in the Django Admin, the select field always
> shows "yes" regardless of the database value.
>
> Saving "yes" or "no" stores the correct 1 or 0; is there a bug in the edit
> form?  Or did I miss a setting?
>
> 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.
>
>
>

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




Django Admin - BooleanField issue

2013-04-27 Thread Marc R
I've setup a boolean field and get it to display correctly using this in my 
model:
active = models.BooleanField(choices=((1,'yes'),(0,'no')))

However, when I edit a record in the Django Admin, the select field always 
shows "yes" regardless of the database value.

Saving "yes" or "no" stores the correct 1 or 0; is there a bug in the edit 
form?  Or did I miss a setting?

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.




django social auth with custom user model is not working

2013-04-27 Thread sri
i am trying to implement django social auth in my project and i am having 
trouble integrating it with my custom user model. Whenever i try to login 
to facebook, it is throwing an error and always re-directing to 
LOGIN_ERROR_URL Page.

My settings.py file looks like below.
 
FACEBOOK_APP_ID  = 'x'
FACEBOOK_API_SECRET  = 'x'
AUTHENTICATION_BACKENDS = (
   'social_auth.backends.facebook.FacebookBackend',
   'django.contrib.auth.backends.ModelBackend',
)

SOCIAL_AUTH_PIPELINE = (
  'social_auth.backends.pipeline.social.social_auth_user',
  'social_auth.backends.pipeline.associate.associate_by_email',
  'social_auth.backends.pipeline.misc.save_status_to_session',
  'social_auth.backends.pipeline.user.create_user',
  'social_auth.backends.pipeline.social.associate_user',
  'social_auth.backends.pipeline.social.load_extra_data',
  'social_auth.backends.pipeline.user.update_user_details',
  'social_auth.backends.pipeline.misc.save_status_to_session',
)

LOGIN_URL = '/user/login_register/'
LOGIN_ERROR_URL = '/user/login_register/'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'

SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'
SOCIAL_AUTH_RAISE_EXCEPTIONS = False
SOCIAL_AUTH_FORCE_POST_DISCONNECT = True
SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL = True

SOCIAL_AUTH_USER_MODEL = 'myapp.MyUser'
FACEBOOK_EXTENDED_PERMISSIONS = ['email']

AUTH_USER_MODEL = 'myapp.MyUser'


And my custom user model is defined as below (just uses e-mail and doesn't 
use firstname, lastname or username)

class MyUserManager(BaseUserManager):
   def create_user(self, email, password=None):
  """
  Creates and saves a User with the given email and password.
  """
  if not email:
 raise ValueError('Users must have an email address')

  user = self.model(
  email=MyUserManager.normalize_email(email),
  )

  user.set_password(password)
  user.save(using=self._db)
  return user


class MyUser(AbstractBaseUser):

email = models.EmailField(
verbose_name='Email address',
max_length=255,
unique=True,
db_index=True,
)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)

objects = MyUserManager()

USERNAME_FIELD = 'email'


Now when i try to login to my webapp using facebook login, it takes me to 
the facebook login credentials page and when i enter the login details, it 
throws me back to the LOGIN_ERROR_URL page. After i enter the facebook 
login details, it is not creating a new user in my app.

Can anyone help with what i am missing?


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.




Terminator plugin

2013-04-27 Thread Guido Castillo Gómez
I want to share this plugin
https://bitbucket.org/pytel/terminator-applauncher, I use
Terminator,
and every time I wanted to set up my development environment, I had to
launch Terminator and execute the commands needed. In order to avoid this
repetitive sequence, I decided to write a plugin that, with just one click,
launches Terminator, creates divisions in it, and executes the commands
needed for every project.

-- 
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: handling IntegrityError: Duplicate entry in UserCreationForm

2013-04-27 Thread isachin
@ Kelly: thank you very much for pointing me to django's source code.

Yes I got that validation done and applied the same code for validation.
Below is the snippet :

   profile.serial_num = self.cleaned_data['phone_num']
try:
profile._default_manager.get(phone_num=profile.serial_num)
except UserProfile.DoesNotExist:
profile.serial_num = profile.phone_num
raise forms.ValidationError("Phone number already exist")

@ all

Now the next problem is, similar snippet appears in

*/site-packages/django/contrib/auth/forms.py*

throws an error in the template form itself, but my code only shows up
error in django's traceback, how can I bring it to front ?
so that as soon as one fills phone number field it and press *submit, *it
should say 'Phone number already exist'.

m I doing wrong in using UserCreationForm ? or UserProfile. I m using
user.get_profile() for profile fields.



On Thu, Apr 25, 2013 at 7:09 PM, Kelly Nicholes wrote:

> If you ever want to know how the UserCreationForm works, the source is
> always available not only on your machine but also on
> https://github.com/django/django/blob/master/django/contrib/auth/models.py
>
>
> On Wednesday, April 24, 2013 9:27:39 AM UTC-6, sachin wrote:
>>
>> Hello,
>>
>> I m extending my auth user model to add addition entries like phone
>> numbers and emp_id. In the model I m marking both the fields as unique=True.
>> Form generation is using UserCreationForm. But whenever I try to save
>> same phone number or emp_id it throws
>>
>> *IntegrityError: (1062, "Duplicate entry '447' for key 'phone_num'")*
>>
>> How to handle this error and show it to user during form input?
>>
>> Also how do the same UserCreationForm validates duplicate entry for
>> username etc ??
>>
>>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/EaYF9DEptLo/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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.
>
>
>



-- 
Sachin

-- 
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-27 Thread Hélio Miranda
Made the proposed change, but what happens is that when will insert the 
movie with a genre that already exists to get the id of that genre, gives 
the following error: ObjectId ('517b15658774a7177cb1280d ') as the id that 
comes from this comes mongodb form.

When the genre does not exist and must enter the new genus, is not to enter.

Does anyone know what I'm doing wrong?
The code is here:
Código (Python):
def csv_upload(request):
if request.method == 'POST':
gen = Genre.objects.all()
genres = dict(Genre.objects.all().values_list('GenreType', 'id'
))
print genres
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 not line["IdGenre"] in genres:
print 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()
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: How to edit django_openid_auth login template

2013-04-27 Thread Babatunde Akinyanmi
The right way is to open django_openid_auth source and copy the contents of
its templates folder into your own templates directory and then edit from
your templates directory.

I wrote about this recently:
http://tundebabzy.blogspot.com/2013/04/overriding-templates-from-django-apps.html

Sent from my Windows Phone
--
From: surya
Sent: 4/27/2013 6:11 AM
To: django-users@googlegroups.com
Subject: How to edit django_openid_auth login template

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.

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