Re: Looking for experienced Django backend engineer

2022-07-03 Thread Tony Wong
Just forward to my teammate.
Good luck

On Sun, Jul 3, 2022 at 2:04 PM Mohammad Foysal  wrote:

>
> I have been working with python for the last two years. so I feel that I
> have some transferable skills to the position you are looking for. As a web
> application developer I have professional experience in various concepts of
> design and development.
>
> Please find enclosed my CV if you have any questions about my skills and
> experiences.
>
> Thank you for your time and consideration and I look forward to hearing
> from you soon.
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/veFA7lPluGg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/529F41A5-EF89-437E-9DEF-5A1F6909811C%40gmail.com
> 
> .
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/veFA7lPluGg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/529F41A5-EF89-437E-9DEF-5A1F6909811C%40gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJkRgPcO0jFp1hGWm1B763DyG4FWki5d43oYUz2m1%3DrtAzOA_w%40mail.gmail.com.


Re: Looking for experienced Django backend engineer

2022-07-02 Thread Tony Wong
>
>
> no part time considered,

sorry

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJkRgPfe73X91hzkjKJG%3DoB0q1cewvrpnks9yJZ8W%3DTB0%3D3iPA%40mail.gmail.com.


Re: Looking for experienced Django backend engineer

2022-07-02 Thread Tony Wong
Yes. Please
Good dev is always needed

Tony

On Sat, Jul 2, 2022 at 3:23 PM Sunday Ajayi  wrote:

> Hi Tony,
>
> Apologies for the late response.
> But if you still need a dev, I can still share my resume with you.
> Regards
> *AJAYI Sunday *
> (+234) 806 771 5394
> *sunnexaj...@gmail.com *
>
>
>
> On Fri, Feb 25, 2022 at 1:06 AM anderso...@gmail.com <
> anderson.wan...@gmail.com> wrote:
>
>> the domain name we bought is : datamall DOT ai.
>> In short, it help AI company to collect data they need ,and users get
>> paid for submitting the data.
>>
>> We treat all user uploaded data as NFT, thus we are also building our
>> public blockchain, but it might be centralized. Just like E-CNY, but we
>> plan to open all transaction history.
>>
>> Best wishes.
>> Tony
>>
>>
>> On Thursday, February 24, 2022 at 8:34:50 AM UTC-8 sunne...@gmail.com
>> wrote:
>>
>>> Hi Tony,
>>>
>>> You can share a mail of what the project is about. I may be interested.
>>>
>>> Regards
>>> *AJAYI Sunday *
>>> (+234) 806 771 5394 <+234%20806%20771%205394>
>>> *sunne...@gmail.com*
>>>
>>>
>>>
>>> On Thu, Feb 24, 2022 at 3:05 PM anderso...@gmail.com <
>>> anderso...@gmail.com> wrote:
>>>
>>>> Dear all,
>>>>
>>>> I'm a SDE, trying to start a startup company.
>>>> Since I learned Django before, so, I plan to use Django to build the
>>>> backend.
>>>>
>>>> But still, we need an backend engineer for our server.
>>>> Ping me if you are interestd.
>>>>
>>>> You can consider this as both freelancer, and stock if it is a good
>>>> match.
>>>>
>>>> Please send me your Resume.
>>>>
>>>> Best wishes.
>>>>
>>>> Tony Wong
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/f13e6f81-8490-4418-9d38-ad14ba17790fn%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/f13e6f81-8490-4418-9d38-ad14ba17790fn%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/f9dd0af2-8917-4379-8dec-0a583db3605cn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/f9dd0af2-8917-4379-8dec-0a583db3605cn%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/veFA7lPluGg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKYSAw3S%3D_pgQcdq9ZN1Ho1AhNi_z1N83aUFbRhwdrM45uyXUA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKYSAw3S%3D_pgQcdq9ZN1Ho1AhNi_z1N83aUFbRhwdrM45uyXUA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJkRgPc39kxCQdaewokTLLR52iq3Gj_gkqtHw%2BmPufcwUrtfNA%40mail.gmail.com.


Re: Stuck with Django on a Synology Diskstation

2021-07-14 Thread Tony Chang
Dear MH,

I also stuck here.

When I run *~*# python3 -m pip install mod-wsgi

I got the same error message: RuntimeError: The 'apxs' command appears not 
to be installed or is not executable. Please check the list of 
prerequisites in the documentation for this package and install any missing 
Apache httpd server packages.

I installed the Apache HTTP Server 2.4.43 from Synology DSM 6.2.4-25556 
Package Center. The apex is found in the system.

*~*# find / -iname apx*

/volume1/@appstore/Apache2.4/usr/local/bin/apxs

Could you share with me the way you got out from here?

Thanks

Best Regards,

Tony

MH 在 2020年3月3日 星期二下午9:01:31 [UTC+8] 的信中寫道:

> Dear nitish
>
> Thanks for your reply. I guess it is kind of a linux that Synology uses, 
> but it is different from other distros. So many advice on the internet 
> builds upon the ability to install packages via apt-get or ipkg, but both 
> are not available here. Somehow (really only somehow) I got entware/opkg 
> installed. But since then I have problems with the installations of most 
> packages there.
>
> Here are the results of my adaption of your suggested commands:
>
> /opt/bin# ./opkg find httpd
> /opt/bin#
>
> So, it seems there is no httpd24 on this repo.
>
> /opt/bin# ./opkg install apache
> Package apache (2.4.37-2) installed in root is up to date.
>
> /opt/bin# ./opkg install gcc
> Package gcc (7.4.0-5) installed in root is up to date.
>
> /opt/bin# sudo python3.5 -m pip install mod-wsgi
> Collecting mod-wsgi
>   Using cached mod_wsgi-4.7.1.tar.gz (498 kB)
> ERROR: Command errored out with exit status 1:
>  command: /usr/local/bin/python3.5 -c 'import sys, setuptools, 
> tokenize; sys.argv[0] = 
> '"'"'/tmp/pip-install-24inw61_/mod-wsgi/setup.py'"'"'; 
> __file__='"'"'/tmp/pip-install-24inw61_/mod-wsgi/setup.py'"'"';f=getattr(tokenize,
>  
> '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
> egg_info --egg-base /tmp/pip-install-24inw61_/mod-wsgi/pip-egg-info
>  cwd: /tmp/pip-install-24inw61_/mod-wsgi/
> Complete output (5 lines):
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/tmp/pip-install-24inw61_/mod-wsgi/setup.py", line 168, in 
> 
> 'missing Apache httpd server packages.' % APXS)
> RuntimeError: The 'apxs' command appears not to be installed or is not 
> executable. Please check the list of prerequisites in the documentation 
> for this package and install any missing Apache httpd server packages.
> 
> ERROR: Command errored out with exit status 1: python setup.py egg_info 
> Check the logs for full command output.
>
> I guess there are many problems, but this is just a start.
>
> Best regards
> MH
>
>
> On Monday, March 2, 2020 at 9:04:23 PM UTC+1, MH wrote:
>>
>> Hi there
>>
>> I am rather a newbie, but after some problems I got django installed on 
>> my Synology Diskstation. So, I ignored many other problems and am very 
>> happy that I built my very first, very simple app. And now I would like to 
>> move it from the development stage to the production stage. Obviously I 
>> should make a change to a distinct webserver. Synology offers nginx and 
>> apache 2.4. I installed both. And now I do not really know how to proceed. 
>> Out there, there are many instructions to use something called mod-wsgi. 
>> But I cannot install this from the package center of the Diskstation.
>>
>> I also tried to get opkg working. And this did not turn out so well, too. 
>> Most packages return an error, when I try to install something. Before this 
>> gets too elusive, I would ask you for guidance and then I can provide you 
>> with the following error messages.
>>
>> Best regards
>> MH
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/37c87088-0375-4c7a-b490-c7e21799cfa5n%40googlegroups.com.


Not raising exception when using form_class in generic CreateView

2018-02-11 Thread Tony
Hi, I am using a package called Django Embed Video 
 for my project. It comes 
with a EmbedVideoField for the model and validation for the URL which 
checks whether the URL is Youtube or Vimeo.
It raises exceptions when using generic create view without using 
customised form(form_class). However, when I use a customised form because 
I want to customise the widgets and css classes, it doesn't raise any 
exceptions. Why is that? Is there a way get the exceptions working with 
form_class?

Another thing is that the data is saved to the db which I can see in Django 
admin. But it is not included in the generic list view. Why?

*models.py*

from django.db import models

from embed_video.fields import EmbedVideoField


Class Video(models.Model):

   title = models.CharField(max_length=30)

   description = models.TextField(blank=True)

   url = EmbedVideoField(verbose_name=‘video’)



*views.py*

from django.views.generic.edit import CreateView

from django.views.generic.list import ListView


class VideoCreate(CreateView):

   model = Video

   form_class = NewVideoForm

class VideoList(ListView):

   model = Video

   ordering = ["-created"]


*forms.py*

from django import forms

from .models import Video


class NewVideoForm(forms.ModelForm):

   description = forms.CharField(widget=forms.Textarea(),

   required=False,

   max_length=4000,

   help_text='The max length of the text is 
4000.')

   url = forms.URLField(label='video', help_text='Please enter a Youtube or 
Vimeo link.')


class Meta:

   model = Video

   fields = ['title', 'description', 'url']

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/036a9a78-960b-44f0-87ca-795168629785%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to test get_success_url in CreateView in Django

2018-02-07 Thread Tony


I am trying to write a test for the get_success_url method in a CreateView, 
to make sure it redirects to the newly created page. But the response 
status code is 200 instead of 302 as I expected.

views.py

class BlogCreate(CreateView):
model = Blog
fields = [‘author’, 'title', ’post’]
def get_success_url(self):
return reverse_lazy('blog:blog-detail', kwargs={'slug': 
self.object.slug})
class BlogList(ListView):
model = Blog
ordering = ["-created"]

class BlogDetail(DetailView):
model = Blog

config/urls.py

from django.conf.urls import include, url

urlpatterns = [
url(r'^blog/', include('blog.url', namespace='blog')),

blog/urls.py

from django.conf.urls import urlfrom .views import BlogCreate, BlogList, 
BlogDetail, BlogEdit, BlogDelete


urlpatterns = [
url(r'^(?P[-\w]+)/$', BlogDetail.as_view(), name='blog-detail'),
url(r'^(?P[-\w]+)/edit$', BlogEdit.as_view(), name='blog-edit'),
url(r'^(?P[-\w]+)/delete$', BlogDelete.as_view(), name='blog-delete'),
url(r'^new$', BlogCreate.as_view(), name='blog-create'),
url(r'^$', BlogList.as_view(), name='blog-list'),]

tests.py

class BlogCreateTest(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='john', password='123')

def test_create_success_url(self):
post = {‘author’: self.user,
'title': ‘new blog’,
‘article’: ‘text’,
}

url = reverse_lazy('blog:blog-create')

success_url = reverse_lazy('blog:blog-detail', 
kwargs={'slug':'new-blog'})
response = self.client.post(url, post)

self.assertEqual(response.status_code, 302)
self.assertRedirects(response, success_url)

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9521294e-a64e-4015-a3b7-9bf1d34c3cd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Let users either upload a file or provide an URL to a file

2018-01-17 Thread Tony
Thank you so much. I will give it a go.

On Wednesday, January 17, 2018 at 4:48:24 PM UTC+1, Matemática A3K wrote:
>
>
>
> On Wed, Jan 17, 2018 at 11:53 AM, Tony <bitbith...@gmail.com 
> > wrote:
>
>> I would like to let users either upload a video file(to AWS S3) or 
>> provide an URL to a video, e.g. Youtube/Vimeo.
>>
>>
>> I found a similar question for Rails: Rails: upload a file OR store a url 
>> <https://stackoverflow.com/questions/13547724/rails-upload-a-file-or-store-a-url>
>>
>>
>>
>> <https://stackoverflow.com/questions/13547724/rails-upload-a-file-or-store-a-url>
>>
>> But how do I do that in Django(1.11)?
>>
>>
>> Should I create 2 separate models, or model inheritance with abstract 
>> model, let users choose what they want to do in the frontend, then display 
>> the appropriate form?
>>
>> class VideoModel(models.Model):
>> title = models.CharField(max_length=200)
>> post_by = models.OneToOneField(settings.AUTH_USER_MODEL)
>> created = models.DateTimeField(auto_now_add=True)
>> modified = models.DateTimeField(auto_now=True)
>>
>> class Meta:
>> abstract = True
>> class VideoFile(VideoModel):
>> video = models.FileField(upload_to='uploads/')
>> class Videolink(VideoModel):
>> URL = URLField(max_length=200)
>>
>>  
>
>> Would it be better if there is only 1 model with both a FileField and 
>> URLField.
>>
> IMO, yes, indeed 
>
>> They are both set to blank = true. Put a message on the page, saying 
>> either upload a file or provide a Youtube link. In the backend, check the 
>> request.POST whether one of these fields is filled in, if not, render the 
>> form again with an error message.
>>
> class VideoModel(models.Model):
> title = models.CharField(max_length=200)
> post_by = models.OneToOneField(settings.AUTH_USER_MODEL)
> created = models.DateTimeField(auto_now_add=True)
> modified = models.DateTimeField(auto_now=True)video = 
> models.FileField(upload_to='uploads/', blank=True, null=True)
> url = URLField(max_length=200, blank=True, null=True)
>
> def clean(self):
>
> super().clean()
>
> if not self.url and not self.video:
>
>  raise(ValidationError({"url": "Both url and video can't be 
> null"})
>
>  def get_video_url(self):
>
>  return(url if self.url else self.video.url)
>
>  
>  This is a way of doing it. If you use a ModelForm, then it will show the 
> error message automatically. You can add some javascript for showing only 
> the one that was chosen. You should have for convenience a function or 
> method that return the url for the video independently of the source.
>
>>
>> Which one is better to handle such situation? Or they are equally 
>> horrible? I couldn't think of a third option.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/31186b81-e108-47f9-8594-a140dcad3097%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/31186b81-e108-47f9-8594-a140dcad3097%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cec10a55-7503-449a-b9d2-c88d5e2e84b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Let users either upload a file or provide an URL to a file

2018-01-17 Thread Tony
Thank you so much. I will give that go.


On Wednesday, January 17, 2018 at 4:48:24 PM UTC+1, Matemática A3K wrote:
>
>
>
> On Wed, Jan 17, 2018 at 11:53 AM, Tony <bitbith...@gmail.com 
> > wrote:
>
>> I would like to let users either upload a video file(to AWS S3) or 
>> provide an URL to a video, e.g. Youtube/Vimeo.
>>
>>
>> I found a similar question for Rails: Rails: upload a file OR store a url 
>> <https://stackoverflow.com/questions/13547724/rails-upload-a-file-or-store-a-url>
>>
>>
>>
>> <https://stackoverflow.com/questions/13547724/rails-upload-a-file-or-store-a-url>
>>
>> But how do I do that in Django(1.11)?
>>
>>
>> Should I create 2 separate models, or model inheritance with abstract 
>> model, let users choose what they want to do in the frontend, then display 
>> the appropriate form?
>>
>> class VideoModel(models.Model):
>> title = models.CharField(max_length=200)
>> post_by = models.OneToOneField(settings.AUTH_USER_MODEL)
>> created = models.DateTimeField(auto_now_add=True)
>> modified = models.DateTimeField(auto_now=True)
>>
>> class Meta:
>> abstract = True
>> class VideoFile(VideoModel):
>> video = models.FileField(upload_to='uploads/')
>> class Videolink(VideoModel):
>> URL = URLField(max_length=200)
>>
>>  
>
>> Would it be better if there is only 1 model with both a FileField and 
>> URLField.
>>
> IMO, yes, indeed 
>
>> They are both set to blank = true. Put a message on the page, saying 
>> either upload a file or provide a Youtube link. In the backend, check the 
>> request.POST whether one of these fields is filled in, if not, render the 
>> form again with an error message.
>>
> class VideoModel(models.Model):
> title = models.CharField(max_length=200)
> post_by = models.OneToOneField(settings.AUTH_USER_MODEL)
> created = models.DateTimeField(auto_now_add=True)
> modified = models.DateTimeField(auto_now=True)video = 
> models.FileField(upload_to='uploads/', blank=True, null=True)
> url = URLField(max_length=200, blank=True, null=True)
>
> def clean(self):
>
> super().clean()
>
> if not self.url and not self.video:
>
>  raise(ValidationError({"url": "Both url and video can't be 
> null"})
>
>  def get_video_url(self):
>
>  return(url if self.url else self.video.url)
>
>  
>  This is a way of doing it. If you use a ModelForm, then it will show the 
> error message automatically. You can add some javascript for showing only 
> the one that was chosen. You should have for convenience a function or 
> method that return the url for the video independently of the source.
>
>>
>> Which one is better to handle such situation? Or they are equally 
>> horrible? I couldn't think of a third option.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/31186b81-e108-47f9-8594-a140dcad3097%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/31186b81-e108-47f9-8594-a140dcad3097%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/04d21929-59cb-4c18-b8ae-118cc92aaa4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Let users either upload a file or provide an URL to a file

2018-01-17 Thread Tony
 

I would like to let users either upload a video file(to AWS S3) or provide 
an URL to a video, e.g. Youtube/Vimeo.


I found a similar question for Rails: Rails: upload a file OR store a url 





But how do I do that in Django(1.11)?


Should I create 2 separate models, or model inheritance with abstract 
model, let users choose what they want to do in the frontend, then display 
the appropriate form?

class VideoModel(models.Model):
title = models.CharField(max_length=200)
post_by = models.OneToOneField(settings.AUTH_USER_MODEL)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)

class Meta:
abstract = True
class VideoFile(VideoModel):
video = models.FileField(upload_to='uploads/')
class Videolink(VideoModel):
URL = URLField(max_length=200)

Would it be better if there is only 1 model with both a FileField and 
URLField. They are both set to blank = true. Put a message on the page, 
saying either upload a file or provide a Youtube link. In the backend, 
check the request.POST whether one of these fields is filled in, if not, 
render the form again with an error message.


Which one is better to handle such situation? Or they are equally horrible? 
I couldn't think of a third option.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/31186b81-e108-47f9-8594-a140dcad3097%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I pass the CSRF token when using a jQuery post

2017-11-09 Thread Tony King

Thanks Gourav,

I have it working now and I can even understand it, which is even better.  
For anyone interested my revised working solution is below.

I'm sure it would be better practice putting the token into the headers as 
described in the documentation and elsewhere but I could not get it to work.


{% load static %}




https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";>



{% csrf_token %}

{{ hdr1 }}




{% if my_apps_list %}
{% for my_apps in my_apps_list %}





$("#app{{ forloop.counter }}").click( function() {
document.getElementById('hdr_1').innerHTML = 'Hello World!';
$.ajax({
url : "{% url 'launch' %}",
type: "POST",
data: { csrfmiddlewaretoken: document.getElementsByName(
'csrfmiddlewaretoken')[0].value,
appname: '{{ my_apps.app_name }}',
apppath: '{{ my_apps.app_path }}',
appexe: '{{ my_apps.app_exe }}',
appargs: '{{ my_apps.app_args }}',
appusr: '{{ my_apps.app_user }}',
apppwd: '{{ my_apps.app_pwd }}',
applook4: '{{ my_apps.app_wait4 }}',
appdelay: '{{ my_apps.app_delay }}',
appkeys: '{{ my_apps.app_keys }}'},
dataType : "json",
success: function( msg ){
document.getElementById('appstatus').innerHTML = msg;
}
});
});


{% endfor %}






{% else %}
No applications are available.
{% endif %}



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1bc91f14-bd24-4c84-929a-ad6302cf7709%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: static files in production

2017-11-08 Thread Tony King

Ok, I've found a solution here 

 which 
allows the serving of static files from within the project file folder 
structure as gathered by collectstatic.  I now see that the FastCGI Handler 
required for the project would interfere with the serving of static files.

Although marginally less convenient, I've also found that putting the 
static files in a folder outside of the project folder and pointing 
STATIC_ROOT to that folder is also an option i.e.

\inetpub\wwwroot\projectfolder\
\inetpub\wwwroot\django-staticfiles\

STATIC_ROOT = 'C:/inetpub/wwwroot/DjangoProjects/static'



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bfa7b2da-43a3-486f-ae87-d910275e7f0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: static files in production

2017-11-08 Thread Tony King


> Thanks.  The diagram clarified what I'd already thought to a degree, 
> although I'd gotten confused by the warning in the documentation for 
> STATIC_ROOT, which says 
>

"
This should be an initially empty destination directory for collecting your 
static files from their permanent locations into one directory for ease of 
deployment; it is *not* a place to store your static files permanently. You 
should do that in directories that will be found by staticfiles 
<https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/>’s finders 
<https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-STATICFILES_FINDERS>,
 
which by default, are 'static/' app sub-directories and any directories you 
include in STATICFILES_DIRS 
<https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-STATICFILES_DIRS>
).
"

 I've set the variables in my settings.py;
STATIC_ROOT = "C:/inetpub/wwwroot/shopfront/static/"
STATIC_URL = '/static/'

I've added 'django.contrib.staticfiles', to my INSTALLED_APPS

> I've run the collectstatic and it did indeed put my handful of static 
files in \static\ grouped into their respective folders.

I've even added  the STATICFILES_FINDERS to my settings.py

STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.DefaultStorageFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

When I view the source of my page, I can see the url built from "{% static 
my_apps.app_icon %}" resolves to /static/images/filename.png

To be sure, I wasn't going totally mad I added the following to my urls.py 
and re-enabled DEBUG

from django.conf import settingsfrom django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...] + static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)


and low and behold, it worked just fine but I obviously cannot leave it 
like that.

Having gone through the tutorial, I thought Django would be a great tool 
but I seem to be struggling with the most simple of things and I've barely 
started this project, I'm just trying to test out some basics including the 
deployment.

Kind regards,

  Tony

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4dd09450-11d0-49da-b21e-dae4856752cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


static files in production

2017-11-07 Thread Tony King

Hi again,

I'm having to deploy my project using IIS 8.5 as this all I have access too 
and I've been relatively successful, however, my static image files are not 
displaying in the way they did in the development environment.

I've tried adding what I believe to be the recommended settings but I'm 
still not getting any images too load.

In an almost desperate attempt to understand the search path logic, I've 
ended up with several static folders in my folder structure and still I do 
not have any images.

The attached file includes a screen shot of the settings.py and folder 
structure, which I'm hoping will be useful.

Can someone please help?

Kind regards,

  Tony

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eae9ab3b-8a2b-49ae-ae24-c837545af7ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I pass the CSRF token when using a jQuery post

2017-11-07 Thread Tony King

Hi,

I thought I'd finally understood this but it seems I have not and I've 
spent far too much time trying to do it myself.

I have a view rendering to the template below, which is displaying a number 
of buttons that when clicked will execute another Python function in the 
views.py.  This works fine if I disable the CSRF protection but as I've 
read this is not good practice, I'm desperately trying to get the token 
included in POST request.  I thought I'd finally cracked it yesterday 
having found the sample code in the documentation and indeed it appeared to 
work until first I tried my project in a different browser and then 
subsequently cleared the cache of Chrome.

What am I doing wrong here?

I've not included the views.py as I'm assuming the issue is in the 
JavaScript.


index.html
{% load static %}




https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";>



function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
$.ajaxSetup({
beforeSend: function(xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
});




{{ hdr1 }}




{% if my_apps_list %}
{% for my_apps in my_apps_list %}





$("#app{{ forloop.counter }}").click( function() {
$.post("{% url 'launch' %}",
{'appname': '{{ my_apps.app_name }}',
'apppath': '{{ my_apps.app_path }}',
'appexe': '{{ my_apps.app_exe }}',
'appargs': '{{ my_apps.app_args }}',
'appusr': '{{ my_apps.app_user }}',
'apppwd': '{{ my_apps.app_pwd }}',
'applook4': '{{ my_apps.app_wait4 }}',
'appdelay': '{{ my_apps.app_delay }}',
'appkeys': '{{ my_apps.app_keys }}'
}, function (msg) {
document.getElementById('appstatus').innerHTML = msg;
});
});


{% endfor %}






{% else %}
No applications are available.
{% endif %}



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/36f50839-ded6-4ea1-8539-afa60041fe30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: My first project - URL issue?

2017-11-02 Thread Tony King

>
> Ok, well I've solved my immediate problem but clearly need to learn more 
> about JavaScript, jQuery and CSRF tokens.
>

But for anyone with a similar URL issue, I did the following;

Added an appname setting to my urls.py
appname = 'shopfront'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^launch_app/$', views.launch_app, name='launch'),
]

 Modified the $.post function to use the URL name mapping which as I 
expected meant I now have single function for handling the application 
launch.
{% for my_apps in my_apps_list %}
{{ my_apps.app_name }}

$("#app{{ forloop.counter }}").click( function() {
$.post("{% url 'launch' %}", {appname: '{{ my_apps.app_name }}'}, function 
() {});
});

{% endfor %}

 Initially this moved me onto CSRF token errors but having temporarily 
> disabled this, my function has been executed.  Onto the next issueCSRF 
> tokens..
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82055563-01b3-4f46-a519-a1c5e15a1006%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


My first project - URL issue?

2017-11-02 Thread Tony King

Hi,

I've started my first real project (django v1.11.4 and Python 3.6.2) and 
I'm probably trying to run before I'm ready, but anyway I'm here.  I'm 
essentially trying to create a front-end menu, that will eventually launch 
and log-on to either a local application or another web-site.  This latter 
part I have managed in Python but not within a Django project.

Anyway, I have a model which hold details of my 3rd party applications and 
I've created an index view and template that will display a series of 
buttons as below.

I want to execute another function when I click on one of the buttons, the 
current idea is a function per button but I expect this to evolve into a 
single function, I'm just trying to get something to work at the moment.  
I've found an example, involving jQuery, which I've attempted to adapt but 
I don't think I'm getting the URL right as nothing happens when I click one 
of my buttons.  I know the click event works, because if I leave in the 
$("h1").hide();, it works just fine.  So, I'm thinking I have the URL 
syntax wrong but as nothing happens, I'm not sure if I have any of the 
$.post quite right, although I receive no errors.

Having followed the tutorial I have stuck to the recommended folder layout 
as below;

project folder \
  *project files*
  shopfront \
  templates \
static \
jquery-3.2.1.min.js
  index.html
  urls.py
  views.py

Despite numerous edits, I don't seem to be getting anywhere - can someone 
tell me what I have wrong?

I'm going to need to create a front-end log-in page to this project, so if 
someone could point me in the right direction on doing this I would be 
grateful for that also.

urls.py
from django.conf.urls import url

from . import views

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^launch_app1/$', views.launch_app1, name='launch1'),
url(r'^launch_app2/$', views.launch_app2, name='launch2'),
url(r'^launch_app3/$', views.launch_app3, name='launch3'),
url(r'^launch_app4/$', views.launch_app4, name='launch4'),
url(r'^launch_app5/$', views.launch_app5, name='launch5'),
]


views.py
from django.shortcuts import render

from django.http import HttpResponse

from .models import my_apps

# Create your views here.
def index(request):
'''
Index page content function
'''
context = {'my_apps_list': my_apps.objects.all(), 'hdr1':'Application List'}
return render(request, 'shopfront/index.html', context)

def launch_app1(request):
'''
Launch application function
'''
# context = {'my_apps_list': my_apps.objects.all(), 'hdr1':'Application 
List - '+request['appname']+' Launched'}
context = {'my_apps_list': my_apps.objects.all(), 'hdr1':'Application List 
- Application 1 Launched'}
return render(request, 'shopfront/index.html', context)
# return HttpResponse(request['msg'])

def launch_app2(request):
'''
Launch application function
'''
return HttpResponse(request['appname'])

. 


index.html
{% load static %}




https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";>



var csrf_token = '{% csrf_token %}';



$("body").bind("ajaxSend", function(elm, xhr, s) {
if (s.type == "POST") {
xhr.setRequestHeader('X-CSRF-Token', csrf_token);
}
});


{{ hdr1 }}

{% if my_apps_list %}

{% for my_apps in my_apps_list %}
{{ my_apps.app_name }}

$("#app{{ forloop.counter }}").click( function() {
// $("h1").hide();
$.post("launch_app{{ forloop.counter }}/", {appname: '{{ my_apps.app_name 
}}'}, function () {});
});

{% endfor %}

{% else %}
No applications are available.
{% endif %}


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8a38901b-1bf4-4337-b3e7-309b991cc727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial part 4 - get_queryset

2017-10-17 Thread Tony King

Thanks James, that is a big help and I'm sure the link will provide some 
worthwhile extra reading, although I've clearly got a lot to learn anyway.

Regards,

  Tony

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/26c60649-b423-47f7-b528-3d23eaaf6726%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


widget form

2016-03-19 Thread Tony Peña
hi,

if i got a form for example with 2 charfield, and bottom a check box 
how can i do if that checkbox is true appears the next other 2
charfields ?(maybe hide)
this exist with some function on django-admin ?

thanxs


-- 
perl -le 's ffSfs.s fSf\x54\x6F\x6E\x79 \x50\x65\x6e\x61f.print'

Secure email with PGP 0x8B021001 available at https://pgp.mit.edu

Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALBaCdvsUseRk%3DAb1ES2z9B9xvBOzO_nL%3DX2N4Ai6-VuGOE0BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model or Form class

2016-03-12 Thread Tony Flury
You can use forms.Form when you want to build a custom form which isn't 
directly connected to a model on the database. For instance one use for a 
forms.Form is where you are collecting data which will be stored into 
attributes on different models. 

The documentation I think uses forms.ModelForn which is ideal for building 
forms which directly relate to models in your 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e8c324b-2c9b-42b9-8076-8892f0bf8c59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Showing BooleanField checkbox on left

2016-01-15 Thread Tony Flury


On Thursday, 14 January 2016 17:55:41 UTC, Sayse wrote:
>
> Yea I've heard of it. Have they managed to achieve this? I'd be interested 
> to see how they've done it if so... 
>
> I was hoping to find a way to do this with native django if possible 
>

One way that might work is to subclass the CheckboxInputWidget, and in the 
new widget overide the render method - but there looks like a lot of deep 
Django Magic in that method : 
https://docs.djangoproject.com/en/1.9/_modules/django/forms/widgets/#CheckboxInput

Or - look at changing the Form render method - again involving lots of 
Django Magic

Or - Accept that you can't do that (as you are trying to including one 
widget (Input) inside the HTML tags for another (Label), and compromise 
with manual ordering and being more explicit in your form : For instance 
using {{ field.label_tag }} Example here : 
https://docs.djangoproject.com/en/1.9/topics/forms/#looping-over-the-form-s-fields

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b4b9f561-4bc2-434d-9cf7-8d5235de372f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why cannot delete attribute id of model?

2016-01-11 Thread Tony Flury
Stating the value of either the id or pk field to None is the recommended way 
to rest the primary key when you take a copy of a record, but Xudong wanted to 
delete the field entirely: which I don't understand. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/84c08106-fee8-43e3-94e0-ca578c894ba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why cannot delete attribute id of model?

2016-01-11 Thread Tony Flury
Why do you want to delete the id field. The idea of a primary key field is 
central to relational databases. If you to suppress the automatically generated 
primary key then you need to assign another field as the unique primary key: as 
far as I know that will prevent the id field being created. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/633880e3-05fe-434a-979d-8b28c4158bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Execute code which runs on the database only when the server is running - and doesn't need users to view pages.

2016-01-11 Thread Tony Flury
Andreas,

Thanks for your answer. Certainly it looks like running celery might alleviate 
the issue with threading stopping the management commands, but the problem with 
your suggestion lies with that flag. If My code was able to identify that the 
server is running to the point of being able to set the flag it would also know 
enough to start my background thread. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a65bcce5-6270-4c88-912c-afee49c85631%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Execute code which runs on the database only when the server is running - and doesn't need users to view pages.

2016-01-11 Thread Tony Flury
I have a small background task (executed by using threading.Timer) which I 
want to start up when the server starts, but doesn't need to start when a 
management command runs.

The background task performs operations on the database, so relies on 
importing the models etc.

I have tried using the App.ready hook introduced in Django 1.7, which was 
touted as correct way to do this, but the ready hook is executed during 
management commands as well, and then the management command fails to exit 
- due to the presence of the timer thread - and I don't want Management 
commands to execute this code in anyway.

What is the correct way to run code which uses the models and all the 
wonderful Django stuff, and which is executed only when the server runs 
(and not during a management command).

Currently the only way I can run management command is to comment out my 
timer start call, whenever I want to run management commands. This wont be 
an option when it comes to needing to execute management commands on the 
production server.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7632c40e-0855-453d-95f9-cb2f552ddd22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: filter in queryset

2015-09-13 Thread Tony Peña
thanxs so much... that works perfect.!

2015-09-13 11:19 GMT+02:00 James Schneider :

> Not sure if I'm following you 100%, but i think you can filter like this:
>>
>> return qs.filter(classi__prof=request.user)
>>
>> This would match the MAC to a class, and the class to a professor, and
>> the professor to request.user. Should return all of the MAC's that belong
>> to a class that request.user is a professor for, I believe.
>>
>>
> I was thinking on this, you might have to use
> qs.filter(classi__prof__prof=request.user) instead.
>
> -James
>
>
> --
> 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%2Be%2BciU5sVtPGvJsi66xBPxwow_ctQ3P-vrGkgm-JoEPNTQJYg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at https://pgp.mit.edu

Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001

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


filter in queryset

2015-09-12 Thread Tony Peña
Hi

need a help with this queryset problem
i got into my models.


models.py
-

class Classi(models.Model):
classi = models.CharField('Class Name', max_length='20', unique=True)
internet = models.BooleanField(default=None)

using Calssi can do:
create: A, B. C

class Prof(models.Model):
prof = models.ForeignKey(User)
classi = models.ManyToManyField(Classi)

i can create a simple User: teacher, and can belong to A, C  Classi

class MAC(models.Model):
classi = models.ForeignKey(Classi)
name = models.CharField('dev_name', max_length=64, default='unnamed',
null=True, blank=True)
mac = MACAddressField('MAC', blank=False, unique=True)
internet = models.BooleanField(default=None)

i create simple macs objects where those belongs to Classi

after that i got

admin.py


class ClassAdmin(admin.ModelAdmin):
 def get_queryset(self, request):
qs = super(ClassAdmin, self).get_queryset(request)
if request.user.is_staff and request.user.is_superuser:
return qs
return qs.filter(prof__prof=request.user)

with this I can see only Classi A and B if I logged as User with A and B
classrooms set it and that's ok

but:

i'm testing 4 macs:  Class A: 1mac ,   Class B: 2mac,   Class C: 1mac

when i define:

class MacAdmin(admin.ModelAdmin):
def get_queryset(self, request):
qs = super(MACAdmin, self).get_queryset(request)
if request.user.is_staff and request.user.is_superuser:
return qs
return qs.filter(classi_id__mac=request.user)

for make a test I create an user belogs to Class A and B so would be see 3
macs on list_display
but only got 1

on debug mode, qs variable i can see the 4 macs,   i need to know filter it
to get only that A and B because is filtered by user wich only belogs to A
and B class

thanxs

-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at https://pgp.mit.edu

Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001

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


limit insert rows into model database

2015-08-12 Thread Tony Peña
Hi
exist some settings to only insert X number of rows in a model?

django.db. (i guess, restrict 5 rows)   as simple way ?

or

setting directly into MySQL  ?

because, i override the save method to check if:

# models.py
class domain(model.Model):
...
max_accounts = models.IntegerField(default=2)


# admin.py

class UserAdmin(admin.ModelAdmin):
list_display = ('user', 'domain',  'max_account')
ordering = ('user',)

def save_model(self, request, obj, form, change):
max_accounts = domains.objects.all()
accounts = users.objects.all()
if  int(max_accounts.values()[0]['max_accounts']) >
accounts.count():
super(UserAdmin, self).save_model(request, obj, form, change)
else:
messages.error(request, "Impossible create more accounts.")

In this code .. the check works... but my problem is:

when account 1 and total is 2 is fine.. save in mysql
when account 2 and total is 2 is fine and save in mysq again
when account is 3 and total is 2 i got the error... not save (because the
logic is fine)

and
django admin output the error message BUT show the OK was successfull
inserted too
(as a fake insert) ...how can I omit the OK message.?

thanxs in advance

-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at https://pgp.mit.edu

Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001

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


Re: display readonly or not

2015-08-11 Thread Tony Peña
because i don't know how... that's why i ask :)

2015-08-11 11:17 GMT+02:00 Daniel Roseman :

> On Tuesday, 11 August 2015 06:24:32 UTC+1, Mike Dewhirst wrote:
>
>
>> There is a get_read_only() method in the admin.ModelAdmin class. It
>> normally returns self.readonly_fields but you can give it a callable.
>>
>>
>> https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields
>>
>> As well as defining any readonly fields (for everyone) you want
>> something like ...
>>
>> def ro_fields(self, request, obj=None):
>>  if obj is None or request.user.is_superuser:
>>  return self.readonly_fields
>>  else:
>>  return self.model._meta.get_all_field_names()
>>
>> ... then get_readonly_fields = ro_fields should make it happen like your
>> pseudocode.
>>
>> Mike
>>
>
> Why do you define a separate method, then alias to get_readonly_fields?
> Why not override the method directly?
> --
> Daniel.
>
> --
> 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/b43856c6-4e6f-435a-bee2-886110d2aa1a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at https://pgp.mit.edu

Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001

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


Re: display readonly or not

2015-08-11 Thread Tony Peña
hmmm.. not work

the field max_account must be modify for superuser not for the staff.

class VeximDomainAdmin(admin.ModelAdmin):
list_display = ('domain', 'enabled', 'avscan', 'spamassassin',
'max_accounts')
list_filter = ('enabled',)
exclude = ('uid', 'gid', 'pipe', 'maildir', 'blocklists', 'complexpass')
readonly_fields = ('max_accounts',)

def ro_fields(self, request, obj=None):
if obj is None or request.user.is_superuser:
return self.readonly_fields
else:
return self.model._meta.get_all_field_names()

get_readonly_fields = ro_fields


2015-08-11 7:23 GMT+02:00 Mike Dewhirst <mi...@dewhirst.com.au>:

> On 11/08/2015 7:25 AM, Tony Peña wrote:
>
>> hi
>>
>> i have this on my model.admin
>>
>> class MyDomainAdmin(admin.ModelAdmin):
>> Â  Â  list_display = ('domain', 'enabled', 'avscan', 'spamassassin',
>> 'max_accounts')
>> Â  Â  list_filter = ('enabled',)
>> Â  Â  exclude = ('uid', 'gid', 'maildir')
>>
>> # this part is my pseudo-code logic I want but i can't solved.
>> Â  Â  if not user.is_superuser
>> Â  Â  Â  Â  readonly_fields = ('max_accounts',)
>>
>>
> There is a get_read_only() method in the admin.ModelAdmin class. It
> normally returns self.readonly_fields but you can give it a callable.
>
>
> https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields
>
> As well as defining any readonly fields (for everyone) you want something
> like ...
>
> def ro_fields(self, request, obj=None):
> if obj is None or request.user.is_superuser:
> return self.readonly_fields
> else:
> return self.model._meta.get_all_field_names()
>
> ... then get_readonly_fields = ro_fields should make it happen like your
> pseudocode.
>
> Mike
>
>
>
> how can i set readonly for users staff? but normally modify for only
>> superusers?
>> --
>> Antonio Peña
>> Secure email with PGP 0x8B021001 available at https://pgp.mit.edu
>> <
>> https://pgp.mit.edu/pks/lookup?search=0x8B021001=index=on=on
>> >
>> Fingerprint: 74E6 2974 B090 366D CE71Â  7BB2 6476 FA09 8B02 1001
>>
>> --
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto: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/CALBaCdsUys33wv1n6tMaiKvEj%2BXcZRPytO_os9xNFW4ij0Vu0w%40mail.gmail.com
>> <
>> https://groups.google.com/d/msgid/django-users/CALBaCdsUys33wv1n6tMaiKvEj%2BXcZRPytO_os9xNFW4ij0Vu0w%40mail.gmail.com?utm_medium=email_source=footer
>> >.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/55C986EC.2030508%40dewhirst.com.au
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at https://pgp.mit.edu
<https://pgp.mit.edu/pks/lookup?search=0x8B021001=index=on=on>
Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001

-- 
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/CALBaCdshxP8Teq%2Bm9vhYhn3EaNR5VUxD%2BTkHCFqUCmXHxw%3D9-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


display readonly or not

2015-08-10 Thread Tony Peña
hi

i have this on my model.admin

class MyDomainAdmin(admin.ModelAdmin):
list_display = ('domain', 'enabled', 'avscan', 'spamassassin',
'max_accounts')
list_filter = ('enabled',)
exclude = ('uid', 'gid', 'maildir')

# this part is my pseudo-code logic I want but i can't solved.
if not user.is_superuser
readonly_fields = ('max_accounts',)

how can i set readonly for users staff? but normally modify for only
superusers?
-- 
Antonio Peña
Secure email with PGP 0x8B021001 available at https://pgp.mit.edu

Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001

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


Deploying Django, nginx , gunicorn, postgresql

2015-02-20 Thread Tony Kyriakidis
Hello, 

It's been a week now since the day i started trying to deploy a test blog 
application on digital ocean.
I tried everthing and if you go to the IP: http://188.166.62.146 you get a 
Welcome to Nginx page.
when i go to http://188.166.62.146:8001 i get a (400 Bad Request) error.

Here on Stack overflow i posted every detail. Please take a look at it.

http://stackoverflow.com/questions/28629112/502-bad-gateway-django-nginx-gunicorn-postgresql-virtualenv?noredirect=1#comment45560477_28629112


Thank in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f9f2ac6-0699-4ce6-812d-0ae8f3564854%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble changing from sqlite3 to postgres

2015-02-17 Thread tony . guil35
The error occurs during migration.
The following shows the complete traceback.
Thanks.

% python manage migrate
WFK: BASE_DIR= /home/bill/django/wfkprojs/proj1
WFK: STATIC_PATH= /home/bill/django/wfkprojs/proj1/app_1/static/
WFK: MEDIA_ROOT= /home/bill/django/wfkprojs/proj1/app_1/media_root/
WFK: MEDIA_URL= /media_root/
Operations to perform:
  Apply all migrations: contenttypes, app_1, sessions, auth, admin
Running migrations:
  Applying app_1.0003_auto_20141126_2333...Traceback (most recent call 
last):
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 
65, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column "date" cannot be cast automatically to 
type integer
HINT:  Specify a USING expression to perform the conversion.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python3.3/site-packages/django/core/management/__init__.py", 
line 385, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python3.3/site-packages/django/core/management/__init__.py", 
line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/usr/local/lib/python3.3/site-packages/django/core/management/base.py", 
line 288, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python3.3/site-packages/django/core/management/base.py", 
line 338, in execute
output = self.handle(*args, **options)
  File 
"/usr/local/lib/python3.3/site-packages/django/core/management/commands/migrate.py",
 
line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
  File 
"/usr/local/lib/python3.3/site-packages/django/db/migrations/executor.py", 
line 63, in migrate
self.apply_migration(migration, fake=fake)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/migrations/executor.py", 
line 97, in apply_migration
migration.apply(project_state, schema_editor)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/migrations/migration.py", 
line 107, in apply
operation.database_forwards(self.app_label, schema_editor, 
project_state, new_state)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/migrations/operations/fields.py",
 
line 139, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/schema.py", line 
473, in alter_field
self._alter_field(model, old_field, new_field, old_type, new_type, 
old_db_params, new_db_params, strict)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/schema.py", line 
626, in _alter_field
params,
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/schema.py", line 
99, in execute
cursor.execute(sql, params)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 
81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 
65, in execute
return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.3/site-packages/django/db/utils.py", line 
94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python3.3/site-packages/django/utils/six.py", line 
549, in reraise
raise value.with_traceback(tb)
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 
65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "date" cannot be cast 
automatically to type integer
HINT:  Specify a USING expression to perform the conversion.


On Tuesday, February 17, 2015 at 4:39:27 PM UTC-8, Joel Burton wrote:
>
> The error is probably in code you wrote that uses the date field. Can you 
> post the full traceback? That will let us see where the caller was that 
> created the problem.
>
> On Tuesday, February 17, 2015 at 3:13:30 PM UTC-5, tony@gmail.com 
> wrote:
>>
>> I have written a simple Django app (my first) that works with sqlite3 
>> database.
>> I want to change to postgres, but when I run the Django 1.7 migration 
>> utility  with the command
>> "python manage.py migrate"
>>
>> I get the error:
>> psycopg2.ProgrammingError: column "date" cannot be cast automatically 
>> to type integer
>>
>> Which is occuring in:
>>   File 
>> "/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py"

Trouble changing from sqlite3 to postgres

2015-02-17 Thread tony . guil35
I have written a simple Django app (my first) that works with sqlite3 
database.
I want to change to postgres, but when I run the Django 1.7 migration 
utility  with the command
"python manage.py migrate"

I get the error:
psycopg2.ProgrammingError: column "date" cannot be cast automatically 
to type integer

Which is occuring in:
  File 
"/usr/local/lib/python3.3/site-packages/django/db/backends/utils.py", line 
65, in execute
return self.cursor.execute(sql, params

I am not sure how to track down the problem.
I am running Slackware Linux.

My models.py file is as follows:


from django.db import models
import datetime

# Create your models here.

class Location(models.Model):

   class Meta:
  unique_together = ("lat", "lng")

   lat  = models.DecimalField(max_digits=8, decimal_places=5)
   lng  = models.DecimalField(max_digits=8, decimal_places=5)
   name = models.CharField(max_length=200,  unique=True)

   def __str__(self):
  return "%s: %d %d" % (self.name, self.lat, self.lng)

class Observation(models.Model):

   date = models.DateField()
   location = models.ForeignKey(Location)
   observer = models.CharField(max_length=50)
   temperature = models.FloatField(default=0.0)
   photo= models.ImageField(default="tower.jpg", 
upload_to="uploaded_photos")

   def __str__(self):
  return self.observer
=

The DATABASE part of my settings.py file is as follows
where I have commented-out the old sqlite3 part:

-
DATABASES = {

#   'default': {
#   # sqllite3
#   'ENGINE': 'django.db.backends.sqlite3',
#   'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#   }

   # For postgres:
#'django.db.backends.postgresql_psycopg2', 
# USER, PASSWORD, HOST also needed
# Inside postgres, "CREATE DATABASE database_name"

 'default': {
 'ENGINE': 'django.db.backends.postgresql_psycopg2',
 'NAME': 'app_1_db',
 'USER': 'bill',
 'PASSWORD': 'bill',
 'HOST': '127.0.0.1',
 'PORT': '5432',
 }

}


Please let me know if you have ideas.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b905e0f0-898b-4c6e-9141-a33987270476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attempting to setup Graphite (Django/Gunicorn) DJANGO_PATH not set and "no such table: auth user"

2014-03-12 Thread Tony Su

>
> Resolved although at the moment I don't have the answer to my specific 
> questions.
>
 
I found a working and maintained script for installing on Ubuntu.
I can't say how extraordinary it is to actually find a Graphite install 
script that sets up Django in working order
https://github.com/gdbtek/setup-graphite
 
Tony 

-- 
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/6541afb6-8d1c-413c-a248-545839602561%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Attempting to setup Graphite (Django/Gunicorn) DJANGO_PATH not set and "no such table: auth user"

2014-03-11 Thread Tony Su
Apache 2.4 on Ubuntu 13.10
 
First,
If anyone knows of a working install script to install Graphite on any 
distro preferably (but not critical) using Apache2.4, gunicorn and WSGI, 
I'd appreciate it.
I've been wending my way through a variety of undocumented and less 
documented issues that differ from the official documentation for a week 
now...
 
Thx,
Tony
 
I have 2 current questions:
 
Q - I strongly suspect that DJANGO_PATH is not set.
I've found documentation that suggests how it might be set from an 
interactive console on Windows
http://stackoverflow.com/questions/7479493/django-settings-module-is-undefined
But, I strongly suspect it should have been set already in a config script 
somewhere, but I can't seem to find it. For such a basic configuration, 
where would I expect to find it?
I've also tried to do the following from a console but it doesn't work
 
export PATH=$DJANGO_PATH:/usr/lib/python2.7/dist-packages/django/bin
 
 
*
Q - "no such table: auth user" 
I attempted to resolve running "manage.py rsync" and "django-admin.py 
rsync" as I've found in a few articles, but still SOL.
 
Error follows
 
DatabaseError at /composer/
no such table: auth_user
Request Method:  GET
Request URL:  http://localhost/composer/
Django Version:  1.5.4
Exception Type:  DatabaseError
Exception Value:  
no such table: auth_user
Exception Location: 
 /usr/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py in 
execute, line 362
Python Executable:  /usr/bin/python
Python Version:  2.7.5
Python Path:  
['/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
 '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
 '/opt/graphite/webapp']
Server time:  Mon, 10 Mar 2014 14:12:29 -0700
 
 

-- 
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/16e487ac-4ebd-4bf4-9568-17ae48730c53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Customize error messages for django-registration

2013-09-05 Thread Tony Lâmpada
Hi, I have a question about django-registration (
https://bitbucket.org/ubernostrum/django-registration), but I can't find 
their issue tracker or a mailing list for it, so I'll try mu luck here.

My application enables login via OpenID and login/password.

Some users "forget their password" on FS on try to reset it 
(here), 
but then they get the message:

The user account associated with this e-mail address cannot reset the 
> password.

 
With no further explanations.
(You can try and reset *my* password - just type my email (tonylampada at 
gmail dot com) there to see the error message.

I want to customize that message. A better message would be:

The user account associated with this e-mail address cannot reset the 
> password.
> This happens because the user account was created with an OpenID or OAuth 
> provider (tipically Google, Facebook, MyOpenID, etc). 

To see the login provider(s) associated with this account, take a look at 
> the user profile .


What is the easiest way to tell django-registration that?

Thanks!

PS: This issue on github: 
https://github.com/freedomsponsors/www.freedomsponsors.org/issues/191 (just 
in case you're feeling like making a pull request today :-))

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


Custom logging formatter issue

2013-07-17 Thread Tony D
I am attempting to eventually set up django logging via a third-party 
service. For this I am using python-json-logger and setting up an 
appropriate formatter in the LOGGING dictionary in settings.py.

I believe I have it set up correctly, but when the formatter is enabled the 
first page I get after starting the app is a white screen with no content. 
After that, I can get pages. In no case am I getting anything in the log in 
response to URL requests. I am specifically testing with 404s.

I've pared the formatter down to nothing (it just returns a static string) 
and the app still breaks when the formatter is specified.

My immediate goal is to log data in the appropriate format to the console 
and then add in the third-party logging.

Here is my LOGGING dictionary:

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'simple': {
'()': 'jsonlogger.JsonFormatter',
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console':{
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
}
},
'loggers': {
   'django': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
}
}
}

jsonlogger has been pared all the way down to:

import logging

class JsonFormatter(logging.Formatter):
def format(self, record):
return "THIS IS A LOG MESSAGE"

It is supposed to have a bit more, but I wanted to get the smallest code 
and still exhibit the issue.

When I start the app, my startup messages are preceded by:

THIS IS A LOG MESSAGE

If I comment out the '()' in 'simple', any 404 I generate is logged on the 
console:

WARNING Not Found: /fdsafdsafdaf

and I never get any white screens. As soon as the formatter is enabled, I 
get a white screen on first access and no log to the console.

Am I missing something obvious?
Why am I getting a white screen?
Why is there no log of what is going wrong?

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




Re: Django Chartit Installed, How do I run the demo???

2013-07-16 Thread Tony Guilin
BTW, I'm using http://chartit.shutupandship.com/docs/#how-to-use

On Tuesday, July 16, 2013 10:43:39 PM UTC-7, Tony Guilin wrote:
>
> I'm a complete noob.
>
> I've been able to go through the Djano tutorial with minimal issues.
>
> I successfully installed this according to:
> Installation¶ <http://chartit.shutupandship.com/docs/#installation>
>
> You can install Django-Chartit from PyPI. Just do
>
> $ pip install django_chartit
>
> You also need supporting JavaScript libraries. See the Required 
> JavaScript 
> Libraries<http://chartit.shutupandship.com/docs/#required-javascript-libraries>
>  section 
> for more details.
>
>
>
> *Now what???*
>

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




Django Chartit Installed, How do I run the demo???

2013-07-16 Thread Tony Guilin
I'm a complete noob.

I've been able to go through the Djano tutorial with minimal issues.

I successfully installed this according to:
Installation¶ 

You can install Django-Chartit from PyPI. Just do

$ pip install django_chartit

You also need supporting JavaScript libraries. See the Required JavaScript 
Libraries 
section 
for more details.



*Now what???*

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




Re: Writing your first Django app - Tutorial Question

2013-06-25 Thread Tony Guilin

>
>  you have missed 
>  from django.utils import timezone
>

That worked! Thanks.

P.S. I just copy and paste in Chrome (in Ubuntu)  and it picks up the 
formatting.

 

On Tuesday, June 4, 2013 4:10:23 PM UTC-7, Tony Guilin wrote:
>
> In the https://docs.djangoproject.com/en/1.5/intro/tutorial01/ tutorial 
> under the,
> Playing with the API
>
>
>
> section, I'm trying to go through the example in my python shell as 
> described.
>
>
> p = Poll(question="What's new?", pub_date=timezone.now())
>
> But I'm unable to get to next command "p.save()" because of the error 
> below.
>
>> tony@tonymachine:~/django_projects/mysite$ python manage.py shell
>> Python 2.7.3 (default, Aug 1 2012, 05:16:07)
>> [GCC 4.6.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> (InteractiveConsole)
>> >>> from polls.models import Poll, Choice
>> >>> Poll.objects.all()
>> []
>> >>> from django.utils import timezone
>> >>> p = Poll(question="What's new?", pub_date=timezone.now())
>> Traceback (most recent call last):
>>  File "", line 1, in 
>>  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
>> line 415, in __init__
>>  raise TypeError("'%s' is an invalid keyword argument for this function" 
>> % list(kwargs)[0])
>> TypeError: 'pub_date' is an invalid keyword argument for this function
>> >>>
>>
> Any guidance is appreciated.
>
>

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




Re: Anyone using django tabs ?

2013-06-20 Thread tony gair
The answer I think is no , ah well. 

On Thursday, 20 June 2013 09:28:39 UTC, tony gair wrote:
>
> I am trying django tabs for my site navigation and was wondering is I have 
> to list multiple tabs in the html file thats inherits from base.html
>
> {% if request.user.is_superuser %}
>  {% activetab "topnav" "home" %}
>  {% activetab "topnav" "admin" %}
> {% endif %}
>
> or can I say
> {% if request.user.is_superuser %}
>  {% activetab "topnav" "home" "topnav" "admin"%}
> {% endif %}
>
> or even 
>
> {% if request.user.is_superuser %}
>  {% activetab "home"  "admin"%}
> {% endif %}
>
> with only one navigation bar?
>

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




Anyone using django tabs ?

2013-06-20 Thread tony gair
I am trying django tabs for my site navigation and was wondering is I have 
to list multiple tabs in the html file thats inherits from base.html

{% if request.user.is_superuser %}
 {% activetab "topnav" "home" %}
 {% activetab "topnav" "admin" %}
{% endif %}

or can I say
{% if request.user.is_superuser %}
 {% activetab "topnav" "home" "topnav" "admin"%}
{% endif %}

or even 

{% if request.user.is_superuser %}
 {% activetab "home"  "admin"%}
{% endif %}

with only one navigation bar?

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




Re: readonly_fields

2013-06-19 Thread tony gair
Ah thanks that explains that I'll look into changing the readonly
attribute on the widget, is there a list of widgets do you know as some of
these are choice fields i.e. non text and non integer fields


On Wed, Jun 19, 2013 at 1:26 PM, Timster  wrote:

> Where are you setting that? readonly_fields is for ModelAdmin when you are
> working with the admin app.
>
> If you want to do it in a normal form, you will need to set readonly
> attribute on the widget.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/SEWttelj3h0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




readonly_fields

2013-06-19 Thread tony gair

I have tried to use readonly_fields in a form to designate fields that the 
user is not allowed to change.

class Meta 
readonly_fields = [user]
e.g.


However when I show the form the user can edit them.doh, btw I do want 
to display, but not to edit!

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




Re: database -> model -> charting

2013-06-10 Thread tony gair
I have subsequently located the problem. I think where the chartit.py 
supplies a parameter saying use_decimal=true is wrong. I have removed that 
parameter and found that it works with that change. 
Do you know if this is because of updates to jquery? 

On Monday, June 10, 2013 12:38:02 PM UTC, tony gair wrote:
>
> I tried that on 1.5 and tried my code out in a 1.4 install. I get the same 
> error.  Interestingly in stack overflow they mention this problem at 
> http://stackoverflow.com/questions/8644060/caught-typeerror-while-rendering-init-got-an-unexpected-keyword-argument
>
> and chartit in its own code seems to expect a decimal value regardless, so 
> maybe decimal values are hardwired into the code
>
> On Monday, June 10, 2013 10:55:00 AM UTC, Christian Schulz wrote:
>>
>> It could be a problem with the simpleson.dumps options in django 1.5 vs. 
>> the included simplejson. I remember there was something... 
>> Change: 
>> chartit/templatetags/chartit.py 
>> - from django.utils import simplejson 
>> +import simplejson 
>>
>>
>> > TypeError at /heating/chart/ 
>> > __init__() got an unexpected keyword argument 'use_decimal' 
>> > Request Method:GET 
>> > Request URL:http://127.0.0.1:8000/heating/chart/ 
>> > Django Version:1.5.1 
>> > Exception Type:TypeError 
>> > Exception Value: 
>> > __init__() got an unexpected keyword argument 'use_decimal' 
>> > Exception Location:/usr/lib/python2.7/json/__init__.py in dumps, line 
>> 250 
>> > Python Executable:/usr/bin/python 
>> > Python Version:2.7.4 
>> > Python Path: 
>> > ['/home/tony/django/sh', 
>> >  '/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg', 
>> >  '/usr/lib/python2.7', 
>> >  '/usr/lib/python2.7/plat-i386-linux-gnu', 
>> >  '/usr/lib/python2.7/lib-tk', 
>> >  '/usr/lib/python2.7/lib-old', 
>> >  '/usr/lib/python2.7/lib-dynload', 
>> >  '/usr/local/lib/python2.7/dist-packages', 
>> >  '/usr/lib/python2.7/dist-packages', 
>> >  '/usr/lib/python2.7/dist-packages/PILcompat', 
>> >  '/usr/lib/python2.7/dist-packages/gtk-2.0', 
>> >  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', 
>> >  '/usr/lib/python2.7/dist-packages/ubuntuone-client', 
>> >  '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', 
>> >  '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol'] 
>> > 
>> > This was my error. What I did was replace the two american city 
>> > temperature example with my own model data. However my data was 
>> > different in that the two temperatures were integer and the time axis 
>> > variable was actually utctime time (unconverted :) ) , the odd thing 
>> > though is that there seems to be no way to specify the variables going 
>> > in to the wrapper. e.g. Why is it insisting on a decimal, I cannot see 
>> > where this is specified in the example! 
>> > 
>> > On Monday, 10 June 2013 08:28:57 UTC, Christian Schulz wrote: 
>> > 
>> > I installed with python2.7/1.4.5 some weeks ago , but I didn't use 
>> a 
>> > BigIntegerField. What is your error message? 
>> > 
>> > 
>> > > After trying this I find a problem with the types it can use. For 
>> > > example it does not seem to like BigIntegerField unless there is 
>> > > something else I am doing wrong. Thinking about it, maybe I am 
>> > letting 
>> > > chartit do too much for me but I do like the idea of something 
>> > doing 
>> > > the hard thinking for me :). I am using python 2.7 and django 
>> > 1.5, are 
>> > > you using the same ? 
>> > > 
>> > > On Friday, 7 June 2013 11:33:07 UTC+1, Christian Schulz wrote: 
>> > > 
>> > > When you have some experience with JS/Highcharts 
>> django-chartit 
>> > > might be 
>> > > interesting. 
>> > > Easy is relativ but I got it and I'm really not a django/JS 
>> > pro. It's 
>> > > nice work, but dev progress seems fallen asleep. 
>> > > 
>> > > http://chartit.shutupandship.com/ 
>> > <http://chartit.shutupandship.com/> 
>> > <http://chartit.shutupandship.com/ 
>> > <http://chartit.shutupandship.com/>> 
>> > > 
>> > > 
>> > > > 
>> > > > 
>> > > > I would like to

Re: database -> model -> charting

2013-06-10 Thread tony gair
I tried that on 1.5 and tried my code out in a 1.4 install. I get the same 
error.  Interestingly in stack overflow they mention this problem at 
http://stackoverflow.com/questions/8644060/caught-typeerror-while-rendering-init-got-an-unexpected-keyword-argument

and chartit in its own code seems to expect a decimal value regardless, so 
maybe decimal values are hardwired into the code

On Monday, June 10, 2013 10:55:00 AM UTC, Christian Schulz wrote:
>
> It could be a problem with the simpleson.dumps options in django 1.5 vs. 
> the included simplejson. I remember there was something... 
> Change: 
> chartit/templatetags/chartit.py 
> - from django.utils import simplejson 
> +import simplejson 
>
>
> > TypeError at /heating/chart/ 
> > __init__() got an unexpected keyword argument 'use_decimal' 
> > Request Method:GET 
> > Request URL:http://127.0.0.1:8000/heating/chart/ 
> > Django Version:1.5.1 
> > Exception Type:TypeError 
> > Exception Value: 
> > __init__() got an unexpected keyword argument 'use_decimal' 
> > Exception Location:/usr/lib/python2.7/json/__init__.py in dumps, line 
> 250 
> > Python Executable:/usr/bin/python 
> > Python Version:2.7.4 
> > Python Path: 
> > ['/home/tony/django/sh', 
> >  '/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg', 
> >  '/usr/lib/python2.7', 
> >  '/usr/lib/python2.7/plat-i386-linux-gnu', 
> >  '/usr/lib/python2.7/lib-tk', 
> >  '/usr/lib/python2.7/lib-old', 
> >  '/usr/lib/python2.7/lib-dynload', 
> >  '/usr/local/lib/python2.7/dist-packages', 
> >  '/usr/lib/python2.7/dist-packages', 
> >  '/usr/lib/python2.7/dist-packages/PILcompat', 
> >  '/usr/lib/python2.7/dist-packages/gtk-2.0', 
> >  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', 
> >  '/usr/lib/python2.7/dist-packages/ubuntuone-client', 
> >  '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', 
> >  '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol'] 
> > 
> > This was my error. What I did was replace the two american city 
> > temperature example with my own model data. However my data was 
> > different in that the two temperatures were integer and the time axis 
> > variable was actually utctime time (unconverted :) ) , the odd thing 
> > though is that there seems to be no way to specify the variables going 
> > in to the wrapper. e.g. Why is it insisting on a decimal, I cannot see 
> > where this is specified in the example! 
> > 
> > On Monday, 10 June 2013 08:28:57 UTC, Christian Schulz wrote: 
> > 
> > I installed with python2.7/1.4.5 some weeks ago , but I didn't use a 
> > BigIntegerField. What is your error message? 
> > 
> > 
> > > After trying this I find a problem with the types it can use. For 
> > > example it does not seem to like BigIntegerField unless there is 
> > > something else I am doing wrong. Thinking about it, maybe I am 
> > letting 
> > > chartit do too much for me but I do like the idea of something 
> > doing 
> > > the hard thinking for me :). I am using python 2.7 and django 
> > 1.5, are 
> > > you using the same ? 
> > > 
> > > On Friday, 7 June 2013 11:33:07 UTC+1, Christian Schulz wrote: 
> > > 
> > > When you have some experience with JS/Highcharts 
> django-chartit 
> > > might be 
> > > interesting. 
> > > Easy is relativ but I got it and I'm really not a django/JS 
> > pro. It's 
> > > nice work, but dev progress seems fallen asleep. 
> > > 
> > > http://chartit.shutupandship.com/ 
> > <http://chartit.shutupandship.com/> 
> > <http://chartit.shutupandship.com/ 
> > <http://chartit.shutupandship.com/>> 
> > > 
> > > 
> > > > 
> > > > 
> > > > I would like to hear peoples opinions on third party django 
> > > charting 
> > > > apps, with various considerations. My primary consideration 
> > > would ease 
> > > > of use by a django noob. 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-

Re: database -> model -> charting

2013-06-10 Thread tony gair
TypeError at /heating/chart/
__init__() got an unexpected keyword argument 'use_decimal'
Request Method: GET
Request URL: http://127.0.0.1:8000/heating/chart/
Django Version: 1.5.1
Exception Type: TypeError
Exception Value: 
__init__() got an unexpected keyword argument 'use_decimal'
Exception Location: /usr/lib/python2.7/json/__init__.py in dumps, line 250
Python Executable: /usr/bin/python
Python Version: 2.7.4
Python Path: 
['/home/tony/django/sh',
 '/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-i386-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
 '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']

This was my error. What I did was replace the two american city temperature 
example with my own model data. However my data was different in that the 
two temperatures were integer and the time axis variable was actually 
utctime time (unconverted :) ) , the odd thing though is that there seems 
to be no way to specify the variables going in to the wrapper. e.g. Why is 
it insisting on a decimal, I cannot see where this is specified in the 
example!

On Monday, 10 June 2013 08:28:57 UTC, Christian Schulz wrote:
>
> I installed with python2.7/1.4.5 some weeks ago , but I didn't use a 
> BigIntegerField. What is your error message? 
>
>
> > After trying this I find a problem with the types it can use. For 
> > example it does not seem to like BigIntegerField unless there is 
> > something else I am doing wrong. Thinking about it, maybe I am letting 
> > chartit do too much for me but I do like the idea of something doing 
> > the hard thinking for me :). I am using python 2.7 and django 1.5, are 
> > you using the same ? 
> > 
> > On Friday, 7 June 2013 11:33:07 UTC+1, Christian Schulz wrote: 
> > 
> > When you have some experience with JS/Highcharts django-chartit 
> > might be 
> > interesting. 
> > Easy is relativ but I got it and I'm really not a django/JS pro. 
> It's 
> > nice work, but dev progress seems fallen asleep. 
> > 
> > http://chartit.shutupandship.com/ <http://chartit.shutupandship.com/> 
>
> > 
> > 
> > > 
> > > 
> > > I would like to hear peoples opinions on third party django 
> > charting 
> > > apps, with various considerations. My primary consideration 
> > would ease 
> > > of use by a django noob. Thanks 
> > > -- 
> > > You received this message because you are subscribed to the Google 
> > > Groups "Django users" group. 
> > > To unsubscribe from this group and stop receiving emails from 
> > it, send 
> > > an email to django-users...@googlegroups.com . 
> > > To post to this group, send email to django...@googlegroups.com 
> > . 
> > > Visit this group at 
> > http://groups.google.com/group/django-users?hl=en 
> > <http://groups.google.com/group/django-users?hl=en>. 
> > > For more options, visit https://groups.google.com/groups/opt_out 
> > <https://groups.google.com/groups/opt_out>. 
> > > 
> > > 
> > 
>
>

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




Re: database -> model -> charting

2013-06-08 Thread tony gair
After trying this I find a problem with the types it can use. For example 
it does not seem to like BigIntegerField unless there is something else I 
am doing wrong. Thinking about it, maybe I am letting chartit do too much 
for me but I do like the idea of something doing the hard thinking for me 
:). I am using python 2.7 and django 1.5, are you using the same ?

On Friday, 7 June 2013 11:33:07 UTC+1, Christian Schulz wrote:
>
> When you have some experience with JS/Highcharts django-chartit might be 
> interesting. 
> Easy is relativ but I got it and I'm really not a django/JS pro. It's 
> nice work, but dev progress seems fallen asleep. 
>
> http://chartit.shutupandship.com/ 
>
>
> > 
> > 
> > I would like to hear peoples opinions on third party django charting 
> > apps, with various considerations. My primary consideration would ease 
> > of use by a django noob. Thanks 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>

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




Re: database -> model -> charting

2013-06-07 Thread tony gair
Been trying out a couple over the last few hours. I have to say, the one 
you mention seems streets ahead of anything else, and its documented really 
well, which is the clincher for me.
Many thanks for that super helpful info!

On Friday, 7 June 2013 11:33:07 UTC+1, Christian Schulz wrote:
>
> When you have some experience with JS/Highcharts django-chartit might be 
> interesting. 
> Easy is relativ but I got it and I'm really not a django/JS pro. It's 
> nice work, but dev progress seems fallen asleep. 
>
> http://chartit.shutupandship.com/ 
>
>
> > 
> > 
> > I would like to hear peoples opinions on third party django charting 
> > apps, with various considerations. My primary consideration would ease 
> > of use by a django noob. Thanks 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>

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




database -> model -> charting

2013-06-07 Thread tony gair


I would like to hear peoples opinions on third party django charting apps, 
with various considerations. My primary consideration would ease of use by 
a django noob. Thanks

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




Re: getting information from a many to many model from user

2013-06-07 Thread tony gair
That would work nicely if I had done my own user management app but I 
lazily used Userena. I think I need to override a function of their profile 
form so it only displays fields if the superuser or a designated boolean in 
same said profile is set to true:)
Do you know how I would over ride a class function ?

On Thursday, 6 June 2013 13:02:02 UTC, Daniel Roseman wrote:
>
> On Thursday, 6 June 2013 11:00:40 UTC+1, tony gair wrote:
>
>>
>>
>>
>> I use the Userena app to manage my users but I want the superuser to 
>> choose the organisation for them so they cannot wonder around other 
>> organisations information.
>>
>> I can either create a foreign key in their profile to point to the 
>> organisation but then I expect they can change it, which would not be 
>> acceptable. 
>>
>> I could create a many to many set of models (as per the documentation) 
>> but then I need to discover the organisation they are part of, every time a 
>> form is entered into, in which case I would need a function to discover the 
>> organisation id from the querying the user object in my group model.
>>
>> My favourite would probably be to have unmodifiable fields (by them) but 
>> which the superuser can alter. Anyone know how I would do this?
>>
>>
>>
> Users can only alter fields if you write code that allows them to do so. 
> If you don't want them to alter a particular field in their profile, just 
> don't include that field on the form (or specifically exclude it).
> --
> DR.
>

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




getting information from a many to many model from user

2013-06-06 Thread tony gair



I use the Userena app to manage my users but I want the superuser to choose 
the organisation for them so they cannot wonder around other organisations 
information.

I can either create a foreign key in their profile to point to the 
organisation but then I expect they can change it, which would not be 
acceptable. 

I could create a many to many set of models (as per the documentation) but 
then I need to discover the organisation they are part of, every time a 
form is entered into, in which case I would need a function to discover the 
organisation id from the querying the user object in my group model.

My favourite would probably be to have unmodifiable fields (by them) but 
which the superuser can alter. Anyone know how I would do this?


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




Writing your first Django app - Tutorial Question

2013-06-04 Thread Tony Guilin
In the https://docs.djangoproject.com/en/1.5/intro/tutorial01/ tutorial 
under the,
Playing with the API



section, I'm trying to go through the example in my python shell as 
described.


p = Poll(question="What's new?", pub_date=timezone.now())

But I'm unable to get to next command "p.save()" because of the error below.

> tony@tonymachine:~/django_projects/mysite$ python manage.py shell
> Python 2.7.3 (default, Aug 1 2012, 05:16:07)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from polls.models import Poll, Choice
> >>> Poll.objects.all()
> []
> >>> from django.utils import timezone
> >>> p = Poll(question="What's new?", pub_date=timezone.now())
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
> line 415, in __init__
>  raise TypeError("'%s' is an invalid keyword argument for this function" % 
> list(kwargs)[0])
> TypeError: 'pub_date' is an invalid keyword argument for this function
> >>>
>
Any guidance is appreciated.

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




Re: CBVs and logging a user

2013-06-04 Thread tony gair
excellent thanks Bill!



On Tue, Jun 4, 2013 at 9:35 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> Looking closer, do you have an app named 'main'?  If so does it have a
> urls.py in it?  Can you import that without error (say in the manage.py
> shell)?  If so, try:
>
> repr(main.urlpatterns)
>
> (Since the error message complains that main.urls has no url patterns in
> it.)
>
> If you don't expect to use such a module, check your existing urls.py
> files for a url pattern that does include('main.urls'), or something close.
>
>
> On Tue, Jun 4, 2013 at 2:58 AM, tony gair <tonytheg...@gmail.com> wrote:
>
>> my URLS_CONF points to my urls.py in my main project directory. The error
>> only once I press the login button, the form is validated, the user
>> then(correctly ) is authenticated then it fails with the error when I try
>> to redirect it to a view.
>>
>>
>> On Monday, June 3, 2013 2:45:09 PM UTC, tony gair wrote:
>>>
>>>
>>> I'm getting an error
>>>
>>> Request URL: 
>>> http://127.0.0.1:8000/heating/**login/?next=/heating/orglv/<http://127.0.0.1:8000/heating/login/?next=/heating/orglv/>
>>> Django Version: 1.5.1
>>> Exception Type: ImproperlyConfigured
>>> Exception Value:
>>> The included urlconf main.urls doesn't have any patterns in it
>>>
>>> my login form and view has been modified to work off email and password
>>> rather than username and password
>>>
>>>
>>> my forms.py looks like
>>>
>>> class MyCustomLoginForm(forms.Form):
>>>   """A login form for the customer model"""
>>>   email = forms.EmailField(
>>> label=('Your email address'),
>>> required=True)
>>>   password = forms.CharField(
>>> label=('Your password'),
>>> widget=forms.PasswordInput,
>>> required=True)
>>>
>>>   def clean(self):
>>> """If the user is valid and active then auth them & return the
>>> clean_data"""
>>> clean_data = self.cleaned_data
>>> try:
>>>   # authenticate the details
>>>   user = authenticate(
>>>   username=clean_data['email'],
>>>   password=clean_data['password'**])
>>>   if user and user.is_active:
>>>   self.user = user
>>>   return clean_data
>>> except (KeyError, AttributeError):
>>>   pass
>>> raise forms.ValidationError(('**Incorrect Password'))
>>>
>>> views.py looks like
>>> class LoginView(FormView):
>>> """Give a view to login"""
>>> form_class = MyCustomLoginForm
>>>   template_name = 'login.html'
>>>   success_url = reverse ('orglv')
>>>
>>> def get_success_url(self):
>>>   return reverse ('orglv')
>>>
>>> def form_valid(self, form):
>>>   """ if the form is valid, then log the user in"""
>>>   login(self.request, form.user)
>>>   return HttpResponseRedirect(self.get_**success_url())
>>>
>>> backends.py looks like
>>>
>>>
>>> class EmailOrUsernameModelBackend(**object):
>>> def authenticate(self, username=None, password=None):
>>> print(username)
>>> print(password)
>>> try:
>>>  user = Heating_User.objects.get(**email=username)
>>>  print(user.username)
>>>  print(user.password)
>>>  if user.check_password(password):
>>> print("password ok")
>>>  return user
>>> except Heating_User.DoesNotExist:
>>>  print("crap")
>>> return None
>>>
>>> def get_user(self, user_id):
>>> try:
>>> return Heating_User.objects.get(pk=**user_id)
>>> except User.DoesNotExist:
>>> return None
>>>
>>> and my login.html looks like
>>>
>>>{% extends "base.html" %}
>>>
>>> {% block title %}Login{% endblock title %}
>>>
>>> {% block content %}
>>> 
>>> {% csrf_token %}
>>> {{ form.as_p }}
>>> login
>>> 
>>> 
>>> {% endblock content %}
>>>
>>>
>>>
>>> and my urls.py looks like
>>>
>>> urlpatterns = 

Re: CBVs and logging a user

2013-06-04 Thread tony gair
my URLS_CONF points to my urls.py in my main project directory. The error 
only once I press the login button, the form is validated, the user 
then(correctly ) is authenticated then it fails with the error when I try 
to redirect it to a view.

On Monday, June 3, 2013 2:45:09 PM UTC, tony gair wrote:
>
>
> I'm getting an error
>
> Request URL: http://127.0.0.1:8000/heating/login/?next=/heating/orglv/
> Django Version: 1.5.1
> Exception Type: ImproperlyConfigured
> Exception Value: 
> The included urlconf main.urls doesn't have any patterns in it
>
> my login form and view has been modified to work off email and password 
> rather than username and password
>
>
> my forms.py looks like
>
> class MyCustomLoginForm(forms.Form):
>   """A login form for the customer model"""
>   email = forms.EmailField(
> label=('Your email address'),
> required=True)
>   password = forms.CharField(
> label=('Your password'),
> widget=forms.PasswordInput,
> required=True)
>  
>   def clean(self):
> """If the user is valid and active then auth them & return the 
> clean_data"""
> clean_data = self.cleaned_data
> try:
>   # authenticate the details
>   user = authenticate(
>   username=clean_data['email'],
>   password=clean_data['password'])
>   if user and user.is_active:
>   self.user = user
>   return clean_data
> except (KeyError, AttributeError):
>   pass
> raise forms.ValidationError(('Incorrect Password'))
>
> views.py looks like
> class LoginView(FormView):
> """Give a view to login"""
> form_class = MyCustomLoginForm
>   template_name = 'login.html'
>   success_url = reverse ('orglv')
>
> def get_success_url(self):
>   return reverse ('orglv')
>  
> def form_valid(self, form):
>   """ if the form is valid, then log the user in"""
>   login(self.request, form.user)
>   return HttpResponseRedirect(self.get_success_url())
>
> backends.py looks like
>
>
> class EmailOrUsernameModelBackend(object):
> def authenticate(self, username=None, password=None):
> print(username)
> print(password)
> try:
>  user = Heating_User.objects.get(email=username)
>  print(user.username)
> print(user.password)
>  if user.check_password(password):
> print("password ok")
> return user
> except Heating_User.DoesNotExist:
>  print("crap")
> return None
>
> def get_user(self, user_id):
> try:
> return Heating_User.objects.get(pk=user_id)
> except User.DoesNotExist:
> return None
>
> and my login.html looks like
>
>{% extends "base.html" %}
>
> {% block title %}Login{% endblock title %}
>
> {% block content %}
> 
> {% csrf_token %}
> {{ form.as_p }}
> login
> 
> 
> {% endblock content %}
>
>
>
> and my urls.py looks like
>
> urlpatterns = patterns('',
> url(regex=r'login/$',
> view=LoginView.as_view(),
> name="login"
> ), 
>  
>
>
> has anyone any ideas?
>

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




CBVs and logging a user

2013-06-03 Thread tony gair

I'm getting an error

Request URL: http://127.0.0.1:8000/heating/login/?next=/heating/orglv/
Django Version: 1.5.1
Exception Type: ImproperlyConfigured
Exception Value: 
The included urlconf main.urls doesn't have any patterns in it

my login form and view has been modified to work off email and password 
rather than username and password


my forms.py looks like

class MyCustomLoginForm(forms.Form):
  """A login form for the customer model"""
  email = forms.EmailField(
label=('Your email address'),
required=True)
  password = forms.CharField(
label=('Your password'),
widget=forms.PasswordInput,
required=True)
 
  def clean(self):
"""If the user is valid and active then auth them & return the 
clean_data"""
clean_data = self.cleaned_data
try:
  # authenticate the details
  user = authenticate(
  username=clean_data['email'],
  password=clean_data['password'])
  if user and user.is_active:
  self.user = user
  return clean_data
except (KeyError, AttributeError):
  pass
raise forms.ValidationError(('Incorrect Password'))

views.py looks like
class LoginView(FormView):
"""Give a view to login"""
form_class = MyCustomLoginForm
  template_name = 'login.html'
  success_url = reverse ('orglv')

def get_success_url(self):
  return reverse ('orglv')
 
def form_valid(self, form):
  """ if the form is valid, then log the user in"""
  login(self.request, form.user)
  return HttpResponseRedirect(self.get_success_url())

backends.py looks like


class EmailOrUsernameModelBackend(object):
def authenticate(self, username=None, password=None):
print(username)
print(password)
try:
 user = Heating_User.objects.get(email=username)
 print(user.username)
print(user.password)
 if user.check_password(password):
print("password ok")
return user
except Heating_User.DoesNotExist:
 print("crap")
return None

def get_user(self, user_id):
try:
return Heating_User.objects.get(pk=user_id)
except User.DoesNotExist:
return None

and my login.html looks like

   {% extends "base.html" %}

{% block title %}Login{% endblock title %}

{% block content %}

{% csrf_token %}
{{ form.as_p }}
login


{% endblock content %}



and my urls.py looks like

urlpatterns = patterns('',
url(regex=r'login/$',
view=LoginView.as_view(),
name="login"
), 
 


has anyone any ideas?

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




Re: django , python and ides

2013-06-03 Thread tony gair
Got to say that this looks very promising. Theres also a Django plugin too. 
dddjjjannnggooo!


On Saturday, June 1, 2013 9:01:00 PM UTC, Doug S wrote:
>
> Hey I just ran into a new opensource Python IDE that looks interesting 
> that wasn't around when I commited to Aptana
> Ninja-ide 
> http://www.ninja-ide.org/
> review at:
> http://yatharthrock.blogspot.com/2013/01/ninja.html
>
> Has anyone used this yet?
>
>
>
> On Sat, Jun 1, 2013 at 4:56 PM, Doug Snyder  > wrote:
>
>> one free one on LInux I'd avoid is SPE IDE - Stani's Python Editor
>> It's just too old and in the dark ages
>> I had a lot of problems with encodings and white space/indentation 
>> nightmares when taking my code from it to other editors
>>
>> If you go with a simple text editor on Linux try Kate,
>> its got some minimal Python functionality built in like code coloring and 
>> intelligent indentation
>>  
>>
>> On Sat, Jun 1, 2013 at 4:46 PM, Doug Snyder > > wrote:
>>
>>> I use an IDE called Aptana Studio 3 and like it.
>>> I can't say that I've tried a lot of IDEs and I tend to get more 
>>> opinionated about programming languages and technologies than editors
>>> but when I got into Django I looked at some options and found Aptana to 
>>> be the most full featured free and platform independent option that I could 
>>> dig up. Its meant to be a web development IDE so it has some nice 
>>> HTML/CSS/JavaScript/JQuery niceities like code coloring, code completion 
>>> and things ( which helps me get through the design and onto the important 
>>> stuff: Django ). Aptana is built on top of PyDev, the python plugin for 
>>> Eclipse ( which has been an opensource standard IDE for a good long time ), 
>>> so its got everything python from PyDev and then has a few Django 
>>> conveniences built in too, like some common command line django commands 
>>> available from the IDE's GUI, and a (i)python shell that loads up your 
>>> django environment and lets you do stuff like play with your models to get 
>>> them working before you add in extended admin functionality for them or 
>>> cook up a proper web interface. 
>>> One complaint I have with it is that its a little hard to work with 
>>> Aptana Django projects if you are developing them on multiple computers 
>>> because the project profile has hard coded paths. The work around is to 
>>> ignore them in your version control. One the first computer you start the 
>>> project with, Aptana and PyDev will create well formed project meta data 
>>> file ( one for each ). You manually copy the new computer and manually edit 
>>> the hidden files and change the file paths in the XML to fit the different 
>>> file system. It could be worse and I'll probably stop complaining once I 
>>> write a script to do it for me.
>>> All around Aptana offers a lot.
>>> I'm believe in simplicity when it comes to programming
>>> When it comes to IDEs I believe in convenience.
>>>
>>>
>>> On Sat, Jun 1, 2013 at 12:57 PM, Jacky Tedy >> > wrote:
>>>
 I just use Vim

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

>>>
>>>
>>
>

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




django , python and ides

2013-05-31 Thread tony gair
Python and Django are not my first languages and currently I am using it 
like I would a compiled language inside gedit on debian wheezy. I was 
actually quite surprised to find a lot of people using it on windows and 
macs when I went to my local python user group but enough digression!.
 I was wondering if anyone using debian wheezy can recommend a nice ide 
(hopefully opensource but if not then relatively inexpenisive) for django 
and python?

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




CBVs and using existing forms for user authentication etc

2013-05-31 Thread tony gair

I'm trying to write my first django app using cbv's and good practice ala 2 
scoops!

(thanks for all the help so far in this forum btw!)

I have constructed the app using django braces and CBV's and have noticed 
that I can only authenticate into my app through the admin panel.

I suspect that django already has the logging mechanism for my abstractuser 
and its just a matter of declaring it in my urls, 

is this so?

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




Re: django 1.5 abstractuser / accessing information of logged on user

2013-05-30 Thread tony gair
Thanks for the post Tom, I notice that the FormMixin class is from 
django.views.generic.edit and I am confused to how to use it so I gave it a 
try with
#views.py
class PremisesUpdateView(LoginRequiredMixin, FormMixin):
form_class = PremisesForm 
model = Premises
success_url = reverse_lazy('premlv')
def get_form_kwargs(self):
kwargs = super(PremisesUpdateView, self).get_form_kwargs()
kwargs['heating_user'] = self.request.user
return kwargs
#forms.py
class HeatingUserForm ( forms.ModelForm):

def __init__(self, *args, **kwargs):
self.user=kwargs.pop('heating_user')
super(HeatingUserForm, self).__init__(*args, **kwargs)
if self.user.is_superuser:
self.fields['premises'].queryset = Premises.objects.all() 
elif self.user.is_staff:
self.fields['premises'].queryset = 
Premises.objects.filter(organisation=self.user.organisation)
else:
self.fields['premises'].queryset = 
Premises.objects.filter(id=self.user.premises)
 
#premises = CustomModelChoiceField(queryset=Premises.objects.all())
#organisation = CustomModelChoiceField(queryset=Organisation.objects.all())
class Meta:
model=Heating_User
fields = [ 'username', 'password', 'first_name', 'last_name', 
'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 
'organisation', 'premises' ]

however a problem now occurs with my urls.py  , because not i get an error 
'type object 'PremisesCreateView' has no attribute 'as_view'
#urls.py
 ),
url(
regex=r'premuv/(?P\d+)/$',
view=PremisesUpdateView.as_view(),
name="premuv"
),
do you know what I would substitute as_view() for ,

thanks for the grounding in these CBV, I am using them ala 2 scoops of 
django!

On Thursday, 30 May 2013 11:14:27 UTC, Tom Evans wrote:
>
> On Thu, May 30, 2013 at 9:57 AM, tony gair <tonyt...@gmail.com> 
> wrote: 
> > 
> > I am using CBV / django braces for authentication. My user authorisation 
> > model inherits abstractuser and adds a few fields which are foreign keys 
> to 
> > two other models organisation and premises. 
> > 
> > When a form initialises I want to be able to examine the details of the 
> user 
> > logged in , look to see if they are a is_superuser  or is_staff and 
> occupy 
> > my organisation and premises form fields accordingly using the values 
> stored 
> > as foreign keys in the logged on and authenticated user. 
> > 
> > My main problem at the moment is that I get a KeyError for the line 
> > 'self.user=kwargs.pop('user')' centered on 'user' 
> > 
> > 
> > #heating/forms.py 
> > from django import forms 
> > from .models import Organisation, Premises,  Heating_User, Room, Heater 
> > 
> > class HeatingUserForm ( forms.ModelForm): 
> > 
> >   def __init__(self, *args, **kwargs): 
> > self.user=kwargs.pop('User') 
> > super(HeatingUserForm, self).__init__(*args, **kwargs) 
> > if self.user.is_superuser: 
> > self.fields['premises'].queryset = Premises.objects.all() 
> > elif self.user.is_staff: 
> > self.fields['premises'].queryset = 
> > Premises.objects.filter(organisation=self.user.organisation) 
> > else: 
> > self.fields['premises'].queryset = 
> > Premises.objects.filter(id=self.user.premises) 
> > 
> > 
> > #models.py 
> > from django.conf import settings 
> > from django.core.urlresolvers import reverse 
> > from django.db import models 
> > from django.contrib.auth.models import AbstractUser 
> > 
> > class Heating_User (AbstractUser): 
> >   jobtitle = models.CharField(max_length=255) 
> >   organisation = models.ForeignKey(Organisation, null=True) 
> >   premises = models.ForeignKey(Premises, null= True) 
> > def __unicode__(self): 
> > return self.username 
> > def get_absolute_url(self): 
> > return reverse('users-detail', kwargs={'pk':self.pk}) 
> > #end of files 
> > 
> > 
> > can anyone see where I am going wrong here? 
> > 
>
> 'user' is not an argument that is supplied to every form that is 
> initialised, I was trying to explain this to you yesterday. 
>
> Yesterday you said are using a CBV. A CBV that deals with forms 
> probably uses the FormMixin to provide it's form handling: 
>
>
> https://docs.djangoproject.com/en/1.5/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin
>  
>
> FormMixin defines various functions and attributes on the class, which 
> you can customise in your derived version of the class to give 
> specialised effects. The one you'll need to change in order to pass 
> user to the form constructor is get_form_kwargs(). You will want to do 
> something like this: 
>
> class MyClassBasedView(UpdateView): 
> form_class = HeatingUserForm 
> def get_form_kwargs(self):

Re: django 1.5 abstractuser / accessing information of logged on user

2013-05-30 Thread tony gair
Thanks for the post Tom, I notice that the FormMixin class is from 
django.views.generic.edit and I am confused to how to use it so I gave it a 
try with
#views.py
class PremisesUpdateView(LoginRequiredMixin, FormMixin):
form_class = PremisesForm 
model = Premises
success_url = reverse_lazy('premlv')
def get_form_kwargs(self):
kwargs = super(PremisesUpdateView, self).get_form_kwargs()
kwargs['heating_user'] = self.request.user
return kwargs
#forms.py
class PremisesUpdateView(LoginRequiredMixin, FormMixin):
form_class = PremisesForm 
model = Premises
success_url = reverse_lazy('premlv')
def get_form_kwargs(self):
kwargs = super(PremisesUpdateView, self).get_form_kwargs()
kwargs['heating_user'] = self.request.user
return kwargs

however a problem now occurs with my urls.py  , because not i get an error 
'type object 'PremisesCreateView' has no attribute 'as_view'
#urls.py
 ),
url(
regex=r'premuv/(?P\d+)/$',
view=PremisesUpdateView.as_view(),
name="premuv"
),
do you know what I would substitute as_view() for ,

thanks for the grounding in these CBV, I am using them ala 2 scoops of 
django!

On Thursday, 30 May 2013 11:14:27 UTC, Tom Evans wrote:
>
> On Thu, May 30, 2013 at 9:57 AM, tony gair <tonyt...@gmail.com> 
> wrote: 
> > 
> > I am using CBV / django braces for authentication. My user authorisation 
> > model inherits abstractuser and adds a few fields which are foreign keys 
> to 
> > two other models organisation and premises. 
> > 
> > When a form initialises I want to be able to examine the details of the 
> user 
> > logged in , look to see if they are a is_superuser  or is_staff and 
> occupy 
> > my organisation and premises form fields accordingly using the values 
> stored 
> > as foreign keys in the logged on and authenticated user. 
> > 
> > My main problem at the moment is that I get a KeyError for the line 
> > 'self.user=kwargs.pop('user')' centered on 'user' 
> > 
> > 
> > #heating/forms.py 
> > from django import forms 
> > from .models import Organisation, Premises,  Heating_User, Room, Heater 
> > 
> > class HeatingUserForm ( forms.ModelForm): 
> > 
> >   def __init__(self, *args, **kwargs): 
> > self.user=kwargs.pop('User') 
> > super(HeatingUserForm, self).__init__(*args, **kwargs) 
> > if self.user.is_superuser: 
> > self.fields['premises'].queryset = Premises.objects.all() 
> > elif self.user.is_staff: 
> > self.fields['premises'].queryset = 
> > Premises.objects.filter(organisation=self.user.organisation) 
> > else: 
> > self.fields['premises'].queryset = 
> > Premises.objects.filter(id=self.user.premises) 
> > 
> > 
> > #models.py 
> > from django.conf import settings 
> > from django.core.urlresolvers import reverse 
> > from django.db import models 
> > from django.contrib.auth.models import AbstractUser 
> > 
> > class Heating_User (AbstractUser): 
> >   jobtitle = models.CharField(max_length=255) 
> >   organisation = models.ForeignKey(Organisation, null=True) 
> >   premises = models.ForeignKey(Premises, null= True) 
> > def __unicode__(self): 
> > return self.username 
> > def get_absolute_url(self): 
> > return reverse('users-detail', kwargs={'pk':self.pk}) 
> > #end of files 
> > 
> > 
> > can anyone see where I am going wrong here? 
> > 
>
> 'user' is not an argument that is supplied to every form that is 
> initialised, I was trying to explain this to you yesterday. 
>
> Yesterday you said are using a CBV. A CBV that deals with forms 
> probably uses the FormMixin to provide it's form handling: 
>
>
> https://docs.djangoproject.com/en/1.5/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin
>  
>
> FormMixin defines various functions and attributes on the class, which 
> you can customise in your derived version of the class to give 
> specialised effects. The one you'll need to change in order to pass 
> user to the form constructor is get_form_kwargs(). You will want to do 
> something like this: 
>
> class MyClassBasedView(UpdateView): 
> form_class = HeatingUserForm 
> def get_form_kwargs(self): 
> kwargs = super(MyClassBasedView, self).get_form_kwargs() 
> kwargs['user'] = self.request.user 
> return kwargs 
>
> Then, when your class based view instantiates your form, it will 
> provide the correct arguments. 
>
> Cheers 
>
> Tom 
>

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




Re: linking the logged in user to other models to filter query sets -( noobie )

2013-05-30 Thread tony gair
with the line
self.user = kwargs.pop('user')

do I need to import anything to access that the value 'user' ?
 
On Wednesday, 29 May 2013 15:16:32 UTC, Tom Evans wrote:
>
> On Wed, May 29, 2013 at 3:29 PM, tony gair <tonyt...@gmail.com> 
> wrote: 
> > 
> > 
> > I've done a basic django app with a user which contains an organisation 
> and 
> > premises foreign key inside the user model which has been inherited 
> using 
> > the features of django 1.5. 
> > 
> > I use the organisation id and premises id inside other models which I 
> would 
> > like to present themselves providing they are the same. 
> > 
> > I have tried to closely follow the 'two scoops of django approach' in 
> that I 
> > use a CBV with django braces approach to show my models. 
> > 
> > It is very important for me only to show the models in the views which 
> use 
> > either the organisation id or premises id. 
> > 
> > At the moment in my  forms.py for my  user it looks like 
> > 
> >  
> > #forms.py 
> > class HeatingUserForm ( forms.ModelForm): 
> > 
> > premises = CustomModelChoiceField(queryset=Premises.objects.all()) 
> > organisation = 
> CustomModelChoiceField(queryset=Organisation.objects.all()) 
> > class Meta: 
> > model=Heating_User 
> > fields = [ 'username', 'password', 'first_name', 'last_name', 
> > 'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 
> 'organisation', 
> > 'premises' ] 
> > 
> > *** 
> > 
> > Unless the user is a super user, I want the organisation to be 
> restricted to 
> > the organisation that the logged in user is of the same . The premises 
> > should be restricted to those premises that have the same id as the 
> logged 
> > in user. 
> > 
> > Can anyone tell me how this is done? 
> > 
> > :) 
> > 
>
> You want to do different things in the form based upon the current 
> user, so the first step is to require that a user object is passed to 
> the form's __init__ method. Then, you simply manipulate the queryset 
> attributes on the desired fields after calling the super class' 
> __init__ method. 
>
> Also, if premises and organisation are foreign key fields, as it 
> seems, you don't need to declare the fields at all: 
>
> class HeatingUserForm (forms.ModelForm): 
> def __init__(self, *args, **kwargs): 
> self.user = kwargs.pop('user') 
> super(HeatingUserForm, self).__init__(*args, **kwargs) 
> if self.user.is_superuser: 
> self.fields['premises'].queryset = Premises.objects.all() 
> self.fields['organisation'].queryset = 
> Organisation.objects.all() 
> else: 
> self.fields['premises'].queryset = 
> Premises.objects.filter(users=self.user) 
> self.fields['organisation'].queryset = 
> Organisation.objects.filter(users=self.user) 
> class Meta: 
> model=Heating_User 
> fields = [ … ] 
>
> You could also do some additional cleanup work, if the number of 
> choices for either of those two fields is exactly one, you could 
> replace the widget on the form field with a hidden input, so that you 
> do not display a pointless control (OTOH, it may not be pointless). 
>
> Cheers 
>
> Tom 
>

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




django 1.5 abstractuser / accessing information of logged on user

2013-05-30 Thread tony gair

I am using CBV / django braces for authentication. My user authorisation 
model inherits abstractuser and adds a few fields which are foreign keys to 
two other models organisation and premises.

When a form initialises I want to be able to examine the details of the 
user logged in , look to see if they are a is_superuser  or is_staff and 
occupy my organisation and premises form fields accordingly using the 
values stored as foreign keys in the logged on and authenticated user. 

My main problem at the moment is that I get a KeyError for the line 
'self.user=kwargs.pop('user')' centered on 'user'


#heating/forms.py
from django import forms
from .models import Organisation, Premises,  Heating_User, Room, Heater

class HeatingUserForm ( forms.ModelForm):

  def __init__(self, *args, **kwargs):
self.user=kwargs.pop('User')
super(HeatingUserForm, self).__init__(*args, **kwargs)
if self.user.is_superuser:
self.fields['premises'].queryset = Premises.objects.all() 
elif self.user.is_staff:
self.fields['premises'].queryset = 
Premises.objects.filter(organisation=self.user.organisation)
else:
self.fields['premises'].queryset = 
Premises.objects.filter(id=self.user.premises)
 

#models.py
from django.conf import settings
from django.core.urlresolvers import reverse
from django.db import models
from django.contrib.auth.models import AbstractUser

class Heating_User (AbstractUser):
  jobtitle = models.CharField(max_length=255)
  organisation = models.ForeignKey(Organisation, null=True)
  premises = models.ForeignKey(Premises, null= True)
def __unicode__(self):
return self.username
def get_absolute_url(self):
return reverse('users-detail', kwargs={'pk':self.pk})
#end of files

 
can anyone see where I am going wrong here?

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




Re: linking the logged in user to other models to filter query sets -( noobie )

2013-05-29 Thread tony gair
I think my first post was a bit messy and I left some information out
I have an organisation as a foreign key contained in my abstact user object 
which is Heating_User. The premises also contains the organisation as a 
foreign key. What I am looking to do on my premises view is to filter the 
premises so that the organisation is the same as that for the logged in 
user. Although my model does include the premises id I want it so there is 
a organisation wide flag that would list all the premises if that flag was 
set. The superuser flag I (oh my that looks really useful). I think you 
have probably told me what I need to know but I'm not sure. I guess what I 
am asking in addition is how do I access the logged in user organisation 
foreign key so that I can filter the query? 

I hope that makes sense, I am quite new to this, but very enthused!!

On Wednesday, 29 May 2013 15:16:32 UTC, Tom Evans wrote:
>
> On Wed, May 29, 2013 at 3:29 PM, tony gair <tonyt...@gmail.com> 
> wrote: 
> > 
> > 
> > I've done a basic django app with a user which contains an organisation 
> and 
> > premises foreign key inside the user model which has been inherited 
> using 
> > the features of django 1.5. 
> > 
> > I use the organisation id and premises id inside other models which I 
> would 
> > like to present themselves providing they are the same. 
> > 
> > I have tried to closely follow the 'two scoops of django approach' in 
> that I 
> > use a CBV with django braces approach to show my models. 
> > 
> > It is very important for me only to show the models in the views which 
> use 
> > either the organisation id or premises id. 
> > 
> > At the moment in my  forms.py for my  user it looks like 
> > 
> >  
> > #forms.py 
> > class HeatingUserForm ( forms.ModelForm): 
> > 
> > premises = CustomModelChoiceField(queryset=Premises.objects.all()) 
> > organisation = 
> CustomModelChoiceField(queryset=Organisation.objects.all()) 
> > class Meta: 
> > model=Heating_User 
> > fields = [ 'username', 'password', 'first_name', 'last_name', 
> > 'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 
> 'organisation', 
> > 'premises' ] 
> > 
> > *** 
> > 
> > Unless the user is a super user, I want the organisation to be 
> restricted to 
> > the organisation that the logged in user is of the same . The premises 
> > should be restricted to those premises that have the same id as the 
> logged 
> > in user. 
> > 
> > Can anyone tell me how this is done? 
> > 
> > :) 
> > 
>
> You want to do different things in the form based upon the current 
> user, so the first step is to require that a user object is passed to 
> the form's __init__ method. Then, you simply manipulate the queryset 
> attributes on the desired fields after calling the super class' 
> __init__ method. 
>
> Also, if premises and organisation are foreign key fields, as it 
> seems, you don't need to declare the fields at all: 
>
> class HeatingUserForm (forms.ModelForm): 
> def __init__(self, *args, **kwargs): 
> self.user = kwargs.pop('user') 
> super(HeatingUserForm, self).__init__(*args, **kwargs) 
> if self.user.is_superuser: 
> self.fields['premises'].queryset = Premises.objects.all() 
> self.fields['organisation'].queryset = 
> Organisation.objects.all() 
> else: 
> self.fields['premises'].queryset = 
> Premises.objects.filter(users=self.user) 
> self.fields['organisation'].queryset = 
> Organisation.objects.filter(users=self.user) 
> class Meta: 
> model=Heating_User 
> fields = [ … ] 
>
> You could also do some additional cleanup work, if the number of 
> choices for either of those two fields is exactly one, you could 
> replace the widget on the form field with a hidden input, so that you 
> do not display a pointless control (OTOH, it may not be pointless). 
>
> Cheers 
>
> Tom 
>

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




linking the logged in user to other models to filter query sets -( noobie )

2013-05-29 Thread tony gair


I've done a basic django app with a user which contains an organisation and 
premises foreign key inside the user model which has been inherited using 
the features of django 1.5.

I use the organisation id and premises id inside other models which I would 
like to present themselves providing they are the same.

I have tried to closely follow the 'two scoops of django approach' in that 
I use a CBV with django braces approach to show my models.

It is very important for me only to show the models in the views which use 
either the organisation id or premises id.

At the moment in my  forms.py for my  user it looks like


#forms.py
class HeatingUserForm ( forms.ModelForm):

premises = CustomModelChoiceField(queryset=Premises.objects.all())
organisation = CustomModelChoiceField(queryset=Organisation.objects.all())
class Meta:
model=Heating_User
fields = [ 'username', 'password', 'first_name', 'last_name', 
'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 
'organisation', 'premises' ]

***

Unless the user is a super user, I want the organisation to be restricted 
to the organisation that the logged in user is of the same . The premises 
should be restricted to those premises that have the same id as the logged 
in user. 

Can anyone tell me how this is done?

:)

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




listing objects in a html file

2013-05-28 Thread tony gair


This file is used to print out the name of the premises with an update link 
, however I wanted to add a list of premises with the in_use flag set to 
false. 
Can anyone tell me what I am doing wrong?


{% extends "base.html" %}

{% block content %}
Premises

{% unusedpremises = [] %}
{% for premises in object_list %}
{% if premises.in_use %}
{{ premises.name }}  Update   

{% else unusedpremises.add(premises) %}
{% endif %}
{% endfor %}

Unused Premises

{% for premises in unusedpremises %}
{{ premises.name }}  Update  
%nbsp 
{% endif %}
{% endfor %}

{% endblock %}

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




newbie- delete confirmation

2013-05-16 Thread tony gair

I'm making a cbv with django braces

I'm wanting to delete a record with a confirm form , does anyone know of an 
exampple to show me how to do this

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




should Django groups and permissions be hard-coded or bootstrapped?

2012-10-25 Thread Tony Schmidt


I'm building an app that assumes the existence of certain groups and 
permissions for its workflow. For example, a "member" can log into the app 
and view and edit their personal data, but cannot see notes that would 
typically be displayed on the same screen. An "employee" can see those 
notes and create or edit their own, but only a "member manager" can delete 
or edit anyone's notes.

My issue is with bootstrapping the data for this app. I can create JSON 
fixture data for the groups, but then I have to hard-code the PKs, which 
seems like bad practice (what if a third party app I wanted to use did the 
same thing and there was a conflict?) A bigger issue is the permissions - I 
would have to add PKs to the permissions which in turn would have PKs to 
their content types.

I've read about using the post_syncdb hook to add initial data in a more 
programmatic fashion which I'm hoping will help me resolve the hard-coded 
PK issue. But I'm wondering whether this is the best solution to this 
problem, or if I'm "abusing" the Django Group and Permission concepts, 
here, and should be doing something else, like creating new models or just 
putting flags (like "is_member_manager") on my user profile model, etc.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/lzhz-lJSPlcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django and LDAP

2012-09-10 Thread Tony
Hi everybody,

I am new to Django and Python, and right now, i am going through the 
documentation. I have an assignment at my Faculty, where i need to install 
Django, 389ds LDAP server (where i have to store my users) and i need to 
somehow connect them two, so i can auth users from LDAP when logging into 
Django. i have read some documentation, and i saw a massive lines of code, 
add this, add that, and i don't get any of that.

Can someone please help me with this issue, i'll be very grateful.

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7ArlkeKjY0YJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[Django Gig - Sacramento/Bay Area, CA] Help make Django/FOSS a success for independent/local grocery retail

2012-05-25 Thread Tony Schmidt
I can read this list and the docs all I want, but there's no substitute for 
experienced code review and pair programming.

*So we, the Sacramento Natural Foods Co-op, are seeking a (preferably 
local) Django guru to help bring best practices to our in-house software 
development.

We have a small I.T. department with one full-time developer and are trying 
to liberate our internal systems using Free Software and Python/Django.  As 
a co-operative, we believe in local/community investment and sharing, which 
is why we are trying to empower in-house staff with custom software and 
tools.  We also hope to share our software with the broader grocery retail 
industry, at some point.  

We have been using Django for about a year for two projects, and are about 
to start a third.  We need someone to help provide support to our in-house 
developer 5-15 hours per week through on-site or remote pair programming 
and other means of collaboration to insure that we are building the best 
Django apps possible.

The current project we need support for is scheduled for a three month time 
frame, starting immediately.  We figure you probably need about 3+ years 
Django experience and some sample code/ sites/ apps to qualify as a “guru” 
- so please have that available.  Please contact tschmidt at our domain, 
sacfoodcoop, which uses the popular “com” TLD, if interested.* 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/5brCoFsmXvkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to emulate parallel multi-user usability testing with django and selenium/grid?

2012-04-24 Thread Tony Schmidt


I can get my Selenium tests running fine for one user/ sequentially on 
Django 1.4 using 
LiveServerTestCase,
 
but I would like to emulate parallel multi-user testing. I don't think I 
need real load testing, since my apps are mostly moderate/low traffic 
web-sites and internal web-apps, so I would prefer to avoid extra tools 
like JMeter.

I've started out setting up Selenium Grid 
but 
am not sure how to keep my tests independent and still run multiple tests 
with multiple users. I assume the test cases should be run for different 
users on the same DB simultaneously - but each test drops and creates a new 
DB, so I don't understand how that is possible.

And I don't want to sign up for a service like 
BrowserMob
.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hNtxu6iloTAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can I use order_by and filter at the same time? (drives me nuts..!!!)

2012-03-01 Thread Tony Kyriakides
Tom thanks again for helping :)

On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!


On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!


On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!


On Thursday, March 1, 2012 3:21:41 PM UTC+2, Tony Kyriakides wrote:
>
> How can I use order_by and filter at the same time? (drives me 
> nuts..!!!) 
>
> This is what i tried: 
>
> from django.shortcuts import render_to_response 
> from vidupdate.posts.models import Entry 
> from datetime import datetime  #( I even imported the date only) 
>
>
> def entry_view(request): 
> entries = Entry.objects.all().filter(posted.date == 
> today).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(date.today()).order_by('pushes') 
>
> def entry_view(request): 
> entries = 
> Entry.objects.all().filter(datetime.date.today()).order_by('pushes') 
>
>
> I think I am wrong at the .filter()... 
> Thanks in advance..!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/PPj7HHWGGuYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How can I use order_by and filter at the same time? (drives me nuts..!!!)

2012-03-01 Thread Tony Kyriakides
How can I use order_by and filter at the same time? (drives me
nuts..!!!)

This is what i tried:

from django.shortcuts import render_to_response
from vidupdate.posts.models import Entry
from datetime import datetime  #( I even imported the date only)


def entry_view(request):
entries = Entry.objects.all().filter(posted.date ==
today).order_by('pushes')

def entry_view(request):
entries =
Entry.objects.all().filter(date.today()).order_by('pushes')

def entry_view(request):
entries =
Entry.objects.all().filter(datetime.date.today()).order_by('pushes')


I think I am wrong at the .filter()...
Thanks in advance..!!

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



Re: Can't get pagination to work in django.!!!

2012-02-28 Thread Tony Kyriakides
Sorry tom! Thanks a lot mate you just made my day!

On Feb 28, 5:34 pm, Tom Evans  wrote:
> Hi. Re-read what I said:
>
> > 24      {% for entry in entries %}
>
>            ^^^
>
> > 25      {{ entry.title }}
> > {{ entry.posted }} {{ entry.submitter }}
> > 26      {% endfor %}
>
> Compare and contrast what you are doing with 'entries' in that for
> loop and what the docs do with the equivalent object in the linked
> example, 'contacts'.
>
> This is the part of the docs I linked you to:
>
> {% for contact in contacts.object_list %}
>     {# Each "contact" is a Contact model object. #}
>     {{ contact.full_name|upper }}
>     ...
> {% endfor %}
>
> Any clearer?
>
> Cheers
>
> Tom

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



Re: Can't get pagination to work in django.!!!

2012-02-28 Thread Tony Kyriakides
hey tom its still not working :P it was easier for me to copy it from
the docs...i still get the same error

template:
Entries

{% for entry in entries %}
{{ entry.title }}
{{ entry.posted }} {{ entry.submitter }}
{% endfor %}



{% if entries.has_previous %}
previous
{% endif %}


Page {{ entries.number }} of
{{ entries.paginator.num_pages }}.


{% if entries.has_next %}
next
{% endif %}


On Feb 28, 5:01 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Tue, Feb 28, 2012 at 2:45 PM, Tony Kyriakides
>
>
>
>
>
>
>
>
>
> <tonykyriaki...@gmail.com> wrote:
> > I get this error:
>
> > Template error
>
> > In template /home/tony/Documents/vidupdate/templates/index.html, error
> > at line 24
>
> > Caught TypeError while rendering: 'Page' object is not iterable
> > 14      {% else %}
> > 15      Register
> > 16      Login
> > 17      {% endif %}
> > 18      feedback
> > 19      Contact
> > 20      
> > 21      
> > 22      Entries
> > 23      
> > 24      {% for entry in entries %}
> > 25      {{ entry.title }}
> > {{ entry.posted }} {{ entry.submitter }}
> > 26      {% endfor %}
>
> https://docs.djangoproject.com/en/1.3/topics/pagination/#using-pagina...
>
> Compare and contrast what you are doing with 'entries' in that for
> loop and what the docs do with the equivalent object in the linked
> example, 'contacts'.
>
> Your pagination links are referring to 'contacts' rather than
> 'entries' - copy/paste error there?
>
> Cheers
>
> Tom

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



Can't get pagination to work in django.!!!

2012-02-28 Thread Tony Kyriakides
I get this error:

Template error

In template /home/tony/Documents/vidupdate/templates/index.html, error
at line 24

Caught TypeError while rendering: 'Page' object is not iterable
14  {% else %}
15  Register
16  Login
17  {% endif %}
18  feedback
19  Contact
20  
21  
22  Entries
23  
24  {% for entry in entries %}
25  {{ entry.title }}
{{ entry.posted }} {{ entry.submitter }}
26  {% endfor %}
27  
28
29  
30  {% if entries.object_list and posts.paginator.num_pages > 1 %}
31  
32  
33  {% if entries.has_previous %}
34  previous

this is my view:

from django.shortcuts import render_to_response
from vidupdate.posts.models import Entry
from django.template import RequestContext
from django.core.paginator import Paginator, InvalidPage, EmptyPage

def homepage(request):
entries = Entry.objects.all().order_by('-posted')
paginator = Paginator(entries, 2)

try: page = int(request.GET.get('page', '1'))
except ValueError: page = 1

try:
entries = paginator.page(page)
except (InvalidPage, EmptyPage):
entries = paginator.page(paginator.num_pages)

return render_to_response('index.html', {'entries' : entries},
context_instance=RequestContext(request))

this is in my template:

{% for entry in entries %}
{{ entry.title }}
{{ entry.posted }} {{ entry.submitter }}
{% endfor %}




{% if contacts.has_previous %}
previous
{% endif %}


Page {{ contacts.number }} of
{{ contacts.paginator.num_pages }}.


{% if contacts.has_next %}
next
{% endif %}



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



Template Loader Error: (It's been really frustrating till now..!)

2012-01-27 Thread Tony Kyriakides
Hey all...  i get this error while i have a template directory and my
about.html file It doesn't display the home.html either...

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/about/

Django Version: 1.3.1
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/tony/Documents/blog/blog/templates/about.html (File does not
exist)
Using loader django.template.loaders.app_directories.Loader:



Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/
base.py" in get_response
  111. response = callback(request,
*callback_args, **callback_kwargs)
File "/home/tony/Documents/blog/../blog/views.py" in about
  9. return render_to_response('about.html',)
File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/
__init__.py" in render_to_response
  20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/template/
loader.py" in render_to_string
  181. t = get_template(template_name)
File "/usr/local/lib/python2.7/dist-packages/django/template/
loader.py" in get_template
  157. template, origin = find_template(template_name)
File "/usr/local/lib/python2.7/dist-packages/django/template/
loader.py" in find_template
  138. raise TemplateDoesNotExist(name)

Exception Type: TemplateDoesNotExist at /about/
Exception Value: about.html

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



Re: imagefiled don't Work

2012-01-27 Thread Tony Kyriakides
(in the terminal)
python manage.py syncdb

On Jan 21, 8:57 am, cha  wrote:
> Hello I reading this 
> tutorialhttps://pype.its.utexas.edu/docs/tutorial/unit6.html#answers
> it's work OK But When I want improve it and add ImageField in Category
> Model i have problem with ImageField It's Not uploaded
>
> file = models.ImageField(upload_to='img/%Y')
>
> see code please :
> _
> views.py
> _
> from django import forms
> class CategoryForm(forms.ModelForm):
>     class Meta:
>         model = Category
>
> def add_category(request):
>     if request.method == "POST":
>         form = CategoryForm(request.POST, request.FILES)
>         ## Handle AJAX  ##
>         if request.is_ajax():
>             if form.is_valid():
>                 form.save()
>                 # Get a list of Categories to return
>                 cats = Category.objects.all().order_by('name')
>                 # Create a dictionary for our response data
>                 data = {
>                     'error': False,
>                     'message': 'Category %s Added Successfully' %
> form.cleaned_data['name'],
>                     # Pass a list of the 'name' attribute from each
> Category.
>                     # Django model instances are not serializable
>                     'categories': [c.name for c in cats],
>                 }
>             else:
>                 # Form was not valid, get the errors from the form and
>                 # create a dictionary for our error response.
>                 data = {
>                     'error': True,
>                     'message': "Please try again! one",
>                     'name_error': str(form.errors.get('name', '')),
>                     'slug_error': str(form.errors.get('slug', '')),
>                     'file_error': str(form.errors.get('file', '')),
>                 }
>             # encode the data as a json object and return it
>             return http.HttpResponse(json.dumps(data))
>
>         ## Old Form Handler Logic ##
>         if form.is_valid():
>             form.save()
>             return http.HttpResponseRedirect('/category/')
>     else:
>         form = CategoryForm()
>     cats = Category.objects.all().order_by('name')
>     context = Context({'title': 'Add Category', 'form': form,
> 'categories': cats})
>     return render_to_response('ajax_form.html',
> context,context_instance=RequestContext(request))
>
> ___
> ajax_form.html
> ___
>
>      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
> http://www.w3.org/1999/xhtml;>
> 
>    {{ title }}
>    
>       #message {width:250px; background-color:#aaa;}
>       .hide {display: none;}
>    
>    http://ajax.googleapis.com/ajax/
> libs/jquery/1.3.2/jquery.js">
> 
> 
>
>     
>     // prepare the form when the DOM is ready
>     $(document).ready(function() {
>         $("#add_cat").ajaxStart(function() {
>             // Remove any errors/messages and fade the form.
>             $(".form_row").removeClass('errors');
>             $(".form_row_errors").html('');
>             $("#add_cat").fadeTo('slow', 0.33);
>             $("#add_cat_btn").attr('disabled', 'disabled');
>             $("#message").addClass('hide');
>         });
>
>         // Submit the form with ajax.
>         $("#add_cat").submit(function(){
>             $.post(
>                 // Grab the action url from the form.
>                 "#add_cat.getAttribute('action')",
>
>                 // Serialize the form data to send.
>                 $("#add_cat").serialize(),
>
>                 // Callback function to handle the response from view.
>                 function(resp, testStatus) {
>                     if (resp.error) {
>                         // check for field errors
>                         if (resp.name_error != '') {
>                             $("#name_row").addClass('errors');
>                             $("#name_errors").html(resp.name_error);
>                         }
>                         if (resp.slug_error != '') {
>                             $("#slug_row").addClass('errors');
>                             $("#slug_errors").html(resp.slug_error);
>                         }
>                         if (resp.file_error != '') {
>                             $("#file_row").addClass('errors');
>                             $("#file_errors").html(resp.file_error);
>                         }
>                     } else {
>                         // No errors. Rewrite the category list.
>                         $("#categories").fadeTo('fast', 0);
>                         var text = new String();
>                         for(i=0; i                             var m = resp.categories[i]
>                             text += "
  • " + m + "
  • " >                         } >                         $("#categories").html(text); >                         $("#categories").fadeTo('slow', 1); >                        

    Re: how to only allow google apps auth from one domain

    2012-01-10 Thread Tony Schmidt
    Got it: Hacked the django-social-auth Google back-end to filter by
    domain.  I'll see if the project wants to accept my changes as a
    setting.
    
    On Jan 9, 5:38 pm, Tony Schmidt <tschm...@sacfoodcoop.com> wrote:
    > I tried django-social-authand googleappsauth but both allow me to
    > authenticate from anydomain.  Has anybody had luck setting this up
    > with these, or any other packages?
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    how to only allow google apps auth from one domain

    2012-01-09 Thread Tony Schmidt
    I tried django-social-auth and googleappsauth but both allow me to
    authenticate from any domain.  Has anybody had luck setting this up
    with these, or any other packages?
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: Will template extends break the html structure?

    2011-10-19 Thread Tony Guo
    It's OK now.The source code is right,but,for using some Chinese
    character,i have to change the source file from GB2312 to UTF-8(in
    win7) during which something go wrong and caused such a error.I am
    using Ubuntu now and everything goes right.
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Will template extends break the html structure?

    2011-10-19 Thread Tony Guo
    Hi,everyone.I have had a strange problem on my homework .I load
    "index.html" template,which extends "base.html" template,in views,then
    access it through firefox and firebug show that the  markup
    seems to be broke.However,if loading "base.html" directly instead of
    "index.html" in views,it works right.My English is not good and I
    can't sure if you are able to understand ,so,they are my project files
    (including "views.py","template/base.html","template/index.html")
    following and you can test it if you like.
    Thank you.
    
    ##[views.py]
    #-*- coding: utf-8 -*-
    from django.template import RequestContext
    from django.shortcuts import render_to_response
    from django.http import HttpResponse
    from django.template.loader import get_template
    import copy
    import  time
    BaseDic={
    'NowTime':time.asctime(),
    }
    def index(request):
    dic = copy.deepcopy(BaseDic)
    dic = RequestContext(request,dic)
    return render_to_response('index.html',dic)
    ###[file end]###
    
    
    {% extends "base.html"%}
    
    
    
    
    
    
    
    
    
    {% block HEAD %}PQP Interview System{% endblock %}
    
    
    This is BODY
    
    
    
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Module or plugin architecture

    2011-10-01 Thread Tony
    Hello,
    
    I am new to Django and I have a question about module or plugin
    architecture.
    Is it possible to write a module with Django and add it to a current
    Django application.
    
    Thank you very much.
    Regards,
    Tony
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: why can't I access a dictionary with an initial form field value from my django template?

    2011-08-23 Thread Tony Schmidt
    Thanks, Reinout.
    
    I wound up creating a custom "getter" filter so I could do {{ MYDICT|
    get:myform.somefiled.value }} - which I'm surprised isn't a built-in,
    actually.  But I think your suggestion is a good alternative.
    
    Tony
    
    On Aug 23, 1:40 pm, Reinout van Rees <rein...@vanrees.org> wrote:
    > On 23-08-11 21:16, Tony Schmidt wrote:
    >
    > > I thought this should be the proper syntax in my template:
    >
    > > {{ MYDICT.myform.somefield.value }}
    >
    > > But I get a "can't parse remainder error."
    >
    > > Just putting {{ myform.somefield.value }} gives me "3" and {{ MYDICT.
    > > 3 }} gives me the dictionary value I want.
    >
    > > Am I missing something?
    >
    > MYDICT.myform looks up an 'myform' attribute on MYDICT or the 'myform'
    > key in the MYDICT dictionary. Which doesn't exist.
    >
    > There's no way the template language can know that it first has to look
    > up the last three items and then apply that to the first item. That's
    > the basic problem.
    >
    > Best solution probably: just do the MYDICT[myform.somefield.value] in
    > your view and pass the value to the template?
    >
    > Reinout
    >
    > --
    > Reinout van Rees                    http://reinout.vanrees.org/
    > rein...@vanrees.org            http://www.nelen-schuurmans.nl/
    > "If you're not sure what to do, make something. -- Paul Graham"
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    why can't I access a dictionary with an initial form field value from my django template?

    2011-08-23 Thread Tony Schmidt
    I thought this should be the proper syntax in my template:
    
    {{ MYDICT.myform.somefield.value }}
    
    But I get a "can't parse remainder error."
    
    Just putting {{ myform.somefield.value }} gives me "3" and {{ MYDICT.
    3 }} gives me the dictionary value I want.
    
    Am I missing something?
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    how can I use ipdb with runserver_plus?

    2011-08-04 Thread Tony Schmidt
    Is this possible?
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: manytomany query problem

    2011-07-18 Thread Tony
    As I still haven't solved this, any suggestions would be appreciated.
    
    On Jun 26, 10:16 pm, Tony <tonyl7...@gmail.com> wrote:
    > Alex,
    > I did it your way and although it does return the intersected sets
    > correctly, it is not exactly what I want because I need those sets to
    > be returned with their respective model A objects.  So, referring back
    > to the end result of my example above:
    > a1 to (b1,), a2 to None, a3 to (b1,)
    > I want to return this (I use the prime symbol ' to denote that these
    > are the new filtered sets):
    > a1'.b_set = (b1,) a2'.b_set = None, a3.b_set = (b1,)
    > You gave me this:
    > [(b1,), None (or does it return nothing?), (b1,)]
    > You were close, but how to I switch yours to what I want above it?
    >
    > On Jun 24, 3:36 pm, Nikhil Somaru <nsom...@gmail.com> wrote:
    >
    > > When you say 'filter' do you mean that you want some objects removed (i.e.
    > > filtered), or, do you mean that you want all the A's returned to be in a
    > > list that is sorted?
    >
    > > On Fri, Jun 24, 2011 at 5:55 AM, Tony <tonyl7...@gmail.com> wrote:
    > > > Nikhil,
    > > > This email will be significantly shorter than the one I wrote 5
    > > > minutes ago before my laptop ran out of battery and failed to get
    > > > sent.  I didn't explain this clearly so I am going to give an example
    > > > (a much smaller one than the one I jsut wrote).
    > > > Lets say I have 3 object As (a1, a2, a3) and 3 object Bs (b1, b2, b3).
    > > > the relations are as follows:
    > > > a1 to (b1, b2), a2 to (b2, b3), a3 to (b1, b3)
    > > > The user who makes the request is b2. b2 has a "friend connection"
    > > > with b1 only (so b2 to (b1,)).  It could have more friends, but for
    > > > simplicity it will have only 1.  What I want to return is this:
    > > > a1 to (b1,), a2 to None, a3 to (b1,).
    >
    > > > I always want to return all of my model "A" objects, but I want to
    > > > filter the model "B" objects within each based on who the current
    > > > user's "friend connections are".  How do I do this in code?
    >
    > > > On Jun 23, 9:02 pm, Nikhil Somaru <nsom...@gmail.com> wrote:
    > > > > Hi Tony,
    >
    > > > > Try this:
    >
    > > > > q1 = A.objects.filter(B=your_b1_instance) # that gets you all A with B =
    > > > > your_b1_instance
    > > > > q2 = A.objects.filter(B__B=your_b2_instance) #that gets you all A with
    > > > B.B =
    > > > > your_b2_instance
    > > > > result = set(q1).intersection(set(q2)) #gives you the A's that are 
    > > > > common
    > > > to
    > > > > both sets.
    > > > > result = list(result) #convert it back to a list
    >
    > > > > There might be an easier way to do it with just the ORM, but that should
    > > > > work for now
    >
    > > > > On Thu, Jun 23, 2011 at 8:46 PM, Tony <tonyl7...@gmail.com> wrote:
    > > > > > You have the question I was asking correct, your notation was fine.
    > > > > > The only thing I should add is I want to return all A, but filter  my
    > > > > > "B1"s (as you put it) for each A. I will post my models if need be,
    > > > > > but they are on another computer and its not convenient right now.  In
    > > > > > the meantime, do you have any ideas for this query?
    >
    > > > > > On Jun 23, 11:50 am, Nikhil Somaru <nsom...@gmail.com> wrote:
    > > > > > > It is very hard to read your message. Please format it appropriately
    > > > next
    > > > > > > time. Avoid repeating variable names and mixing classes with
    > > > instances.
    > > > > > > Could you post your models here?
    >
    > > > > > > Are you defining the following structure:
    >
    > > > > > > A hasMany B;
    > > > > > > B hasMany A;
    > > > > > > B hasMany B;
    >
    > > > > > > So you want* A such that A.yourB1.yourB2 exists*? Sorry for the
    > > > notation.
    >
    > > > > > > On Thu, Jun 23, 2011 at 12:03 PM, Tony <tonyl7...@gmail.com> wrote:
    > > > > > > > I have two models with a manytomany through relation (A and B).  B
    > > > has
    > > > > > > > a self referential manytomany relation (a userprofile model).  How
    > > > > > > > could I filter objects of model B per each relationship with model
    > > > A?
    > > > > > > > So lets say 3 arbitrary model A objects have 20 model B object
    > > > > > > > relations each.  I want to filter the relations so when I return
    &

    Re: manytomany query problem

    2011-06-26 Thread Tony
    Alex,
    I did it your way and although it does return the intersected sets
    correctly, it is not exactly what I want because I need those sets to
    be returned with their respective model A objects.  So, referring back
    to the end result of my example above:
    a1 to (b1,), a2 to None, a3 to (b1,)
    I want to return this (I use the prime symbol ' to denote that these
    are the new filtered sets):
    a1'.b_set = (b1,) a2'.b_set = None, a3.b_set = (b1,)
    You gave me this:
    [(b1,), None (or does it return nothing?), (b1,)]
    You were close, but how to I switch yours to what I want above it?
    
    On Jun 24, 3:36 pm, Nikhil Somaru <nsom...@gmail.com> wrote:
    > When you say 'filter' do you mean that you want some objects removed (i.e.
    > filtered), or, do you mean that you want all the A's returned to be in a
    > list that is sorted?
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > On Fri, Jun 24, 2011 at 5:55 AM, Tony <tonyl7...@gmail.com> wrote:
    > > Nikhil,
    > > This email will be significantly shorter than the one I wrote 5
    > > minutes ago before my laptop ran out of battery and failed to get
    > > sent.  I didn't explain this clearly so I am going to give an example
    > > (a much smaller one than the one I jsut wrote).
    > > Lets say I have 3 object As (a1, a2, a3) and 3 object Bs (b1, b2, b3).
    > > the relations are as follows:
    > > a1 to (b1, b2), a2 to (b2, b3), a3 to (b1, b3)
    > > The user who makes the request is b2. b2 has a "friend connection"
    > > with b1 only (so b2 to (b1,)).  It could have more friends, but for
    > > simplicity it will have only 1.  What I want to return is this:
    > > a1 to (b1,), a2 to None, a3 to (b1,).
    >
    > > I always want to return all of my model "A" objects, but I want to
    > > filter the model "B" objects within each based on who the current
    > > user's "friend connections are".  How do I do this in code?
    >
    > > On Jun 23, 9:02 pm, Nikhil Somaru <nsom...@gmail.com> wrote:
    > > > Hi Tony,
    >
    > > > Try this:
    >
    > > > q1 = A.objects.filter(B=your_b1_instance) # that gets you all A with B =
    > > > your_b1_instance
    > > > q2 = A.objects.filter(B__B=your_b2_instance) #that gets you all A with
    > > B.B =
    > > > your_b2_instance
    > > > result = set(q1).intersection(set(q2)) #gives you the A's that are common
    > > to
    > > > both sets.
    > > > result = list(result) #convert it back to a list
    >
    > > > There might be an easier way to do it with just the ORM, but that should
    > > > work for now
    >
    > > > On Thu, Jun 23, 2011 at 8:46 PM, Tony <tonyl7...@gmail.com> wrote:
    > > > > You have the question I was asking correct, your notation was fine.
    > > > > The only thing I should add is I want to return all A, but filter  my
    > > > > "B1"s (as you put it) for each A. I will post my models if need be,
    > > > > but they are on another computer and its not convenient right now.  In
    > > > > the meantime, do you have any ideas for this query?
    >
    > > > > On Jun 23, 11:50 am, Nikhil Somaru <nsom...@gmail.com> wrote:
    > > > > > It is very hard to read your message. Please format it appropriately
    > > next
    > > > > > time. Avoid repeating variable names and mixing classes with
    > > instances.
    > > > > > Could you post your models here?
    >
    > > > > > Are you defining the following structure:
    >
    > > > > > A hasMany B;
    > > > > > B hasMany A;
    > > > > > B hasMany B;
    >
    > > > > > So you want* A such that A.yourB1.yourB2 exists*? Sorry for the
    > > notation.
    >
    > > > > > On Thu, Jun 23, 2011 at 12:03 PM, Tony <tonyl7...@gmail.com> wrote:
    > > > > > > I have two models with a manytomany through relation (A and B).  B
    > > has
    > > > > > > a self referential manytomany relation (a userprofile model).  How
    > > > > > > could I filter objects of model B per each relationship with model
    > > A?
    > > > > > > So lets say 3 arbitrary model A objects have 20 model B object
    > > > > > > relations each.  I want to filter the relations so when I return
    > > the
    > > > > > > filtered version of model A is outputted, each object of type model
    > > A
    > > > > > > returns only object Bs (the userprofiles) that are connected
    > > through
    > > > > > > the self referential manytomany relationship to the userprofile
    > > (the
    > > > > > > object B, sorry if I use them interchangeably but they are the same
    > > > > > > thing) that is currently se

    Re: manytomany query problem

    2011-06-26 Thread Tony
    It means I want some objects of type B to be filtered within their
    parent relation of model A.  I am about to try Alex's suggestion, but
    any other suggestions would be great too and I will let you guys know
    if it works.
    
    On Jun 24, 3:36 pm, Nikhil Somaru <nsom...@gmail.com> wrote:
    > When you say 'filter' do you mean that you want some objects removed (i.e.
    > filtered), or, do you mean that you want all the A's returned to be in a
    > list that is sorted?
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > On Fri, Jun 24, 2011 at 5:55 AM, Tony <tonyl7...@gmail.com> wrote:
    > > Nikhil,
    > > This email will be significantly shorter than the one I wrote 5
    > > minutes ago before my laptop ran out of battery and failed to get
    > > sent.  I didn't explain this clearly so I am going to give an example
    > > (a much smaller one than the one I jsut wrote).
    > > Lets say I have 3 object As (a1, a2, a3) and 3 object Bs (b1, b2, b3).
    > > the relations are as follows:
    > > a1 to (b1, b2), a2 to (b2, b3), a3 to (b1, b3)
    > > The user who makes the request is b2. b2 has a "friend connection"
    > > with b1 only (so b2 to (b1,)).  It could have more friends, but for
    > > simplicity it will have only 1.  What I want to return is this:
    > > a1 to (b1,), a2 to None, a3 to (b1,).
    >
    > > I always want to return all of my model "A" objects, but I want to
    > > filter the model "B" objects within each based on who the current
    > > user's "friend connections are".  How do I do this in code?
    >
    > > On Jun 23, 9:02 pm, Nikhil Somaru <nsom...@gmail.com> wrote:
    > > > Hi Tony,
    >
    > > > Try this:
    >
    > > > q1 = A.objects.filter(B=your_b1_instance) # that gets you all A with B =
    > > > your_b1_instance
    > > > q2 = A.objects.filter(B__B=your_b2_instance) #that gets you all A with
    > > B.B =
    > > > your_b2_instance
    > > > result = set(q1).intersection(set(q2)) #gives you the A's that are common
    > > to
    > > > both sets.
    > > > result = list(result) #convert it back to a list
    >
    > > > There might be an easier way to do it with just the ORM, but that should
    > > > work for now
    >
    > > > On Thu, Jun 23, 2011 at 8:46 PM, Tony <tonyl7...@gmail.com> wrote:
    > > > > You have the question I was asking correct, your notation was fine.
    > > > > The only thing I should add is I want to return all A, but filter  my
    > > > > "B1"s (as you put it) for each A. I will post my models if need be,
    > > > > but they are on another computer and its not convenient right now.  In
    > > > > the meantime, do you have any ideas for this query?
    >
    > > > > On Jun 23, 11:50 am, Nikhil Somaru <nsom...@gmail.com> wrote:
    > > > > > It is very hard to read your message. Please format it appropriately
    > > next
    > > > > > time. Avoid repeating variable names and mixing classes with
    > > instances.
    > > > > > Could you post your models here?
    >
    > > > > > Are you defining the following structure:
    >
    > > > > > A hasMany B;
    > > > > > B hasMany A;
    > > > > > B hasMany B;
    >
    > > > > > So you want* A such that A.yourB1.yourB2 exists*? Sorry for the
    > > notation.
    >
    > > > > > On Thu, Jun 23, 2011 at 12:03 PM, Tony <tonyl7...@gmail.com> wrote:
    > > > > > > I have two models with a manytomany through relation (A and B).  B
    > > has
    > > > > > > a self referential manytomany relation (a userprofile model).  How
    > > > > > > could I filter objects of model B per each relationship with model
    > > A?
    > > > > > > So lets say 3 arbitrary model A objects have 20 model B object
    > > > > > > relations each.  I want to filter the relations so when I return
    > > the
    > > > > > > filtered version of model A is outputted, each object of type model
    > > A
    > > > > > > returns only object Bs (the userprofiles) that are connected
    > > through
    > > > > > > the self referential manytomany relationship to the userprofile
    > > (the
    > > > > > > object B, sorry if I use them interchangeably but they are the same
    > > > > > > thing) that is currently sending in the request.  I figure out
    > > which
    > > > > > > userprofile is sending the request with a unique identifier sent by
    > > > > > > the user in the request (basically their primary key).  Is this
    > > type
    > > > > > > of filtering possible.
    >
    > > > > > > --
    >

    Re: manytomany query problem

    2011-06-23 Thread Tony
    Nikhil,
    This email will be significantly shorter than the one I wrote 5
    minutes ago before my laptop ran out of battery and failed to get
    sent.  I didn't explain this clearly so I am going to give an example
    (a much smaller one than the one I jsut wrote).
    Lets say I have 3 object As (a1, a2, a3) and 3 object Bs (b1, b2, b3).
    the relations are as follows:
    a1 to (b1, b2), a2 to (b2, b3), a3 to (b1, b3)
    The user who makes the request is b2. b2 has a "friend connection"
    with b1 only (so b2 to (b1,)).  It could have more friends, but for
    simplicity it will have only 1.  What I want to return is this:
    a1 to (b1,), a2 to None, a3 to (b1,).
    
    I always want to return all of my model "A" objects, but I want to
    filter the model "B" objects within each based on who the current
    user's "friend connections are".  How do I do this in code?
    
    On Jun 23, 9:02 pm, Nikhil Somaru <nsom...@gmail.com> wrote:
    > Hi Tony,
    >
    > Try this:
    >
    > q1 = A.objects.filter(B=your_b1_instance) # that gets you all A with B =
    > your_b1_instance
    > q2 = A.objects.filter(B__B=your_b2_instance) #that gets you all A with B.B =
    > your_b2_instance
    > result = set(q1).intersection(set(q2)) #gives you the A's that are common to
    > both sets.
    > result = list(result) #convert it back to a list
    >
    > There might be an easier way to do it with just the ORM, but that should
    > work for now
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > On Thu, Jun 23, 2011 at 8:46 PM, Tony <tonyl7...@gmail.com> wrote:
    > > You have the question I was asking correct, your notation was fine.
    > > The only thing I should add is I want to return all A, but filter  my
    > > "B1"s (as you put it) for each A. I will post my models if need be,
    > > but they are on another computer and its not convenient right now.  In
    > > the meantime, do you have any ideas for this query?
    >
    > > On Jun 23, 11:50 am, Nikhil Somaru <nsom...@gmail.com> wrote:
    > > > It is very hard to read your message. Please format it appropriately next
    > > > time. Avoid repeating variable names and mixing classes with instances.
    > > > Could you post your models here?
    >
    > > > Are you defining the following structure:
    >
    > > > A hasMany B;
    > > > B hasMany A;
    > > > B hasMany B;
    >
    > > > So you want* A such that A.yourB1.yourB2 exists*? Sorry for the notation.
    >
    > > > On Thu, Jun 23, 2011 at 12:03 PM, Tony <tonyl7...@gmail.com> wrote:
    > > > > I have two models with a manytomany through relation (A and B).  B has
    > > > > a self referential manytomany relation (a userprofile model).  How
    > > > > could I filter objects of model B per each relationship with model A?
    > > > > So lets say 3 arbitrary model A objects have 20 model B object
    > > > > relations each.  I want to filter the relations so when I return the
    > > > > filtered version of model A is outputted, each object of type model A
    > > > > returns only object Bs (the userprofiles) that are connected through
    > > > > the self referential manytomany relationship to the userprofile (the
    > > > > object B, sorry if I use them interchangeably but they are the same
    > > > > thing) that is currently sending in the request.  I figure out which
    > > > > userprofile is sending the request with a unique identifier sent by
    > > > > the user in the request (basically their primary key).  Is this type
    > > > > of filtering possible.
    >
    > > > > --
    > > > > You received this message because you are subscribed to the Google
    > > Groups
    > > > > "Django users" group.
    > > > > To post to this group, send email to django-users@googlegroups.com.
    > > > > To unsubscribe from this group, send email to
    > > > > django-users+unsubscr...@googlegroups.com.
    > > > > For more options, visit this group at
    > > > >http://groups.google.com/group/django-users?hl=en.
    >
    > > > --
    > > > Yours,
    > > > Nikhil Somaru
    >
    > > --
    > > You received this message because you are subscribed to the Google Groups
    > > "Django users" group.
    > > To post to this group, send email to django-users@googlegroups.com.
    > > To unsubscribe from this group, send email to
    > > django-users+unsubscr...@googlegroups.com.
    > > For more options, visit this group at
    > >http://groups.google.com/group/django-users?hl=en.
    >
    > --
    > Yours,
    > Nikhil Somaru
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: manytomany query problem

    2011-06-23 Thread Tony
    You have the question I was asking correct, your notation was fine.
    The only thing I should add is I want to return all A, but filter  my
    "B1"s (as you put it) for each A. I will post my models if need be,
    but they are on another computer and its not convenient right now.  In
    the meantime, do you have any ideas for this query?
    
    On Jun 23, 11:50 am, Nikhil Somaru <nsom...@gmail.com> wrote:
    > It is very hard to read your message. Please format it appropriately next
    > time. Avoid repeating variable names and mixing classes with instances.
    > Could you post your models here?
    >
    > Are you defining the following structure:
    >
    > A hasMany B;
    > B hasMany A;
    > B hasMany B;
    >
    > So you want* A such that A.yourB1.yourB2 exists*? Sorry for the notation.
    >
    >
    >
    > On Thu, Jun 23, 2011 at 12:03 PM, Tony <tonyl7...@gmail.com> wrote:
    > > I have two models with a manytomany through relation (A and B).  B has
    > > a self referential manytomany relation (a userprofile model).  How
    > > could I filter objects of model B per each relationship with model A?
    > > So lets say 3 arbitrary model A objects have 20 model B object
    > > relations each.  I want to filter the relations so when I return the
    > > filtered version of model A is outputted, each object of type model A
    > > returns only object Bs (the userprofiles) that are connected through
    > > the self referential manytomany relationship to the userprofile (the
    > > object B, sorry if I use them interchangeably but they are the same
    > > thing) that is currently sending in the request.  I figure out which
    > > userprofile is sending the request with a unique identifier sent by
    > > the user in the request (basically their primary key).  Is this type
    > > of filtering possible.
    >
    > > --
    > > You received this message because you are subscribed to the Google Groups
    > > "Django users" group.
    > > To post to this group, send email to django-users@googlegroups.com.
    > > To unsubscribe from this group, send email to
    > > django-users+unsubscr...@googlegroups.com.
    > > For more options, visit this group at
    > >http://groups.google.com/group/django-users?hl=en.
    >
    > --
    > Yours,
    > Nikhil Somaru
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    manytomany query problem

    2011-06-23 Thread Tony
    I have two models with a manytomany through relation (A and B).  B has
    a self referential manytomany relation (a userprofile model).  How
    could I filter objects of model B per each relationship with model A?
    So lets say 3 arbitrary model A objects have 20 model B object
    relations each.  I want to filter the relations so when I return the
    filtered version of model A is outputted, each object of type model A
    returns only object Bs (the userprofiles) that are connected through
    the self referential manytomany relationship to the userprofile (the
    object B, sorry if I use them interchangeably but they are the same
    thing) that is currently sending in the request.  I figure out which
    userprofile is sending the request with a unique identifier sent by
    the user in the request (basically their primary key).  Is this type
    of filtering possible.
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    unique identifier to distinguish an instance

    2011-04-06 Thread Tony
    so I have two models, A and B.  B has a foreignkey relationship in it
    from A (To be clear because I know I dont explain it that well, one A
    has many Bs).  for each group of Bs each A is connected with, I want
    there to be a way to mark one of the Bs as unique from the rest of
    them.  I added in an extra field called unique_identifier that is a
    booleanfield. The problem is I dont know the best way to go about
    making sure there is only one B instance marked True for the
    unique_identifier field for each set of Bs.  What would be a good way
    to ensure there is one and only one instance marked True?
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: model manager and request

    2011-03-30 Thread Tony
    yeah, shawn said the exact dilemma I am having.  I am working with a
    plugged in app and dont want to change its code and mess with its
    views and create a new fork, it just seems like small thing to make a
    change for (and I would probably mess something else up).
    
    On Mar 30, 11:58 am, Shawn Milochik  wrote:
    > Jacob,
    >
    > This sort of thing comes up so frequently on this list that we've all
    > seen those answers dozens of times, although not usually in so concise
    > a manner.
    >
    > My question, to which there seems to be no answer, is what a good
    > approach to do something that I know (from spending a long time on
    > this list) is also in high demand: Storing audit information.
    >
    > Simple requirement:
    >     Store datetime.now(), request.user, and changes to a model
    > automatically on post_save.
    >
    > Problem:
    >     The "correct" solutions do not work. If you're using any pluggable
    > apps at all you have to fork them or not log them. Refactoring is not
    > an option.
    >
    > I understand why request information is simply not in scope in
    > models.py. This isn't a rant or a demand for a fundamental change to
    > the way Django works. I'm just looking for either:
    >
    >     1. A definitive "This is currently impossible in Django."
    >
    >     2. This is possible with this clever hack/middleware/pseudocode/whatever.
    >
    > Obviously this method (should it exist) allows a lot of bad designs in
    > Django apps. But for the case of applying automatic logging in a
    > Django project, it seems like a reasonable desire. Especially given
    > that, as Django is a Web framework, there is always a request and
    > always a user (even if it's an anonymous user).
    >
    > Your thoughts would be greatly appreciated. I'll also be attending
    > your webinar tomorrow. If you find this question to be in scope or
    > have extra time then I'd love to see it addressed.
    >
    > Thank you,
    > Shawn
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    model manager and request

    2011-03-30 Thread Tony
    Is there a way to use the "request.user" attributes in a custom model
    manager?  So I could filter by certain attributes the current logged
    in user has?  This is the preferable way I would like to filter the
    objects the user sees, so if there is a way, I would appreciate the
    help.  If there is no way to do it like this, I would be open to other
    suggestions although, the way my project is structured I dont want to
    do this in my view functions.
    thanks for any help
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: embedding tag in another tag

    2011-03-23 Thread Tony
    there is a form called F, and I am trying to set its "action"
    attribute dynamically with javascript.  I can do this successfully.
    However, when I try to use one tag in another like this: url_1 = {%
    page_url '{% page_attribute "slug"%}/{{id}}/vote/' %} (these are
    django-cms tags), I get a parsing error.  Ive also tried to put '{%
    page_attribute "slug"%}/{{id}}/vote/' into a variable (url_2) and do
    {% page_url url_2 %}, but the tag didn't recognize the variable as a
    variable but took url_2 as a null.  Is there anything I can do to get
    this to parse correctly?  Do I have to go into the django-cms template
    tags folder and change the code?  That seems like it could get messy.
    
    On Mar 23, 1:18 pm, delegb...@dudupay.com wrote:
    > What exactly are you trying to get done or achieve?
    >
    > If that is known, we could be able to help.
    > Sent from my BlackBerry wireless device from MTN
    >
    >
    >
    >
    >
    >
    >
    > -Original Message-
    > From: Tony <tonyl7...@gmail.com>
    >
    > Sender: django-users@googlegroups.com
    > Date: Wed, 23 Mar 2011 13:06:13
    > To: Django users<django-users@googlegroups.com>
    > Reply-To: django-users@googlegroups.com
    > Subject: embedding tag in another tag
    >
    > I have two tags, and I am trying to put together a dynamic form action
    > url.  For the url to come together lke I want, one would be embedded
    > in the other, but when i try to do it this way, I get a parsing
    > error.  I've also tried using javascript and variables but the tags
    > dont read the variable like it should, it just reads the actual
    > variable name.  Are there any possible work arounds?
    >
    > --
    > You received this message because you are subscribed to the Google Groups 
    > "Django users" group.
    > To post to this group, send email to django-users@googlegroups.com.
    > To unsubscribe from this group, send email to 
    > django-users+unsubscr...@googlegroups.com.
    > For more options, visit this group 
    > athttp://groups.google.com/group/django-users?hl=en.
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: suspiciousoperation with file upload on django-cms

    2011-03-23 Thread Tony
    Ive tried it the other way but when it appends the filename the final
    slash is the other way.  Either way, the octal thing you said hasn't
    had an effect Im pretty sure.  The url in the error message appears to
    be the path it should be.  Is there any other reason?
    
    On Mar 23, 4:10 pm, Karen Tracey <kmtra...@gmail.com> wrote:
    > On Wed, Mar 23, 2011 at 3:26 PM, Tony <tonyl7...@gmail.com> wrote:
    > > It uses my CMS_PAGE_MEDIA_PATH, which is 'C:\Users\Tony\Documents\My
    > > Music\1'.  Maybe this is the problem, but I dont know how to
    > > explicitely tell Django to use my MEDIA_ROOT.
    >
    > Assuming that string is literally what you are using in your settings,
    > replace the backslashes with forward slashes. \1 is interpreted as an octal
    > escape sequence, which you do not want.
    >
    > Karen
    > --http://tracey.org/kmt/
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    embedding tag in another tag

    2011-03-23 Thread Tony
    I have two tags, and I am trying to put together a dynamic form action
    url.  For the url to come together lke I want, one would be embedded
    in the other, but when i try to do it this way, I get a parsing
    error.  I've also tried using javascript and variables but the tags
    dont read the variable like it should, it just reads the actual
    variable name.  Are there any possible work arounds?
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    Re: suspiciousoperation with file upload on django-cms

    2011-03-23 Thread Tony
    It uses my CMS_PAGE_MEDIA_PATH, which is 'C:\Users\Tony\Documents\My
    Music\1'.  Maybe this is the problem, but I dont know how to
    explicitely tell Django to use my MEDIA_ROOT.
    
    On Mar 22, 8:45 pm, Karen Tracey <kmtra...@gmail.com> wrote:
    > On Tue, Mar 22, 2011 at 5:12 PM, Tony <tonyl7...@gmail.com> wrote:
    > >  I have looked at my media_url and
    > > media_root, and played with them but I haven't been able to have any
    > > success.
    >
    > MEDIA_URL isn't relevant for the problem you are reporting. MEDIA_ROOT is.
    > It would help people help you if you shared what value you have been trying
    > for MEDIA_ROOT.
    >
    > Karen
    > --http://tracey.org/kmt/
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-users@googlegroups.com.
    To unsubscribe from this group, send email to 
    django-users+unsubscr...@googlegroups.com.
    For more options, visit this group at 
    http://groups.google.com/group/django-users?hl=en.
    
    
    

    suspiciousoperation with file upload on django-cms

    2011-03-22 Thread Tony
    I am using django-cms for my project right now and I am using their
    file and image plugins on my pages, but when I try to upload a file, I
    get a suspiciousoperation error.  I have looked at my media_url and
    media_root, and played with them but I haven't been able to have any
    success.  There is also a django cms media root which I have played
    with too.  I have gotten this error on the dev server as well as
    apache.  I have set file upload permissions to 0644 as well (which was
    recommended by others with similar problems).  All other media files
    work properly.  Here is my traceback.
    
    
    Environment:
    
    Request Method: POST
    Request URL: 
    http://localhost:8000/admin/cms/page/1/edit-plugin/13/?popup=true_preview
    Django Version: 1.2.4
    Python Version: 2.7.1
    Installed Applications:
    ['django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.admin',
     'django.contrib.admindocs',
     'menus',
     'mptt',
     'appmedia',
     'south',
     'cms.plugins.text',
     'cms.plugins.picture',
     'cms.plugins.link',
     'cms.plugins.file',
     'cms.plugins.snippet',
     'cms.plugins.googlemap',
     'publisher',
     'myproject.polls',
     'social_auth',
     'registration',
     'voting',
     'cms']
    Installed Middleware:
    ('django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'cms.middleware.page.CurrentPageMiddleware',
     'cms.middleware.user.CurrentUserMiddleware',
     'cms.middleware.toolbar.ToolbarMiddleware',
     'cms.middleware.media.PlaceholderMediaMiddleware')
    
    
    Traceback:
    File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
    get_response
      100. response = callback(request,
    *callback_args, **callback_kwargs)
    File "C:\Python27\lib\site-packages\django\utils\decorators.py" in
    _wrapped_view
      76. response = view_func(request, *args,
    **kwargs)
    File "C:\Python27\lib\site-packages\django\views\decorators\cache.py"
    in _wrapped_view_func
      78. response = view_func(request, *args, **kwargs)
    File "C:\Python27\lib\site-packages\django\contrib\admin\sites.py" in
    inner
      190. return view(request, *args, **kwargs)
    File "C:\Python27\lib\site-packages\cms\admin\pageadmin.py" in
    edit_plugin
      1239. response = plugin_admin.add_view(request)
    File "C:\Python27\lib\site-packages\django\utils\decorators.py" in
    _wrapper
      21. return decorator(bound_func)(*args, **kwargs)
    File "C:\Python27\lib\site-packages\django\utils\decorators.py" in
    _wrapped_view
      76. response = view_func(request, *args,
    **kwargs)
    File "C:\Python27\lib\site-packages\django\utils\decorators.py" in
    bound_func
      17. return func(self, *args2, **kwargs2)
    File "C:\Python27\lib\site-packages\django\db\transaction.py" in
    _commit_on_success
      299. res = func(*args, **kw)
    File "C:\Python27\lib\site-packages\django\contrib\admin\options.py"
    in add_view
      821. self.save_model(request, new_object, form,
    change=False)
    File "C:\Python27\lib\site-packages\cms\plugin_base.py" in save_model
      169. return super(CMSPluginBase, self).save_model(request,
    obj, form, change)
    File "C:\Python27\lib\site-packages\django\contrib\admin\options.py"
    in save_model
      623. obj.save()
    File "C:\Python27\lib\site-packages\cms\models\pluginmodel.py" in save
      206. super(CMSPlugin, self).save()
    File "C:\Python27\lib\site-packages\django\db\models\base.py" in save
      456. self.save_base(using=using, force_insert=force_insert,
    force_update=force_update)
    File "C:\Python27\lib\site-packages\django\db\models\base.py" in
    save_base
      542. for f in meta.local_fields]
    File "C:\Python27\lib\site-packages\django\db\models\fields\files.py"
    in pre_save
      255. file.save(file.name, file, save=False)
    File "C:\Python27\lib\site-packages\django\db\models\fields\files.py"
    in save
      92. self.name = self.storage.save(name, content)
    File "C:\Python27\lib\site-packages\django\core\files\storage.py" in
    save
      47. name = self.get_available_name(name)
    File "C:\Python27\lib\site-packages\django\core\files\storage.py" in
    get_available_name
      73. while self.exists(name):
    File "C:\Python27\lib\site-packages\django\core\files\storage.py" in
    exists
      196. return os.path.exists(self.path(name))
    File "C:\Python27\lib\site-packages\django\core\files\storage.py" in
    path
      212. raise SuspiciousOperation("Attempted access to '%s'
    denied." % name)
    
    Exception Type: SuspiciousOperation at /admin/cms/page/1/edi

      1   2   >