Re: Issues saving a formset form with multiple forms.

2013-11-08 Thread Jason S
Hi Paul,
After a bit more playing around I got it going, there was another unrelated 
issue with my code.
Learnt to use the debugging info more effectively in the process which is 
great.

Thanks again for your help, very much appreciated.
Kind regards,
Jason

On Thursday, 7 November 2013 04:56:14 UTC-10, pnich...@gmail.com wrote:
>
> Hey Jason--
>
> You defined the save method as needing the user parameter, but you don't 
> pass that in.  Try that (assuming user should equal request.user).  Good 
> luck!
>
> -Paul
>
> On Thursday, November 7, 2013 5:25:18 AM UTC-5, Jason S wrote:
>>
>> Hi, 
>> Disclaimer - I'm new to django and python, so please bear with me.
>>
>> Note: My django instance uses a nosql database.
>>
>> I'm trying to create a formset which has multiple forms based on models.
>> The formset will have one form "post", then 1-3 "comment" forms. 
>> Eventually i'd like to be able to add/remove the comment fields but i'll 
>> work that out later once the form saves with manually set number of comment 
>> fields. 
>> For now the formset just has the two forms "post" and "comment" to make 
>> it easy, but if i can save one it should work for more.
>> The form displays as expected but I get "save() takes at least 2 
>> arguments (1 given)".
>>
>> I think thats because i'm supplying the "post" data, but not the object 
>> itself? I've tried referencing it but without success.
>> I may need to set the form up as a class with methods and then use 
>> something like the following which is how another tut does it, but my first 
>> attempt to do it this way failed.
>>  21 def post(self, request, *args, **kwargs):
>>  22 self.object = self.get_object()
>>  23 form = CommentForm(object=self.object, data=request.POST)
>>  24
>>  25 if form.is_valid():
>>  26 form.save()
>>  27 return 
>> HttpResponseRedirect(self.object.get_absolute_url())
>>
>>
>> *Models:*
>>   7 class Object_Post(models.Model):
>>   8 # Defines the post model
>>   9 def __unicode__(self):
>>  10 return self.name
>>  11
>>  12 name = models.CharField(max_length=70)
>>  13 desc = models.TextField()
>>  14 Comments = ListField(EmbeddedModelField('Comment), editable=False)
>>  15
>>  16
>>  17 class Comment(models.Model):
>>  18 # Comments.
>>  19 def __unicode__(self):
>>  20return self.name
>>  21
>>  22 name = models.CharField(max_length=70)
>>  23 desc = models.TextField()
>>
>> *Forms:*
>>  39 class PostForm(forms.ModelForm):
>>  40 class Meta:
>>  41 model = Object_Post
>>  42
>>  43 def save(self, user, commit = True):
>>  44 Object_Post = super(PostForm, self).save(commit = False)
>>  45 Object_Post.user = user
>>  46
>>  47 if commit:
>>  48 Object_Post.save()
>>  49
>>  50 return Object_Post
>>  51
>>  52 class CommentForm(forms.ModelForm):
>>  53 class Meta:
>>  54 model = Comment
>>  55
>>  56 def save(self, user, commit = True):
>>  57 Comment = super(CommentForm, self).save(commit = False)
>>  58 Comment.user = user
>>  59
>>  60 if commit:
>>  61 Comment.save()
>>  62
>>  63 return Comment
>>
>> *View:*
>>  65 def create_post(request):
>>  66 
>>  67 #   
>>  68 #   Manually set number of comment fields for now
>>  69 commentfields = 1
>>  70
>>  71 if request.method == "POST":
>>  72 pform = PostForm(request.POST, instance=Object_Post())
>>  73 #
>>  74 cforms = [CommentForm(request.POST, prefix=str(x), 
>> instance=Comment()) for x in range(0,Commentfields)]
>>  75 if pform.is_valid() and all([cf.is_valid() for cf in cforms]):
>>  76 #
>>  77 new_post = pform.save()
>>  78 for cf in cforms:
>>  79 new_Comment = cf.save(commit=False)
>>  80 new_Comment.Object_Post = new_post
>>  81 new_Comment.save()
>>  82 return 
>> HttpResponseRedirect(reverse('blogtut.views.dashboard'))
>>  83 else:
>>  84 pform = PostForm(instance=Object_Post())
>>  85 cforms = [CommentForm(prefix=str(x), instance=Comment()) for 
>> x in range(0,Commentfields)]
>>  86 return render_to_response('create_object.html', {'Post_Form': 
>> pform, 'Comment_Form': cforms},
>>  87 context_instance=RequestContext(request)
>>  88 )
>>
>> *Template:*
>>   1 {% extends "base.html" %}
>>   2
>>   3 {% block content %}
>>   4 
>>   5
>> # Irrelevent to the form.
>>  11
>>  12 
>>  13
>>  14 > accept-ch>
>>  15 {% csrf_token %}
>>  16 {{ form.as_p }}
>>  17
>>  18 Enter a name and description for the post: 
>>  19 {{ Post_Form }} 
>>  20 Enter one or more Comments:
>>  21 {% for mform in Comment_Form %}
>>  22 Comment: {{ cform }}
>>  23 {% endfor %}
>>  24 
>>  25 
>>  26 
>>  27
>>  28 {% endblock %}
>> ~
>>
>> I'd really appreci

Re: Invitations Apps

2013-11-08 Thread Amirouche Boubekki
2013/11/8 Avraham Serour 

> You could create a invitation model, I don't see the problem
> but maybe you don't even need to, if all you want is for a user to ask the
> server to send some emails you can just do that: let the user ask the
> server to send emails.
>

Invitation are probably limited.



>
> On Thu, Nov 7, 2013 at 11:43 PM, Rafael E. Ferrero <
> rafael.ferr...@gmail.com> wrote:
>
>> Im doing a project where visitors can registers with his social accounts
>> (this it can be done with AllAuth in a very simple way)
>> When a visitor get registered the system he can create a group. (this is
>> not a problem too)
>> But... a registered visitor can invitate, by email, to other people to
>> join in his group. The idea is that these guest can login with his own
>> social accounts too, So here's the problem, AllAuth make it easy to login
>> with social accounts but does not manage invitations.
>>  I do not want to reinvent the wheel but if nobody did this before I'm
>> afraid that i have to put my hands in the dough.
>>
>> Cheers !
>>
>>
>> 2013/11/7 Amirouche Boubekki 
>>
>>> Héllo Rafael,
>>>
>>>
>>> I don't know those particular applications, so I can't help. Do you have
>>> a specific problem?
>>>
>>>
>>> 2013/11/7 Rafael E. Ferrero 
>>>
 No body can help me?


 2013/11/7 Rafael E. Ferrero 


> Has someone used some invitation app for django like django-invitation
> [1]... and more, has someone integrated something like that with AllAuth
> [2] ??
>
> In a project I need visitors to register on the site with their social
> accounts. Once registered the system will create a group which will
> own. Then the owner of the group may invite people to integrate this
> group. Those who respond to the invitation may log in with their social
> accounts too. Guests can not create groups, because they are guests.
>
> Someon has some tips for me?
>
> Thanks a lot!
>
>
> [1] https://bitbucket.org/david/django-invitation/wiki/Home
>

>>>
>>>
>>>
  [2] https://github.com/pennersr/django-allauth
>

>>> I don't know this application, I know about:
>>>
>>> - python-social-auth
>>> - http://peterhudec.github.io/authomatic/ something like that
>>>
>>> Both are nice and probably work but I couldn't use because I did not use
>>> django for this specific project and they did not integrate well.
>>>
>>>
>>> Hope this helps,
>>>
>>>
>>>
>>> Amirouche
>>> --
>>> 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/CAL7_Mo9nHfUbR-OrvOjLALUZmeqqSKePbhzYuZXzOcxUaFC%3DJg%40mail.gmail.com
>>> .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Rafael E. Ferrero
>>  --
>> 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/CAJJc_8XfAHskv35fZw%3D-GMT16%2Bvp%3DcU0W9BCokOm_Y158N0pHA%40mail.gmail.com
>> .
>>
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFWa6tKeyH5SbfN9zMZUv2b4QsfsCSNubmZpu-3azozr-u-fmQ%40mail.gmail.com
> .
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL7_Mo_2wzF9XWmJpwfYO%2ByX7h%2BAb%2BfmPW0Q1ZMH9mJN-4tVhw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Complex query reduction

2013-11-08 Thread François Schiettecatte
I am pretty sure the IN() performance issue in MySQL was fixed 5.5, and  
5.6/5.7 certainly don't have an issue with IN() whether you use a bunch of 
values or a subquery.

Cheers

François

On Nov 8, 2013, at 2:15 AM, akaariai  wrote:

> On Friday, November 8, 2013 8:44:09 AM UTC+2, Robin St.Clair wrote:
> Anssi
> 
> The last time I checked the use of IN, all the records from the database in 
> the query were brought back to the workstation, rather than being processed 
> on the backend and only the results returned to the workstation.
> 
> Have there been changes that carry out the entire query on the backend? What 
> has changed to cause you to prefer the use of the IN statement?
> 
> Django has had the ability to execute __in=qs in single query for a somewhat 
> long time (from Django 1.2 maybe?).
> 
> It is true that __in lookup against a large list of values is often a bad 
> choice even if you have the values at hand. Unfortunately this doesn't apply 
> to all databases, for example older versions of MySQL do not handle 
> subqueries well.
> 
>  - Anssi
> 
> -- 
> 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/f3428fda-e4be-4d75-8626-a95bd20f66c8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Django 1.6 transactions witn multiple databases

2013-11-08 Thread Vaal
Thx!
How have I missed this ...
пятница, 8 ноября 2013 г., 9:47:22 UTC+4 пользователь akaariai написал:
>
> On Thursday, November 7, 2013 3:36:17 PM UTC+2, Vaal wrote:
>>
>> Hi
>> How to be in 1.6 with queries that involve multiple databases?
>> Previously recommended to create custom TransactionMiddleware. It was 
>> convenient. Now TransactionMiddleware is deprecated.
>>
>
> You can set ATOMIC_REQUESTS per database.
>

-- 
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/ae42b5ac-7c81-4fe5-94a9-68b26b2ea27c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django debugger

2013-11-08 Thread DJ-Tom
Hi,

Pycharm ist very good, I'm using it on a daily basis with Django, debugging 
included.

Google for debugging django pycharm and you will find loads of hints how to 
set this up.

You may also want to look at this review, as it covers a lot of the 
features that Pycharm has:

http://andrewbrookins.com/tech/one-year-later-an-epic-review-of-pycharm-2-7-from-a-vim-users-perspective/

Thomas

Am Dienstag, 5. November 2013 19:29:28 UTC+1 schrieb Harjot Mann:
>
> I want to know that how can we debug django applications? 
> I got pdb but I think in this some commands are need to use and then I 
> come to know about pycharm. 
> Is it good? 
> I successfully installed it but dont' know how to use it? 
> Anyone please help me.. 
>
>

-- 
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/36e4bf1c-3243-4cfc-8fa4-d841f0aa3bd5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with (unwanted) field validation

2013-11-08 Thread DJ-Tom
I still didn't get this to work... isn't there anybody that is able to help?

Am Mittwoch, 30. Oktober 2013 10:47:34 UTC+1 schrieb DJ-Tom:
>
> Hi,
>
> given the following model field:
>
> room_setup = models.ForeignKey("roomsetup", verbose_name='Default room 
> setup', blank=True, null=True, default='')
>
> In the modelform __init__ method I'm setting the choices for this field 
> like this:
>
> self.fields['room_setup'].choices = roomsetups_as_choices(subevt)
>
> def roomsetups_as_choices(subevt):
> rs = [['', '-']]
> for setup in roomsetup.objects.filter(Q(subevent__isnull=True) | 
> Q(subevent=subevt)):
> rs.append([setup.id, setup.name])
>
> return rs
>
> When adding a new record I keep getting the following validation message, 
> but only for the first try to submit of the form:
>
> "Select a valid choice. That choice is not one of the available choices."
>
> It passes without error on the second try... I really don't understand why?
>
> IMHO it should not complain at all...
>
> Any ideas?
>
> Thomas
>

-- 
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/d6ff282b-aafa-411a-a5f6-00f6b6687e7a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with (unwanted) field validation

2013-11-08 Thread Sergiy Khohlov
answer is  simple .  Validator would like to check field which is
used for Key.  Look like this field is not set   before validation.
 I would like take a look at model  form  and part of code before form.is_valid
Many thanks,

Serge


+380 636150445
skype: skhohlov


On Fri, Nov 8, 2013 at 2:29 PM, DJ-Tom  wrote:
> I still didn't get this to work... isn't there anybody that is able to help?
>
> Am Mittwoch, 30. Oktober 2013 10:47:34 UTC+1 schrieb DJ-Tom:
>>
>> Hi,
>>
>> given the following model field:
>>
>> room_setup = models.ForeignKey("roomsetup", verbose_name='Default room
>> setup', blank=True, null=True, default='')
>>
>> In the modelform __init__ method I'm setting the choices for this field
>> like this:
>>
>> self.fields['room_setup'].choices = roomsetups_as_choices(subevt)
>>
>> def roomsetups_as_choices(subevt):
>> rs = [['', '-']]
>> for setup in roomsetup.objects.filter(Q(subevent__isnull=True) |
>> Q(subevent=subevt)):
>> rs.append([setup.id, setup.name])
>>
>> return rs
>>
>> When adding a new record I keep getting the following validation message,
>> but only for the first try to submit of the form:
>>
>> "Select a valid choice. That choice is not one of the available choices."
>>
>> It passes without error on the second try... I really don't understand
>> why?
>>
>> IMHO it should not complain at all...
>>
>> Any ideas?
>>
>> Thomas
>
> --
> 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/d6ff282b-aafa-411a-a5f6-00f6b6687e7a%40googlegroups.com.
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJPyZgR24v3PpKbux9CbOX6aD5Z5zkoxWp-kcgzDA4HBxw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: 1.5 user abstract question

2013-11-08 Thread Andreas Schosser
Hi Frocco

> I need a couple of extra fields in my user model 

You can connect a model in your app to the user model and add your
fields there.

Example myapp/models.py:
...
from django.contrib.auth.models import User
...
class Profile(models.Model):
user = models.OneToOneField(User, related_name='profile')
...

You can then access your data via "user.profile" in your views.

Hope that helps,
Andreas

-- 
Kurs 10 / IT-Consulting
Andreas Schosser  a...@kurs-10.de

St.-Cajetan-Str. 13  Telefon +49 89 41615842-0
81669 MünchenTelefax +49 89 41615842-3

0x6EDECCF1 - 2AA0 939B 5585 819B FCE8 E43B 0B8E 0DF2 6EDE CCF1

-- 
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/527CC3FD.6000602%40kurs-10.de.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Invitations Apps

2013-11-08 Thread Rafael E. Ferrero
Avraham Serour Sending the email its not my problem.
I start to think doing by my self an invitation app for what i need... so
thank you all you guys!!

See ya.



2013/11/8 Amirouche Boubekki 

>
>
>
> 2013/11/8 Avraham Serour 
>
>> You could create a invitation model, I don't see the problem
>> but maybe you don't even need to, if all you want is for a user to ask
>> the server to send some emails you can just do that: let the user ask the
>> server to send emails.
>>
>
> Invitation are probably limited.
>
>
>
>>
>> On Thu, Nov 7, 2013 at 11:43 PM, Rafael E. Ferrero <
>> rafael.ferr...@gmail.com> wrote:
>>
>>> Im doing a project where visitors can registers with his social accounts
>>> (this it can be done with AllAuth in a very simple way)
>>> When a visitor get registered the system he can create a group. (this
>>> is not a problem too)
>>> But... a registered visitor can invitate, by email, to other people to
>>> join in his group. The idea is that these guest can login with his own
>>> social accounts too, So here's the problem, AllAuth make it easy to login
>>> with social accounts but does not manage invitations.
>>>  I do not want to reinvent the wheel but if nobody did this before I'm
>>> afraid that i have to put my hands in the dough.
>>>
>>> Cheers !
>>>
>>>
>>> 2013/11/7 Amirouche Boubekki 
>>>
 Héllo Rafael,


 I don't know those particular applications, so I can't help. Do you
 have a specific problem?


 2013/11/7 Rafael E. Ferrero 

> No body can help me?
>
>
> 2013/11/7 Rafael E. Ferrero 
>
>
>> Has someone used some invitation app for django like
>> django-invitation [1]... and more, has someone integrated something like
>> that with AllAuth [2] ??
>>
>> In a project I need visitors to register on the site with their social
>> accounts. Once registered the system will create a group which will
>> own. Then the owner of the group may invite people to integrate this
>> group. Those who respond to the invitation may log in with their social
>> accounts too. Guests can not create groups, because they are guests.
>>
>> Someon has some tips for me?
>>
>> Thanks a lot!
>>
>>
>> [1] https://bitbucket.org/david/django-invitation/wiki/Home
>>
>



>  [2] https://github.com/pennersr/django-allauth
>>
>
 I don't know this application, I know about:

 - python-social-auth
 - http://peterhudec.github.io/authomatic/ something like that

 Both are nice and probably work but I couldn't use because I did not
 use django for this specific project and they did not integrate well.


 Hope this helps,



 Amirouche
 --
 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/CAL7_Mo9nHfUbR-OrvOjLALUZmeqqSKePbhzYuZXzOcxUaFC%3DJg%40mail.gmail.com
 .
 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>
>>>
>>> --
>>> Rafael E. Ferrero
>>>  --
>>> 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/CAJJc_8XfAHskv35fZw%3D-GMT16%2Bvp%3DcU0W9BCokOm_Y158N0pHA%40mail.gmail.com
>>> .
>>>
>>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAFWa6tKeyH5SbfN9zMZUv2b4QsfsCSNubmZpu-3azozr-u-fmQ%40mail.gmail.com
>> .
>>
>> 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 

Re: Invitations Apps

2013-11-08 Thread Amirouche Boubekki
Tell us when you are done, maybe share it on github ?


2013/11/8 Rafael E. Ferrero 

> Avraham Serour Sending the email its not my problem.
> I start to think doing by my self an invitation app for what i need... so
> thank you all you guys!!
>
> See ya.
>
>
>
> 2013/11/8 Amirouche Boubekki 
>
>>
>>
>>
>> 2013/11/8 Avraham Serour 
>>
>>> You could create a invitation model, I don't see the problem
>>> but maybe you don't even need to, if all you want is for a user to ask
>>> the server to send some emails you can just do that: let the user ask the
>>> server to send emails.
>>>
>>
>> Invitation are probably limited.
>>
>>
>>
>>>
>>> On Thu, Nov 7, 2013 at 11:43 PM, Rafael E. Ferrero <
>>> rafael.ferr...@gmail.com> wrote:
>>>
 Im doing a project where visitors can registers with his social
 accounts (this it can be done with AllAuth in a very simple way)
 When a visitor get registered the system he can create a group. (this
 is not a problem too)
 But... a registered visitor can invitate, by email, to other people to
 join in his group. The idea is that these guest can login with his own
 social accounts too, So here's the problem, AllAuth make it easy to login
 with social accounts but does not manage invitations.
  I do not want to reinvent the wheel but if nobody did this before I'm
 afraid that i have to put my hands in the dough.

 Cheers !


 2013/11/7 Amirouche Boubekki 

> Héllo Rafael,
>
>
> I don't know those particular applications, so I can't help. Do you
> have a specific problem?
>
>
> 2013/11/7 Rafael E. Ferrero 
>
>> No body can help me?
>>
>>
>> 2013/11/7 Rafael E. Ferrero 
>>
>>
>>> Has someone used some invitation app for django like
>>> django-invitation [1]... and more, has someone integrated something like
>>> that with AllAuth [2] ??
>>>
>>> In a project I need visitors to register on the site with their social
>>> accounts. Once registered the system will create a group which will
>>> own. Then the owner of the group may invite people to integrate this
>>> group. Those who respond to the invitation may log in with their social
>>> accounts too. Guests can not create groups, because they are guests.
>>>
>>> Someon has some tips for me?
>>>
>>> Thanks a lot!
>>>
>>>
>>> [1] https://bitbucket.org/david/django-invitation/wiki/Home
>>>
>>
>
>
>
>>  [2] https://github.com/pennersr/django-allauth
>>>
>>
> I don't know this application, I know about:
>
> - python-social-auth
> - http://peterhudec.github.io/authomatic/ something like that
>
> Both are nice and probably work but I couldn't use because I did not
> use django for this specific project and they did not integrate well.
>
>
> Hope this helps,
>
>
>
> Amirouche
> --
> 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/CAL7_Mo9nHfUbR-OrvOjLALUZmeqqSKePbhzYuZXzOcxUaFC%3DJg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



 --
 Rafael E. Ferrero
  --
 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/CAJJc_8XfAHskv35fZw%3D-GMT16%2Bvp%3DcU0W9BCokOm_Y158N0pHA%40mail.gmail.com
 .

 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAFWa6tKeyH5SbfN9zMZUv2b4QsfsCSNubmZpu-3azozr-u-fmQ%40mail.gmail.com
>>> .
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
>> You received this message be

Re: 1.5 user abstract question

2013-11-08 Thread Vincenzo Prignano
You can define your Custom User Model in your models.py (
https://docs.djangoproject.com/en/1.6/topics/auth/customizing/#substituting-a-custom-user-model
)
and then in your settings specify with AUTH_USER_MODEL = 'myapp.MyUser'

On Tuesday, March 26, 2013 9:51:21 PM UTC+1, frocco wrote:
>
> Hello
>
> I need a couple of extra fields in my user model 
>
> Do I have to specify all fields in django user?
>
> Is django user still used?
>
>

-- 
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/3b3d0a8f-2767-48bc-9b0b-80938d075b05%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Connection with third database using multidb implementing DB Router

2013-11-08 Thread Ovnicraft
Hi to all friends !

I am working in django project its has many apps with their default db
configured.
So now i need to read (and possible write) to third DB (mysql) and i found
a thread[1] here about it.

There are some suggestions about write ReadOnly objects, redefine save
methods but i'm not totally convinced about it.

Reading documentation about multidb i found DB routes and it has
allow_syndb[2] so my question is, if i code to dont allow sync any model in
third db i can query (RAW SQL) without problems ?

I dont want to write any dirty layer to connect to my third DB just re-use
django engine.

I will appreciated your help !

Best regards,

[1]
https://groups.google.com/forum/#!msg/django-users/rv6D5Pqs7Fo/pkwinU7PGOQJ
[2] https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#allow_syncdb


-- 
Cristian Salamea
@ovnicraft

-- 
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%2B16coM5s7KgGrMF4MqTGY5DYZ%2B7M43-4PkV14sm2yNTvstCHA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Saving an inline view and executing an aggregating function only once

2013-11-08 Thread Vincenzo Prignano
 I got that you are executing a raw sql query every time you insert a new 
OrderDetail record. But can I ask why are you doing this? 
I think you should really need to redesign your models..

On Thursday, November 7, 2013 10:04:33 AM UTC+1, vittorio wrote:
>
> I made an effort to simplify my app and translate it into English. 
> Here it is 
> = 
> models.py 
> . 
> class Items(models.Model): 
> code = 
> models.CharField(primary_key=True,max_length=15,db_column='code') 
> description = models.CharField(max_length=255, 
> db_column='Description', db_index=True) 
> category = models.IntegerField(choices=categoria, 
> db_column='Category',default=2) 
> 
> total_quantity_in_store=models.IntegerField(db_column='total_quantity_in_store',
>  
> default=0) 
> def __unicode__(self): 
> return self.description 
> class Meta: 
> db_table = u'Items' 
>   
> class Order(models.Model): 
> id_order = models.IntegerField(primary_key=True,db_column='id_order') 
> patient = models.ForeignKey(Patients, db_column='patient') 
> def __unicode__(self): 
> return u"Ord.%s per %s" % (self.id_order, self.paziente) 
> class Meta: 
> db_table = u'Order' 
>
> post_save.connect(TotalInStore, sender=Order) 
>
> class OrderDetail(models.Model): 
>id_order = models.ForeignKey(Order,db_column='id_order') 
>item_code = models.ForeignKey(Items,verbose_name='Items') 
>quantity = 
> models.IntegerField(db_column='quantity',blank=True,default=0) 
> class Meta: 
> db_table = u'OrderDetail' 
> == 
> admin.py 
> .. 
> class OrderDetailInline(admin.TabularInline): 
> model=OrderDetail 
> raw_id_fields = ['item_code',] 
> fields=('item_code', 'quantity',) 
>
> class OrderOption(admin.ModelAdmin): 
> readonly_fields = ['order_id', 'patient'] 
> list_display = ( 'patient','order_id') 
> fields=( 'order_id', 'patient') 
> inlines=[OrderDetailInline,] 
>
> admin.site.register(Order,OrderOption) 
>  
> = 
> signals.py 
> def ExecuteQuery(query): 
> from django.db import connection 
> cursor=None 
> cursor= connection.cursor() 
> cursor.execute(query, []) 
> return cursor.fetchall() 
>
> def TotalInStore(sender,**kwargs): 
>  
> ItemsInOrder = """SELECT item_code_id as code,SUM(quantity) as total 
> FROM OrderDetail 
> GROUP BY item_code_id 
> ORDER BY item_code_id""" 
> SUMS = ExecuteQuery(ItemsInOrder) 
> if SUMS: 
>   
>  [Items.objects.filter(pk=t[0]).update(total_quantity_in_store=int(t[1])) 
> for t in SUMS] 
> . 
> return 
>
> To put it in a nutshell my Django 1.5.5 app 1):records the quantities of 
> medical items given to patients of a medical center by means of  an inline 
> view that connects 'OrderDetail' to 'Order', 2):  then input in the field 
> total_quantity_in_store of the model 'Items' the sum of the field quantity 
> ('OrderDetail') aggregated by item code via a post_save signal calling the 
> TotalInStore function. 
> It works happily BUT  unfortunately with the increasing numbers of 
> record in 'OrderDetail' it is (and will be obviously) becoming slower and 
> slower.  This is due to the fact that the post_save signal - aggregating 
> the quantities - by code is called for EACH OrderDetail record I have input 
> in the inline view while it will be more logical to execute it ***after*** 
> all records of the inline view have been saved. 
>   
> Please help me modify my app so that the TotalInStore function is called 
> only once after the inline view Order-OrderDetail has been saved. 
>
> Ciao 
> Vittorio 
>
>

-- 
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/c1081e20-375a-4626-9b72-6582caad3a97%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: AbstractBaseUser with a foreignkey...

2013-11-08 Thread Vincenzo Prignano
I think the problem here is that when you create the superuser, the related 
field will not be created.
You should add sistema = models.ForeignKey('Sistema', null=True) or sistema 
= models.ForeignKey('Sistema', default=1) where 1 is a placeholder 
'Sistema' object that you have created.
I suggest to just use the null method as it designs a better system.

On Thursday, November 7, 2013 2:56:03 PM UTC+1, Vanni Brutto wrote:
>
> i'm trying to use AbstractBaseUser to extend the user model...
>
> i used the code found on django pages, the only difference is that i use a 
> foreignkey to "Sistema" models.
> The originale code is on django pages: 
> https://docs.djangoproject.com/en/dev/topics/auth/customizing/
>
> my changes was:
>
> [...]
> class Sistema(models.Model):
> models.ForeignKey(settings.AUTH_USER_MODEL)
> nome = models.CharField(max_length=80)
> def __unicode__(self):
> return self.nome
> class Meta:
> verbose_name_plural = "Sistemi"
>
> [...]
>
> class MyUser(AbstractBaseUser):
> email = models.EmailField(
> verbose_name='email address',
> max_length=255,
> unique=True,
> db_index=True,
> )
> date_of_birth = models.DateField()
> is_active = models.BooleanField(default=True)
> is_admin = models.BooleanField(default=False)
>
> TIPO_CHOICES = (
> ('C', 'Cameriere'),
> ('G', 'Guest'),
> ('A', 'Admin'),
> )
> tipo = models.CharField(max_length=1, choices=TIPO_CHOICES, 
> default="C")
> sistema = models.ForeignKey(Sistema)
>
>
>
> when create the db with syncdb i got:
> ds\createsuperuser.py", line 116, in handle
> user_data[field_name] = field.clean(raw_value, None)
>   File 
> "C:\apps\Python27\Lib\site-packages\django\db\models\fields\__init__.py",
>  line 255, in clean
> self.validate(value, model_instance)
>   File 
> "C:\apps\Python27\Lib\site-packages\django\db\models\fields\related.py",
> line 1189, in validate
> using = router.db_for_read(model_instance.__class__, 
> instance=model_instance
> )
>   File "C:\apps\Python27\Lib\site-packages\django\db\utils.py", line 250, 
> in _ro
> ute_db
> return hints['instance']._state.db or DEFAULT_DB_ALIAS
> AttributeError: 'NoneType' object has no attribute '_state'
>
> C:\apps\xampp\htdocs\py\comanda>
>

-- 
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/cbf65546-3816-4140-93dd-29dc4ca9c728%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Invitations Apps

2013-11-08 Thread Rafael E. Ferrero
Yes, Off Course... im doing an Simple Fixed Asset Management System who can
support multiple litle companies, guided by tickets.
Thats why a registered user should not see any stuff from other group
(or company)



2013/11/8 Amirouche Boubekki 

> Tell us when you are done, maybe share it on github ?
>
>
> 2013/11/8 Rafael E. Ferrero 
>
>> Avraham Serour Sending the email its not my problem.
>> I start to think doing by my self an invitation app for what i need... so
>> thank you all you guys!!
>>
>> See ya.
>>
>>
>>
>> 2013/11/8 Amirouche Boubekki 
>>
>>>
>>>
>>>
>>> 2013/11/8 Avraham Serour 
>>>
 You could create a invitation model, I don't see the problem
 but maybe you don't even need to, if all you want is for a user to ask
 the server to send some emails you can just do that: let the user ask the
 server to send emails.

>>>
>>> Invitation are probably limited.
>>>
>>>
>>>

 On Thu, Nov 7, 2013 at 11:43 PM, Rafael E. Ferrero <
 rafael.ferr...@gmail.com> wrote:

> Im doing a project where visitors can registers with his social
> accounts (this it can be done with AllAuth in a very simple way)
> When a visitor get registered the system he can create a group. (this
> is not a problem too)
> But... a registered visitor can invitate, by email, to other people to
> join in his group. The idea is that these guest can login with his own
> social accounts too, So here's the problem, AllAuth make it easy to login
> with social accounts but does not manage invitations.
>  I do not want to reinvent the wheel but if nobody did this before I'm
> afraid that i have to put my hands in the dough.
>
> Cheers !
>
>
> 2013/11/7 Amirouche Boubekki 
>
>> Héllo Rafael,
>>
>>
>> I don't know those particular applications, so I can't help. Do you
>> have a specific problem?
>>
>>
>> 2013/11/7 Rafael E. Ferrero 
>>
>>> No body can help me?
>>>
>>>
>>> 2013/11/7 Rafael E. Ferrero 
>>>
>>>
 Has someone used some invitation app for django like
 django-invitation [1]... and more, has someone integrated something 
 like
 that with AllAuth [2] ??

 In a project I need visitors to register on the site with their social
 accounts. Once registered the system will create a group which will
 own. Then the owner of the group may invite people to integrate
 this group. Those who respond to the invitation may log in with
 their social accounts too. Guests can not create groups, because
 they are guests.

 Someon has some tips for me?

 Thanks a lot!


 [1] https://bitbucket.org/david/django-invitation/wiki/Home

>>>
>>
>>
>>
>>>  [2] https://github.com/pennersr/django-allauth

>>>
>> I don't know this application, I know about:
>>
>> - python-social-auth
>> - http://peterhudec.github.io/authomatic/ something like that
>>
>> Both are nice and probably work but I couldn't use because I did not
>> use django for this specific project and they did not integrate well.
>>
>>
>> Hope this helps,
>>
>>
>>
>> Amirouche
>> --
>> 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/CAL7_Mo9nHfUbR-OrvOjLALUZmeqqSKePbhzYuZXzOcxUaFC%3DJg%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Rafael E. Ferrero
>  --
> 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/CAJJc_8XfAHskv35fZw%3D-GMT16%2Bvp%3DcU0W9BCokOm_Y158N0pHA%40mail.gmail.com
> .
>
> 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 grou

Re: Managing existing UI

2013-11-08 Thread Vincenzo Prignano
Hello Paolo,
I really don't get your question. The templates are still used in Django. 
You should be aware of the Model View Controller philosophy. Actually in 
Django is Model Templates (as View) View (as Controller).

PS: If you are going to use Python 3 be sure to start with Django 1.6 
(released few days ago) as it's the first release to support Python 3. But 
still, if you are a beginner please start with Python 2.7.x

On Friday, November 1, 2013 8:25:22 PM UTC+1, Paolo Giannoccaro wrote:
>
> Hi All,
> which are the best practices while developing a full Django app (version 
> 1.5, Phyton 3) starting from an existing html UI ? The template approach is 
> still valid ? In this case which is the impact over existing html UI ?
> Many 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/0ce77b64-f61a-48c1-b9be-72cdf9dfd082%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Complex query reduction

2013-11-08 Thread Javier Guerra Giraldez
On Fri, Nov 8, 2013 at 1:44 AM, Robin St.Clair  wrote:
> The last time I checked the use of IN, all the records from the database in
> the query were brought back to the workstation, rather than being processed
> on the backend and only the results returned to the workstation.


Django ORM's __in operator tries to use SQL facilities, but depending
on the type of object passed, it could read the list of options and
pass it explicitly, or it could merge two SQL commands.  always check
the type of SQL commands generated!  (debug toolbar is your friend)

i haven't seen it doing a post-retrieve check in python, thought.

-- 
Javier

-- 
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/CAFkDaoRLfeLi%3DWVu5f%3DcyCXRH0x5mr1fbDiV0OzW%2Bn-fpk6uHw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Problems with turning on the Admin

2013-11-08 Thread Keith Edmiston
Hi,

I am building a new site in Django 1.4 and I'm using the South migration
tool to keep my dev MySQL database in sync with changes made to my models.
It should be said that I use one MySQL database account to serve various
Django projects/apps (confusing, yes). It all seems to be working fine
until I attempt to open up the Admin site from the project currently in
development (bus/certs/admin/).

It *appears* that the autodiscover is trying to find a model "Listing" that
is no longer in existence, but did exist in earlier development stages. I
deleted that model and have since run a South migration to extend that
deletion to the database.  That seems to have worked fine. What did not
seem to happen is the removal of references to the "listing" table in the
django_content_type and auth_permission tables, so I removed those manually
thinking the autodiscover might be "seeing" those entries and subsequently
attempting to find the model in "bus_models.models". That seems to have
made no difference, the error still exists.

Not sure if this matters or not, but I had initially used the admin up in a
separate project ("deans" vs. "certs") and it still works.  It even still
lists the "Bus_models.Listing" model and only fails once I click on that
link...gives me a "Table does not exist" error, as I would expect. This
does make me think, however, that there is a lingering pointer somewhere
that I'm unable to locate.

I can reliably cause this error to occur and go away again by
uncommenting/commenting the following lines in my
bus(app)/certs(proj)/urls.py file:

from django.contrib import admin
admin.autodiscover()
(r'^apps/bus/certs/admin/', include(admin.site.urls)),

Here is the traceback of the error page that shows up when the above are
uncommented (no matter what url I use):
Environment:


Request Method: GET
Request URL: https://local.utexas.edu:8000/apps/bus/certs/application/1256/

Django Version: 1.4.3
Python Version: 2.6.7
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'utdirect',
 'bus.certs.application',
 'bus.certs.listing',
 'bus.certs.common',
 'bus.certs.bus_shared_common',
 'bus.certs.bus_models',
 'debug_toolbar',
 'ut_debug_toolbar',
 'south')
Installed Middleware:
('django.middleware.gzip.GZipMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'utdirect.middleware.HttpHeaderMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/core/handlers/base.py"
in get_response
  89. response = middleware_method(request)
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py"
in process_request
  160. request.urlconf = _build_urlconf(request)
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py"
in _build_urlconf
  123. class URLPatterns(object):
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py"
in URLPatterns
  130. url('', include(original_urlconf)),
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/conf/urls/__init__.py"
in include
  24. urlconf_module = import_module(urlconf_module)
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/utils/importlib.py"
in import_module
  35. __import__(name)
File "/pype/bus/certs/urls.py" in 
  7. admin.autodiscover()
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/contrib/admin/__init__.py"
in autodiscover
  29. import_module('%s.admin' % app)
File
"/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/utils/importlib.py"
in import_module
  35. __import__(name)

Exception Type: NameError at /apps/bus/certs/application/1256/
Exception Value: name 'Listing' is not defined

Lastly, I have searched in as many ways I can think to search for any
reference to "Listing" in the database and code base, but cannot find
anything.

Any help would be greatly appreciated.

Regards,

-- 
Keith

-- 
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/CAP_gv7%2B%2BO-M6Kac4crBK6qHHdW04kFNm5AQuusGP0D9nJ3fUuA%40mail.gmail.com.
For more options, visit https://groups.goo

Re: Connection with third database using multidb implementing DB Router

2013-11-08 Thread George Silva
I only had to query external databases.

I've created my models as managed=False and implemented a custom manager
that redefined the default database configuration. We did not had
situations where depending on a certain condition the target database would
change, but this worked just fine.


On Fri, Nov 8, 2013 at 12:45 PM, Ovnicraft  wrote:

> Hi to all friends !
>
> I am working in django project its has many apps with their default db
> configured.
> So now i need to read (and possible write) to third DB (mysql) and i found
> a thread[1] here about it.
>
> There are some suggestions about write ReadOnly objects, redefine save
> methods but i'm not totally convinced about it.
>
> Reading documentation about multidb i found DB routes and it has
> allow_syndb[2] so my question is, if i code to dont allow sync any model in
> third db i can query (RAW SQL) without problems ?
>
> I dont want to write any dirty layer to connect to my third DB just re-use
> django engine.
>
> I will appreciated your help !
>
> Best regards,
>
> [1]
> https://groups.google.com/forum/#!msg/django-users/rv6D5Pqs7Fo/pkwinU7PGOQJ
> [2] https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#allow_syncdb
>
>
> --
> Cristian Salamea
> @ovnicraft
>
> --
> 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%2B16coM5s7KgGrMF4MqTGY5DYZ%2B7M43-4PkV14sm2yNTvstCHA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
George R. C. Silva
SIGMA Consultoria

http://www.consultoriasigma.com.br/

-- 
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/CAGyPVTsLt%2BPcWojAeGJFGqE9oNsR4HA6ecgnYg8zeBU%2BTGFG-g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Problems with turning on the Admin

2013-11-08 Thread Vincenzo Prignano
'bus.certs.listing' is this entry in your installed apps referring to the 
"Listing" models perhaps? We can't really help you with much more info btw.

On Friday, November 8, 2013 4:55:04 PM UTC+1, Keith Edmiston wrote:
>
> Hi,
>
> I am building a new site in Django 1.4 and I'm using the South migration 
> tool to keep my dev MySQL database in sync with changes made to my models. 
> It should be said that I use one MySQL database account to serve various 
> Django projects/apps (confusing, yes). It all seems to be working fine 
> until I attempt to open up the Admin site from the project currently in 
> development (bus/certs/admin/).
>
> It *appears* that the autodiscover is trying to find a model "Listing" 
> that is no longer in existence, but did exist in earlier development 
> stages. I deleted that model and have since run a South migration to extend 
> that deletion to the database.  That seems to have worked fine. What did 
> not seem to happen is the removal of references to the "listing" table in 
> the django_content_type and auth_permission tables, so I removed those 
> manually thinking the autodiscover might be "seeing" those entries and 
> subsequently attempting to find the model in "bus_models.models". That 
> seems to have made no difference, the error still exists.
>
> Not sure if this matters or not, but I had initially used the admin up in 
> a separate project ("deans" vs. "certs") and it still works.  It even still 
> lists the "Bus_models.Listing" model and only fails once I click on that 
> link...gives me a "Table does not exist" error, as I would expect. This 
> does make me think, however, that there is a lingering pointer somewhere 
> that I'm unable to locate.
>
> I can reliably cause this error to occur and go away again by 
> uncommenting/commenting the following lines in my 
> bus(app)/certs(proj)/urls.py file:
>
> from django.contrib import admin
> admin.autodiscover()
> (r'^apps/bus/certs/admin/', include(admin.site.urls)),
>
> Here is the traceback of the error page that shows up when the above are 
> uncommented (no matter what url I use):
> Environment:
>
>
> Request Method: GET
> Request URL: 
> https://local.utexas.edu:8000/apps/bus/certs/application/1256/
>
> Django Version: 1.4.3
> Python Version: 2.6.7
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'django.contrib.admin',
>  'utdirect',
>  'bus.certs.application',
>  'bus.certs.listing',
>  'bus.certs.common',
>  'bus.certs.bus_shared_common',
>  'bus.certs.bus_models',
>  'debug_toolbar',
>  'ut_debug_toolbar',
>  'south')
> Installed Middleware:
> ('django.middleware.gzip.GZipMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'utdirect.middleware.HttpHeaderMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware',
>  'debug_toolbar.middleware.DebugToolbarMiddleware')
>
>
> Traceback:
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/core/handlers/base.py"
>  
> in get_response
>   89. response = middleware_method(request)
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py" 
> in process_request
>   160. request.urlconf = _build_urlconf(request)
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py" 
> in _build_urlconf
>   123. class URLPatterns(object):
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py" 
> in URLPatterns
>   130. url('', include(original_urlconf)),
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/conf/urls/__init__.py"
>  
> in include
>   24. urlconf_module = import_module(urlconf_module)
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/utils/importlib.py"
>  
> in import_module
>   35. __import__(name)
> File "/pype/bus/certs/urls.py" in 
>   7. admin.autodiscover()
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/contrib/admin/__init__.py"
>  
> in autodiscover
>   29. import_module('%s.admin' % app)
> File 
> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/utils/importlib.py"
>  
> in import_module
>   35. __import__(name)
>
> Exception Type: NameError at /apps/bus/certs/application/1256/
> Exception Value: name 'Listing' is not defined
>
> Lastly, I have searched in as many ways I can think to search for any 
> reference to "Listing" in the database and code base, but cannot find 
> anything.
>
> Any help would be greatly appreciated.
>
> Regards,
>
> -- 
> Keith  
>

-- 
You received this message because you are subscribe

django - How to copy the actual image file from one model to another?

2013-11-08 Thread Aamu Padi
I want to copy images from one model to another within the project. Suppose
these are my models:

class BackgroundImage(models.Model):
user = models.ForeignKey(User)
image = models.ImageField(upload_to=get_upload_file_name)
caption = models.CharField(max_length=200)
pub_date = models.DateTimeField(default=datetime.now)


class ProfilePicture(models.Model):
user = models.ForeignKey(User)
image = models.ImageField(upload_to=get_upload_file_name)
caption = models.CharField(max_length=200)
pub_date = models.DateTimeField(default=datetime.now)

@classmethod
def create_from_bg(cls, bg_img):
img = cls(user=bg_img.user, image=bg_img.image,
caption=bg_img.caption+'_copy', pub_date=bg_img.pub_date)
img.save()
return img

*For now, I can do these:*

*To get the user*
   * >>>m = User.objects.get(username='m')*

*To get the user's profile picture set*


*>>>m_pro_set = m.profilepicture_set.all()>>>m_pro_set
[]*

*Get an image object from Background image of the user*


*>>>m_back_1 = m.backgroundimage_set.get(id=2)>>>m_back_1
*

*And then:*
*>>>profile_pic = ProfilePicture.create_from_bg(m_back_1)*

*Now when I check it, it does create a new instance.*

*>>>m_pro_set[,]*


*But, if I check on the path, and even on the media folder, its the same
image and not an actual copy of the image file in the folder or disk.*





*>>>profile_pic.image>>>m_back_1.image*

What it does is, when I save a new instance of the image, it creates a new
instance of that same image, and not creates a new file in the disk, i.e.
there's no actual copying of the file in the directory. How do I go about
to actually copy the original image `file` within the models? Any help will
be much appreciated! 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/CAHSNPWvovkBszoFPJJC_o_T1aENXB7GNpAH6NzpbOAg%2BmXbvpA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Connection with third database using multidb implementing DB Router

2013-11-08 Thread Ovnicraft
On Fri, Nov 8, 2013 at 11:39 AM, George Silva wrote:

> I only had to query external databases.
>
> I've created my models as managed=False and implemented a custom manager
> that redefined the default database configuration. We did not had
> situations where depending on a certain condition the target database would
> change, but this worked just fine.
>

What database configuration did you change ?

Regards,

>
>
> On Fri, Nov 8, 2013 at 12:45 PM, Ovnicraft  wrote:
>
>> Hi to all friends !
>>
>> I am working in django project its has many apps with their default db
>> configured.
>> So now i need to read (and possible write) to third DB (mysql) and i
>> found a thread[1] here about it.
>>
>> There are some suggestions about write ReadOnly objects, redefine save
>> methods but i'm not totally convinced about it.
>>
>> Reading documentation about multidb i found DB routes and it has
>> allow_syndb[2] so my question is, if i code to dont allow sync any model in
>> third db i can query (RAW SQL) without problems ?
>>
>> I dont want to write any dirty layer to connect to my third DB just
>> re-use django engine.
>>
>> I will appreciated your help !
>>
>> Best regards,
>>
>> [1]
>> https://groups.google.com/forum/#!msg/django-users/rv6D5Pqs7Fo/pkwinU7PGOQJ
>> [2]
>> https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#allow_syncdb
>>
>>
>> --
>> Cristian Salamea
>> @ovnicraft
>>
>> --
>> 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%2B16coM5s7KgGrMF4MqTGY5DYZ%2B7M43-4PkV14sm2yNTvstCHA%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> George R. C. Silva
> SIGMA Consultoria
> 
> http://www.consultoriasigma.com.br/
>
> --
> 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/CAGyPVTsLt%2BPcWojAeGJFGqE9oNsR4HA6ecgnYg8zeBU%2BTGFG-g%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Cristian Salamea
@ovnicraft

-- 
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%2B16coOOX0W6MjxDvB9GRUjq%3D-tYj4bfZX%2B_K1hV1rUt-uMpiA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Connection with third database using multidb implementing DB Router

2013-11-08 Thread George Silva
Let me explain this better.

I've created a custom manager, in which I replaced the default database
alias it should connect.

class ExternalManager(models.Manager):
"""
Manager customizado para buscar os dados no banco legado.
"""
alias = None


def __init__(self, alias=None):
self.alias = alias
super(LegadoManager, self).__init__()


def get_query_set(self):
"""
Retorna um query set conectando ao banco legado.
"""
if not hasattr(self.model, '_db_alias'):
self.model._db_alias = self.alias
qs = QuerySet(self.model)
if self.model._db_alias is not None:
qs = qs.using(self.model._db_alias)
return qs




Now, create your model and override the objects property, passing the name
of the database configured in settings.py as the alias.


Like this:


class ModelInAnotherDatabase(models.Model):


name = models.CharField()


objects = ExternalManager(alias="external")


Where external is the database name configured in settings.py.



On Fri, Nov 8, 2013 at 3:11 PM, Ovnicraft  wrote:

>
>
>
> On Fri, Nov 8, 2013 at 11:39 AM, George Silva wrote:
>
>> I only had to query external databases.
>>
>> I've created my models as managed=False and implemented a custom manager
>> that redefined the default database configuration. We did not had
>> situations where depending on a certain condition the target database would
>> change, but this worked just fine.
>>
>
> What database configuration did you change ?
>
> Regards,
>
>>
>>
>> On Fri, Nov 8, 2013 at 12:45 PM, Ovnicraft  wrote:
>>
>>> Hi to all friends !
>>>
>>> I am working in django project its has many apps with their default db
>>> configured.
>>> So now i need to read (and possible write) to third DB (mysql) and i
>>> found a thread[1] here about it.
>>>
>>> There are some suggestions about write ReadOnly objects, redefine save
>>> methods but i'm not totally convinced about it.
>>>
>>> Reading documentation about multidb i found DB routes and it has
>>> allow_syndb[2] so my question is, if i code to dont allow sync any model in
>>> third db i can query (RAW SQL) without problems ?
>>>
>>> I dont want to write any dirty layer to connect to my third DB just
>>> re-use django engine.
>>>
>>> I will appreciated your help !
>>>
>>> Best regards,
>>>
>>> [1]
>>> https://groups.google.com/forum/#!msg/django-users/rv6D5Pqs7Fo/pkwinU7PGOQJ
>>> [2]
>>> https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#allow_syncdb
>>>
>>>
>>> --
>>> Cristian Salamea
>>> @ovnicraft
>>>
>>> --
>>> 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%2B16coM5s7KgGrMF4MqTGY5DYZ%2B7M43-4PkV14sm2yNTvstCHA%40mail.gmail.com
>>> .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> George R. C. Silva
>> SIGMA Consultoria
>> 
>> http://www.consultoriasigma.com.br/
>>
>> --
>> 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/CAGyPVTsLt%2BPcWojAeGJFGqE9oNsR4HA6ecgnYg8zeBU%2BTGFG-g%40mail.gmail.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Cristian Salamea
> @ovnicraft
>
> --
> 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%2B16coOOX0W6MjxDvB9GRUjq%3D-tYj4bfZX%2B_K1hV1rUt-uMpiA%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
George R. C. Silva
SIGMA Consultoria

http://www.consultoriasigma.com.br/

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

Re: Connection with third database using multidb implementing DB Router

2013-11-08 Thread Ovnicraft
I will check it ! thanks !

On Fri, Nov 8, 2013 at 12:19 PM, George Silva wrote:

> Let me explain this better.
>
> I've created a custom manager, in which I replaced the default database
> alias it should connect.
>
> class ExternalManager(models.Manager):
>
>
> """
>
> Manager customizado para buscar os dados no banco legado.
>
>
> """
>
> alias = None
>
>
>
>
>
>
> def __init__(self, alias=None):
>
>
> self.alias = alias
>
>
> super(LegadoManager, self).__init__()
>
>
>
>
>
>
> def get_query_set(self):
>
> """
>
>
> Retorna um query set conectando ao banco legado.
>
>
> """
>
>
> if not hasattr(self.model, '_db_alias'):
>
>
> self.model._db_alias = self.alias
>
>
> qs = QuerySet(self.model)
>
>
> if self.model._db_alias is not None:
>
>
> qs = qs.using(self.model._db_alias)
>
>
> return qs
>
>
>
>
>
>
> Now, create your model and override the objects property, passing the name
> of the database configured in settings.py as the alias.
>
>
> Like this:
>
>
> class ModelInAnotherDatabase(models.Model):
>
>
> name = models.CharField()
>
>
> objects = ExternalManager(alias="external")
>
>
> Where external is the database name configured in settings.py.
>
>
>
> On Fri, Nov 8, 2013 at 3:11 PM, Ovnicraft  wrote:
>
>>
>>
>>
>> On Fri, Nov 8, 2013 at 11:39 AM, George Silva wrote:
>>
>>> I only had to query external databases.
>>>
>>> I've created my models as managed=False and implemented a custom manager
>>> that redefined the default database configuration. We did not had
>>> situations where depending on a certain condition the target database would
>>> change, but this worked just fine.
>>>
>>
>> What database configuration did you change ?
>>
>> Regards,
>>
>>>
>>>
>>> On Fri, Nov 8, 2013 at 12:45 PM, Ovnicraft  wrote:
>>>
 Hi to all friends !

 I am working in django project its has many apps with their default db
 configured.
 So now i need to read (and possible write) to third DB (mysql) and i
 found a thread[1] here about it.

 There are some suggestions about write ReadOnly objects, redefine save
 methods but i'm not totally convinced about it.

 Reading documentation about multidb i found DB routes and it has
 allow_syndb[2] so my question is, if i code to dont allow sync any model in
 third db i can query (RAW SQL) without problems ?

 I dont want to write any dirty layer to connect to my third DB just
 re-use django engine.

 I will appreciated your help !

 Best regards,

 [1]
 https://groups.google.com/forum/#!msg/django-users/rv6D5Pqs7Fo/pkwinU7PGOQJ
 [2]
 https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#allow_syncdb


 --
 Cristian Salamea
 @ovnicraft

 --
 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%2B16coM5s7KgGrMF4MqTGY5DYZ%2B7M43-4PkV14sm2yNTvstCHA%40mail.gmail.com
 .
 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>
>>>
>>> --
>>> George R. C. Silva
>>> SIGMA Consultoria
>>> 
>>> http://www.consultoriasigma.com.br/
>>>
>>> --
>>> 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/CAGyPVTsLt%2BPcWojAeGJFGqE9oNsR4HA6ecgnYg8zeBU%2BTGFG-g%40mail.gmail.com
>>> .
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Cristian Salamea
>> @ovnicraft
>>
>> --
>> 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%2B16coOOX0W6MjxDvB9GRUjq%3D-tYj4bfZX%2B_K1hV1rUt-uMpiA%40mail.gmail.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> George R.

Re: Problems with turning on the Admin

2013-11-08 Thread Keith Edmiston
Sorry...I was trying to be careful of not putting so much info in the email
that it became too much.

My project structure is (in part):
--bus/certs
|_ application
  |_ __init__
  |_ models.py --> empty, using common/models.py & bus_models/models.py
  |_ urls.py
  |_ views.py

|_ bus_models (svn: externals)
  |_ __init__
  |_ models.py --> Person

|_ bus_shared_common (svn: externals)
  |_ __init__
  |_ static (css, js, etc.)
  |_ templates

|_ common
  |_ __init__
  |_ models.py --> Program, Status, Application, Notes, Action,
Correspondence

|_ listing
  |_ __init__
  |_ models.py --> empty, using common/models.py & bus_models/models.py
  |_ urls.py --> only one regex so far..."listing", which calls
"listing" in views.py
  |_ views.py --> "listing" function

So, in answer to your question Vincenzo, bus.certs.listing does not make a
call to any model just yet.  Thanks for suggesting I look though.

Keith


On Fri, Nov 8, 2013 at 10:39 AM, Vincenzo Prignano <
vincenzo.prign...@gmail.com> wrote:

> 'bus.certs.listing' is this entry in your installed apps referring to the
> "Listing" models perhaps? We can't really help you with much more info btw.
>
>
> On Friday, November 8, 2013 4:55:04 PM UTC+1, Keith Edmiston wrote:
>>
>> Hi,
>>
>> I am building a new site in Django 1.4 and I'm using the South migration
>> tool to keep my dev MySQL database in sync with changes made to my models.
>> It should be said that I use one MySQL database account to serve various
>> Django projects/apps (confusing, yes). It all seems to be working fine
>> until I attempt to open up the Admin site from the project currently in
>> development (bus/certs/admin/).
>>
>> It *appears* that the autodiscover is trying to find a model "Listing"
>> that is no longer in existence, but did exist in earlier development
>> stages. I deleted that model and have since run a South migration to extend
>> that deletion to the database.  That seems to have worked fine. What did
>> not seem to happen is the removal of references to the "listing" table in
>> the django_content_type and auth_permission tables, so I removed those
>> manually thinking the autodiscover might be "seeing" those entries and
>> subsequently attempting to find the model in "bus_models.models". That
>> seems to have made no difference, the error still exists.
>>
>> Not sure if this matters or not, but I had initially used the admin up in
>> a separate project ("deans" vs. "certs") and it still works.  It even still
>> lists the "Bus_models.Listing" model and only fails once I click on that
>> link...gives me a "Table does not exist" error, as I would expect. This
>> does make me think, however, that there is a lingering pointer somewhere
>> that I'm unable to locate.
>>
>> I can reliably cause this error to occur and go away again by
>> uncommenting/commenting the following lines in my
>> bus(app)/certs(proj)/urls.py file:
>>
>> from django.contrib import admin
>> admin.autodiscover()
>> (r'^apps/bus/certs/admin/', include(admin.site.urls)),
>>
>> Here is the traceback of the error page that shows up when the above are
>> uncommented (no matter what url I use):
>> Environment:
>>
>>
>> Request Method: GET
>> Request URL: https://local.utexas.edu:8000/apps/bus/certs/application/
>> 1256/
>>
>> Django Version: 1.4.3
>> Python Version: 2.6.7
>> Installed Applications:
>> ('django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.sites',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'django.contrib.admin',
>>  'utdirect',
>>  'bus.certs.application',
>>  'bus.certs.listing',
>>  'bus.certs.common',
>>  'bus.certs.bus_shared_common',
>>  'bus.certs.bus_models',
>>  'debug_toolbar',
>>  'ut_debug_toolbar',
>>  'south')
>> Installed Middleware:
>> ('django.middleware.gzip.GZipMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'utdirect.middleware.HttpHeaderMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>  'debug_toolbar.middleware.DebugToolbarMiddleware')
>>
>>
>> Traceback:
>> File 
>> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/core/handlers/base.py"
>> in get_response
>>   89. response = middleware_method(request)
>> File 
>> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py"
>> in process_request
>>   160. request.urlconf = _build_urlconf(request)
>> File 
>> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py"
>> in _build_urlconf
>>   123. class URLPatterns(object):
>> File 
>> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py"
>> in URLP

Re: Problems with turning on the Admin

2013-11-08 Thread Vincenzo Prignano
Can you post the line in urls.py that is calling the view function?

On Friday, November 8, 2013 6:48:28 PM UTC+1, Keith Edmiston wrote:
>
> Sorry...I was trying to be careful of not putting so much info in the 
> email that it became too much.
>
> My project structure is (in part):
> --bus/certs
> |_ application
>   |_ __init__
>   |_ models.py --> empty, using common/models.py & bus_models/models.py
>   |_ urls.py
>   |_ views.py
>
> |_ bus_models (svn: externals)
>   |_ __init__
>   |_ models.py --> Person
>
> |_ bus_shared_common (svn: externals)
>   |_ __init__
>   |_ static (css, js, etc.)
>   |_ templates
>
> |_ common
>   |_ __init__
>   |_ models.py --> Program, Status, Application, Notes, Action, 
> Correspondence
>
> |_ listing
>   |_ __init__
>   |_ models.py --> empty, using common/models.py & bus_models/models.py
>   |_ urls.py --> only one regex so far..."listing", which calls 
> "listing" in views.py
>   |_ views.py --> "listing" function
>
> So, in answer to your question Vincenzo, bus.certs.listing does not make a 
> call to any model just yet.  Thanks for suggesting I look though.
>
> Keith
>
>
> On Fri, Nov 8, 2013 at 10:39 AM, Vincenzo Prignano 
> 
> > wrote:
>
>> 'bus.certs.listing' is this entry in your installed apps referring to the 
>> "Listing" models perhaps? We can't really help you with much more info btw.
>>
>>
>> On Friday, November 8, 2013 4:55:04 PM UTC+1, Keith Edmiston wrote:
>>>
>>> Hi,
>>>
>>> I am building a new site in Django 1.4 and I'm using the South migration 
>>> tool to keep my dev MySQL database in sync with changes made to my models. 
>>> It should be said that I use one MySQL database account to serve various 
>>> Django projects/apps (confusing, yes). It all seems to be working fine 
>>> until I attempt to open up the Admin site from the project currently in 
>>> development (bus/certs/admin/).
>>>
>>> It *appears* that the autodiscover is trying to find a model "Listing" 
>>> that is no longer in existence, but did exist in earlier development 
>>> stages. I deleted that model and have since run a South migration to extend 
>>> that deletion to the database.  That seems to have worked fine. What did 
>>> not seem to happen is the removal of references to the "listing" table in 
>>> the django_content_type and auth_permission tables, so I removed those 
>>> manually thinking the autodiscover might be "seeing" those entries and 
>>> subsequently attempting to find the model in "bus_models.models". That 
>>> seems to have made no difference, the error still exists.
>>>
>>> Not sure if this matters or not, but I had initially used the admin up 
>>> in a separate project ("deans" vs. "certs") and it still works.  It even 
>>> still lists the "Bus_models.Listing" model and only fails once I click on 
>>> that link...gives me a "Table does not exist" error, as I would expect. 
>>> This does make me think, however, that there is a lingering pointer 
>>> somewhere that I'm unable to locate.
>>>
>>> I can reliably cause this error to occur and go away again by 
>>> uncommenting/commenting the following lines in my 
>>> bus(app)/certs(proj)/urls.py file:
>>>
>>> from django.contrib import admin
>>> admin.autodiscover()
>>> (r'^apps/bus/certs/admin/', include(admin.site.urls)),
>>>
>>> Here is the traceback of the error page that shows up when the above are 
>>> uncommented (no matter what url I use):
>>> Environment:
>>>
>>>
>>> Request Method: GET
>>> Request URL: https://local.utexas.edu:8000/apps/bus/certs/application/
>>> 1256/
>>>
>>> Django Version: 1.4.3
>>> Python Version: 2.6.7
>>> Installed Applications:
>>> ('django.contrib.auth',
>>>  'django.contrib.contenttypes',
>>>  'django.contrib.sessions',
>>>  'django.contrib.sites',
>>>  'django.contrib.messages',
>>>  'django.contrib.staticfiles',
>>>  'django.contrib.admin',
>>>  'utdirect',
>>>  'bus.certs.application',
>>>  'bus.certs.listing',
>>>  'bus.certs.common',
>>>  'bus.certs.bus_shared_common',
>>>  'bus.certs.bus_models',
>>>  'debug_toolbar',
>>>  'ut_debug_toolbar',
>>>  'south')
>>> Installed Middleware:
>>> ('django.middleware.gzip.GZipMiddleware',
>>>  'django.middleware.common.CommonMiddleware',
>>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>>  'django.middleware.csrf.CsrfViewMiddleware',
>>>  'utdirect.middleware.HttpHeaderMiddleware',
>>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>>  'django.contrib.messages.middleware.MessageMiddleware',
>>>  'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>>  'debug_toolbar.middleware.DebugToolbarMiddleware')
>>>
>>>
>>> Traceback:
>>> File 
>>> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/django/core/handlers/base.py"
>>>  
>>> in get_response
>>>   89. response = middleware_method(request)
>>> File 
>>> "/usr/local/env/26.3.4a/lib/python2.6/site-packages/utdirect/middleware.py" 
>>> in process_request
>

Re: Problems with turning on the Admin

2013-11-08 Thread Keith Edmiston
bus/certs/urls.py:

from django.conf.urls import patterns, url, include
from django.conf import settings
from bus.certs.views import index

from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
   (r'^apps/bus/certs/$', index),
   (r'^apps/bus/certs/index$', index),
   (r'^apps/bus/certs/listing/',
include('bus.certs.listing.urls')),
   (r'^apps/bus/certs/application/',
include('bus.certs.application.urls')),
   (r'^apps/bus/certs/admin/',
include(admin.site.urls)),
   )

bus/certs/listing/urls.py:

from django.conf.urls import patterns, url, include
from django.conf import settings
from listing.views import listing

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('bus.certs.listing.views',
   (r'^$', listing, {}, 'listing'),
   )

bus/certs/application/urls.py:

from django.conf.urls import patterns, url, include
from django.conf import settings
from application.views import application_view, application_submit,
application_update

# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()

urlpatterns = patterns('bus.certs.application.views',
   (r'^(?P\d+)/$', application_view, {},
'application_view'),
   (r'^update/(?P\d+)/$', application_update,
{}, 'application_update'),
   (r'^submit/$', application_submit, {},
'application_submit'),
   #(r'^admin/', include(admin.site.urls)),
   )


On Fri, Nov 8, 2013 at 12:20 PM, Vincenzo Prignano <
vincenzo.prign...@gmail.com> wrote:

> Can you post the line in urls.py that is calling the view function?
>
>
> On Friday, November 8, 2013 6:48:28 PM UTC+1, Keith Edmiston wrote:
>
>> Sorry...I was trying to be careful of not putting so much info in the
>> email that it became too much.
>>
>> My project structure is (in part):
>> --bus/certs
>> |_ application
>>   |_ __init__
>>   |_ models.py --> empty, using common/models.py &
>> bus_models/models.py
>>   |_ urls.py
>>   |_ views.py
>>
>> |_ bus_models (svn: externals)
>>   |_ __init__
>>   |_ models.py --> Person
>>
>> |_ bus_shared_common (svn: externals)
>>   |_ __init__
>>   |_ static (css, js, etc.)
>>   |_ templates
>>
>> |_ common
>>   |_ __init__
>>   |_ models.py --> Program, Status, Application, Notes, Action,
>> Correspondence
>>
>> |_ listing
>>   |_ __init__
>>   |_ models.py --> empty, using common/models.py &
>> bus_models/models.py
>>   |_ urls.py --> only one regex so far..."listing", which calls
>> "listing" in views.py
>>   |_ views.py --> "listing" function
>>
>> So, in answer to your question Vincenzo, bus.certs.listing does not make
>> a call to any model just yet.  Thanks for suggesting I look though.
>>
>> Keith
>>
>>
>> On Fri, Nov 8, 2013 at 10:39 AM, Vincenzo Prignano > > wrote:
>>
>>> 'bus.certs.listing' is this entry in your installed apps referring to
>>> the "Listing" models perhaps? We can't really help you with much more info
>>> btw.
>>>
>>>
>>> On Friday, November 8, 2013 4:55:04 PM UTC+1, Keith Edmiston wrote:

 Hi,

 I am building a new site in Django 1.4 and I'm using the South
 migration tool to keep my dev MySQL database in sync with changes made to
 my models. It should be said that I use one MySQL database account to serve
 various Django projects/apps (confusing, yes). It all seems to be working
 fine until I attempt to open up the Admin site from the project currently
 in development (bus/certs/admin/).

 It *appears* that the autodiscover is trying to find a model "Listing"
 that is no longer in existence, but did exist in earlier development
 stages. I deleted that model and have since run a South migration to extend
 that deletion to the database.  That seems to have worked fine. What did
 not seem to happen is the removal of references to the "listing" table in
 the django_content_type and auth_permission tables, so I removed those
 manually thinking the autodiscover might be "seeing" those entries and
 subsequently attempting to find the model in "bus_models.models". That
 seems to have made no difference, the error still exists.

 Not sure if this matters or not, but I had initially used the admin up
 in a separate project ("deans" vs. "certs") and it still works.  It even
 still lists the "Bus_models.Listing" model and only fails once I click on
 that link...gives me a "Table does not exist" error, as I would expect.
 This does make me think, however, that there is a lingering pointer
 somewhere that I'm unable to locate.

 I can reliably cause this error to occu

Accessing ManyToMany Field in models.py (helper function)

2013-11-08 Thread Michael Muster
Hi there,

I want to collect some statistics about a card game.

So i have three models in my app:

Player = holds the player data
Hand = the data for one round 
Partie = The data for a complete game

class Player(models.Model):
name = models.CharField(max_length=200, unique=True)
color = models.CharField(max_length=200, unique=True)
def __unicode__(self):
return '%s' % self.name
class Meta:
ordering = ['-name',]

class Hand(models.Model):
player = models.ForeignKey(Player)
date_created = models.DateTimeField('Date',default=datetime.datetime.now)
date_changed = models.DateTimeField('Date',default=datetime.datetime.now)
round = models.IntegerField("Runde", blank=True, null=True)
points_round = models.IntegerField("Points this round", blank=True, 
null=True)
phase = models.IntegerField("Phase",blank=True,null=True)
points_partie = models.IntegerField("All Points",blank=True, null=True)
def __unicode__(self):
return "%s - %s - %s" % (self.player, self.rount, self.date_created)
class Meta:
ordering = ['player', '-round']

class Partie(models.Model):
player = models.ManyToManyField(Player)
hand = models.ManyToManyField(Hand)
date_created = models.DateTimeField('Datum',default=datetime.datetime.now)
def __unicode__(self):
return '%s' % self.date_created
class Meta:
ordering = ['date_created']
def get_phase(self):
phase = Partie.objects.filter(spieler=self.spieler).count()
return phase


In "get_phase" in the Partie model i want to use "round" and points_round" to 
calculate in which phase the player is.

In short: I want to be able to do:
phase_raw = Partie.objects.filter(player=self.player, partie=self.id, 
round=self.round, points_round__lte=9).count()

I know that this does not work, it would work for the two mentioned fields if i 
put the function into the Hand-Model, but
then i miss the "partie.id" field.

Any hints are welcome...

Best regards,
michael





-- 
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/20131108190700.GB15281%40homer.mm.
For more options, visit https://groups.google.com/groups/opt_out.


ImproperlyConfigured DJANGO_SETTINGS_MODULE error when migrating from 1.5.1 to 1.6

2013-11-08 Thread Brian DeWeese
I'm using Apache 2.4 and Python 2.6.8.  We have several different virtual 
hosts and the DJANGO_SETTINGS_MODULE is defined within each virtual host. 
 However, the wsgi file gets loaded before the settings.py file.  This 
works fine under Django 1.5.1 as settings aren't referenced from within the 
wsgi.  But with 1.6 it does get referenced and therefore raises an 
ImproperlyConfigured error.  Does anyone have any suggestions to help fix 
this issue?  Is there anyway I can get the settings module to load before 
the wsgi module?

Brian DeWeese


-- apache.conf --

WSGIScriptAlias / /opt/ecn/www/web-sites/wsgi/foo.wsgi

Allow from all


WSGIDaemonProcess mysite1 display-name=%{GROUP} processes=10


ServerName mysite1.foo
SetEnv DJANGO_SETTINGS_MODULE mysite1.settings
WSGIProcessGroup mysite1



-- output --
[Fri Nov 08 13:24:02.120637 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] mod_wsgi (pid=20169): Target WSGI script 
'/opt/ecn/www/web-sites/wsgi/foo.wsgi' cannot be loaded as Python module.
[Fri Nov 08 13:24:02.120703 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] mod_wsgi (pid=20169): Exception occurred processing WSGI 
script '/opt/ecn/www/web-sites/wsgi/foo.wsgi'.
[Fri Nov 08 13:24:02.120735 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] Traceback (most recent call last):
[Fri Nov 08 13:24:02.120767 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192]   File "/opt/ecn/www/web-sites/wsgi/foo.wsgi", line 8, in 

[Fri Nov 08 13:24:02.120879 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] from django.core.handlers import wsgi as django_wsgi
[Fri Nov 08 13:24:02.120901 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192]   File "/opt/ecn/www/Django/django/core/handlers/wsgi.py", 
line 11, in 
[Fri Nov 08 13:24:02.121020 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] from django.core.handlers import base
[Fri Nov 08 13:24:02.121048 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192]   File "/opt/ecn/www/Django/django/core/handlers/base.py", 
line 12, in 
[Fri Nov 08 13:24:02.121186 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] from django.db import connections, transaction
[Fri Nov 08 13:24:02.121215 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192]   File "/opt/ecn/www/Django/django/db/__init__.py", line 
83, in 
[Fri Nov 08 13:24:02.121314 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] signals.request_started.connect(reset_queries)
[Fri Nov 08 13:24:02.121343 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192]   File 
"/opt/ecn/www/Django/django/dispatch/dispatcher.py", line 88, in connect
[Fri Nov 08 13:24:02.121489 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] if settings.DEBUG:
[Fri Nov 08 13:24:02.121520 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192]   File "/opt/ecn/www/Django/django/conf/__init__.py", line 
54, in __getattr__
[Fri Nov 08 13:24:02.121628 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] self._setup(name)
[Fri Nov 08 13:24:02.121656 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192]   File "/opt/ecn/www/Django/django/conf/__init__.py", line 
47, in _setup
[Fri Nov 08 13:24:02.121690 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] % (desc, ENVIRONMENT_VARIABLE))
[Fri Nov 08 13:24:02.121729 2013] [:error] [pid 20169] [remote 
127.0.0.1:40192] ImproperlyConfigured: Requested setting DEBUG, but 
settings are not configured. You must either define the environment 
variable DJANGO_SETTINGS_MODULE or call settings.configure() before 
accessing settings.


-- 
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/c9f822e5-2993-4fce-9f9f-bbd0bef43dd2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Message Framework fails on Django 1.6

2013-11-08 Thread Christian Schmitt
Hello, currently I try to use the Django Message Framework, but it will 
always fail with:

> You cannot add messages without installing 
django.contrib.messages.middleware.MessageMiddleware

My middleware, etc:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages"
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'south',
'kombu.transport.django',
'djcelery',
...
)

-- 
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/34638999-f278-44d1-bc7a-de05fb3aeb84%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Odd behaviour from prefetch_related since upgrading to 1.6

2013-11-08 Thread Tim Dawborn
After upgrading to 1.6 yesterday, our production instance is exhibiting 
some odd behaviour with prefetch_related.

As the example below shows, when using prefetch_related on the foreign 
field (viewed_cm), the returned instance apparently does not have this 
foreign field set, even though the earlier filter on the queryset asserted 
it had to exist. 

>>> cb = 
user.coursebookmark_set.filter(viewed_cm__course__type=course_type).prefetch_related('viewed_cm').latest('viewed_at')
>>> cb.viewed_cm
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/ubuntu/app/ve-web/local/lib/python2.7/site-packages/django/db/models/fields/related.py",
 
line 314, in __get__
"%s has no %s." % (self.field.model.__name__, self.field.name))
DoesNotExist: CourseBookmark has no viewed_cm.
>>>

When prefetch_related is excluded, everything operates as expected.

>>> cb = 
user.coursebookmark_set.filter(viewed_cm__course__type=course_type).latest('viewed_at')
>>> cb.viewed_cm

>>>

Has anyone else experienced anything like this before? I can't seem to 
replicate it not on production.

-- 
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/17df129b-3ce0-4909-851e-3553081c7e88%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Announcing native Chameleon template engine support in Django

2013-11-08 Thread Kevin
Hello Django users!

  Today I sat down and wrote a native template Loader for Chameleon support 
in Django.  For those not familiar with this template engine, it was used 
in the previously infamous Zope and later Plone web frameworks.  It uses 
mostly XHTML formatting and documentation generation, and is supposedly 
very fast!  You can find the project over on my BitBucket page here:

https://bitbucket.org/kveroneau/django-chameleon-templates

  The README file explains it's usage, and it also contains some example 
templates and a standard Django view to see it in action.  The project 
itself has drop-in replacements for Django's own filesystem.Loader and 
app_directories.Loader, so using it with your existing Django projects 
couldn't be easier.  On top of these drop-in replacement, it has another 
Loader which instead of using TEMPLATE_DIRS like filesystem.Loader does, it 
uses another settings variable called CHAMELEON_TEMPLATES, which uses the 
exact same format.

  This project can for example help those moving from either Pyramid or a 
Zope/Plone solution over to Django.  As it uses the Django API natively, 
including it's context variables.  Furthermore, I also included Django's 
URL Reversal into Chameleon, so you can still properly generate your URLs 
like normal.  There is even a METAL macro to generate the CSRF_TOKEN 
construct.

  It does not support Django's native template tags and filters, but most 
of them aren't really needed.  If you have your own custom tags or filters, 
they will need to be recoded for Chameleon.  Adding new METAL macros takes 
on a similar method to how you add new template tags and filters.  You mere 
just create a macros/ directory inside your apps directory, and place .pt 
template files in there with the macro definitions.  The filename is used 
for the namespace inside the Chameleon template engine.  For example, say 
you have a macro file called example.pt with the following contents:


  Hello, World

To use this macro inside any other template in your project, you merely use 
either of the following:



- Or -


  Kevin


Wonderful, isn't it?  It makes working with Chamelon inside Django super 
simple and very Django-like.

I hope to soon add the ability to add new expressions into the template 
engine using some sort of registry, similar to how Django's own template 
engine adds new tags.

Let me know if you have any questions or comments about this Django app.

-- 
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/d691b6d2-a2e3-489f-b8e7-cd9a810e1d92%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django Insert edit update delete

2013-11-08 Thread Suvankar Roy
Hii All,

I am new to django please help me i want to an example project in this 
funtionality insert ,edit ,update delete data from database

Thanks
Suvankar




-- 
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/b1171e2c-36c5-495e-a6dd-879da79524d7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.