Re: Live server tests from cron

2013-08-10 Thread Drew Ferguson
Hi 

I don't know anything about selenium.

However, from what you are describing - trying to run an application from
cron that requires an Xserver - is problematic i.e. there is generally no
Xserver available that can be used so your "DISPLAY=:0.0" essentially has
no effect.

To get round this, you may need to launch an X server whenever your cron
job kicks off. You can do this by creating a virtual X server using Xvfb.
In the past I have used the script xvfb-run to achieve this; this article
pointed the way

http://www.flexthinker.com/2009/09/building-a-flex-project-with-maven-using-hudson-on-centos/

If you think this might be the way to go, feel free to contact me off list
as it has nothing really to do with django.


On Sat, 10 Aug 2013 16:56:32 -0600
Larry Martell  wrote:

> I have some tests that use LiveServerTestCase and selenium. When I run
> them from the command line they work fine. But I want to run them from
> cron. I know I need to use pyvirtualdisplay, but I can't seem to get
> it to work.
> 
> I have this in my test:
> 
> from pyvirtualdisplay import Display
> 
> @classmethod
> def setUpClass(cls):
> #initialize HIDDEN display
> display = Display(visible=0, size=(800, 600))
> display.start()
> 
> cls.selenium = WebDriver()
> super(EventsTableTestLive, cls).setUpClass()
> 
> But it fails with:
> 
> WebDriverException: Message: 'The browser appears to have exited
> before we could connect. The output was: Error: cannot open display:
> :1024\n'
> 
> Where the display number is different each time. Googling this, I saw
> that I needed to add something like this to the script I run from cron
> that invokes the tests:
> 
> export DISPLAY=:0.0
> xhost +
> 
> But that seems to have had no effect at all. This question seems to
> have been asked a lot, but none of the answers I saw on SO or other
> sites worked for me (none of them were using django).
> 
> Anyone here run LiveServerTestCase selenium tests from cron?
> 
> Thanks!
> -larry
> 



-- 
Drew Ferguson

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

2013-08-10 Thread Aaron C. de Bruyn
Google is your friend.

The first tutorial that came up when I searched for 'ssh for windows users'
was this site:
http://support.suso.com/supki/SSH_Tutorial_for_Windows

Do you have an existing Linux server at your house or with a hosting
provider?

If managing a Linux server is too steep of a learning curve, there are
several providers out there that will do that for you and provide you a
simple way to deploy your application.

A good resource is Django Hosting: http://djangohosting.com/

Each provider has different requirements for 'automagically' deploying your
site.  Some use 'requirements.txt' file or a 'Procfile'.

Some people find Heroku easy and cheap for deploying small test
applications: https://www.heroku.com/

If you have specific questions, please ask them and the community would be
glad to assist.

-A



On Sat, Aug 10, 2013 at 3:27 PM, Robin Lery  wrote:

> Hello,
> I am a windows user, and its great learning django and python as well. I
> am just curious that, when I happen to deploy my site for production, is it
> helpful to deploy in unix system. And if there is, please guide me to use
> ssh and other stuff that is required to deploy so. Any help will be highly
> appreciated.
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> 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.




Live server tests from cron

2013-08-10 Thread Larry Martell
I have some tests that use LiveServerTestCase and selenium. When I run
them from the command line they work fine. But I want to run them from
cron. I know I need to use pyvirtualdisplay, but I can't seem to get
it to work.

I have this in my test:

from pyvirtualdisplay import Display

@classmethod
def setUpClass(cls):
#initialize HIDDEN display
display = Display(visible=0, size=(800, 600))
display.start()

cls.selenium = WebDriver()
super(EventsTableTestLive, cls).setUpClass()

But it fails with:

WebDriverException: Message: 'The browser appears to have exited
before we could connect. The output was: Error: cannot open display:
:1024\n'

Where the display number is different each time. Googling this, I saw
that I needed to add something like this to the script I run from cron
that invokes the tests:

export DISPLAY=:0.0
xhost +

But that seems to have had no effect at all. This question seems to
have been asked a lot, but none of the answers I saw on SO or other
sites worked for me (none of them were using django).

Anyone here run LiveServerTestCase selenium tests from cron?

Thanks!
-larry

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

2013-08-10 Thread Robin Lery
Hello,
I am a windows user, and its great learning django and python as well. I am
just curious that, when I happen to deploy my site for production, is it
helpful to deploy in unix system. And if there is, please guide me to use
ssh and other stuff that is required to deploy so. Any help will be highly
appreciated.
Thank you.

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


Re: Newbie: do I need to upload in order to access data?

2013-08-10 Thread Nigel Legg
The file is uploaded - ie it is copied onto the server drive.
I don't think you can do stuff client side with Django - beyond my
knowledge.

Regards,
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 10 August 2013 18:04, Bob Aalsma  wrote:

> Thanks Nigel, this looks very promising ;)
>
> If I interpret your text correctly, this is based on the upload/save
> example I mentioned.
> I'm really interested in the meaning of parts your closing paragraph:
>
>- "This saves the file in 'media/documents/2013/08/10/**datafile.csv'."
>- I think this means the contents of the file is copied from the user disk
>to my disk, right?
>- "pointing them to the correct directory and file." - could I not
>simply point to the *original* directory and file (on the user's
>machine) and read the contents from that location?
>
>
> Regards,
> Bob
>
> Op zaterdag 10 augustus 2013 18:39:38 UTC+2 schreef Nigel Legg:
>>
>> I've based my process a minimal file upload - I think based on the answer
>> to the link above.  I use:
>> models.py:
>> class Document(models.Model):
>> docfile = models.FileField(upload_to='**documents/%Y/%m/%d')
>>
>> views.py:
>> def list(request):
>> # Handle file uploadf
>> if request.method == 'POST':
>> form = DocumentForm(request.POST, request.FILES)
>> if form.is_valid():
>> newdoc = Document(docfile = request.FILES['docfile'])
>> newdoc.save()
>>
>> # Redirect to the document list after POST
>> return HttpResponseRedirect(reverse('**
>> myproject.myapp.views.list'))
>> else:
>> form = DocumentForm() # A empty, unbound form
>>
>> # Load documents for the list page
>> documents = Document.objects.all()
>>
>> # Render list page with the documents and the form
>> return render_to_response(
>> 'myapp/list.html',
>> {'documents': documents, 'form': form},
>> context_instance=**RequestContext(request)
>> )
>>
>> forms.py:
>> class DocumentForm(forms.Form):
>> docfile = forms.FileField(
>> label='Select a file',
>> help_text='max. 42 megabytes'
>> )
>>
>> This saves the file in 'media/documents/2013/08/10/**datafile.csv'.  You
>> can then access this using the normal open() and read() functions, pointing
>> them to the correct directory and file.  As far as I can see, the data
>> remains in the file you upload, but the location and name are stored in the
>> database - in this case, "documents/2013/10/08/**datafile.csv".
>>
>> Hope this helps
>>
>> Regards,
>> Nigel Legg
>> 07914 740972
>> http://www.trevanianlegg.co.uk
>> http://twitter.com/nigellegg
>> http://uk.linkedin.com/in/**nigellegg
>>
>>
>>
>> On 10 August 2013 15:52, Bob Aalsma  wrote:
>>
>>> Hi,
>>>
>>> I'm trying to achieve the following:
>>>
>>>- user indicates a file on his/her machine
>>>- the program opens the file, reads the data and acts on that
>>>
>>>
>>> So far, I can find examples of indicating the file on the user's
>>> machine, but this is always combined with saving to database (which I don't
>>> want); the clearest example I could find is http://stackoverflow.com/**
>>> questions/5871730/need-a-**minimal-django-file-upload-**example
>>>
>>> Question 1: is it really necessary to store the data in my database?
>>>
>>> If not, I've not been able to find how to actually open and read the
>>> file.
>>> I've been trying out variations on reading, based on what I could find
>>> in the Tutorials and Managing files (https://docs.djangoproject.**
>>> com/en/1.5/topics/files/)
>>>  but I don't seem to understand how to actually find the path and filename
>>> the user would have indicated. I seem to get completely lost in FileField
>>> and FieldFile and connected methods 
>>>
>>> Question 2: how do I find the indicated path and filename from the user?
>>>
>>> Regards,
>>> Bob
>>>
>>> --
>>> 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
>>> .
>>> 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 

Re: Django Calendar App Just Like Google Calendar

2013-08-10 Thread Tito Gonzales
I made a conector for DHTMLxScheduler for python/django with JS/Ajax.
https://github.com/tgonzales/dhtmlx-scheduler-django

Makes a clone and run with django 1.5, to customize visit
http://dhtmlx.com/docs/products/dhtmlxScheduler/index.shtml



Em sábado, 12 de janeiro de 2013 04h59min50s UTC-2, kashif escreveu:
>
> Hello Guys,
>
> Is there any django app available that is a replica of google calendar?
> I have checked django-scheduler, django-swingtime and couple of more but 
> the hardest part with these apps/projects is the limited documentation.
> Can anybody please guide me what app can serve my purpose?
>
> Thanks,
> Kashif 
>

-- 
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: Adding YouTube video id to url

2013-08-10 Thread Sithembewena Lloyd Dube
Sorted. I got owned by regex :-/

In urls.py, it should be:

url(r'^watch/(?P[\w{}.-]{1,40})/$', 'find_music.views.watch',
name='watch'),

(see
http://stackoverflow.com/questions/15951948/django-url-for-40-characters-alphanumeric
)

Thanks.


On Sat, Aug 10, 2013 at 10:36 PM, Sithembewena Lloyd Dube  wrote:

> P.S: The view looks like the following:
>
> def watch(request, video_id):
> return HttpResponse("This is the watch page for %s") % video_id
>
>
> On Sat, Aug 10, 2013 at 10:31 PM, Sithembewena Lloyd Dube <
> zebr...@gmail.com> wrote:
>
>> Hi,
>>
>> I am using the YouTube API to fetch video data and display it on a web
>> page. As part of the html template I have an anchor tag with an href
>> directing to my Django 1.5 app. as follows:
>>
>> 
>>
>> The url definition in urls.py is as follows:
>>
>> url(r'^(?P\w+)$', 'find_music.views.watch', name='watch'),
>>
>> When I load the page, I get a NoReverseMatch exception as follows:
>>
>> Reverse for 'watch' with arguments '()' and keyword arguments '{u'video_id': 
>> 'D-dNA0NwLSw'}' not found.
>>
>>
>> What could I be missing?
>>
>> Thanks.
>>
>> --
>> Regards,
>> Sithu Lloyd Dube
>>
>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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: Adding YouTube video id to url

2013-08-10 Thread Sithembewena Lloyd Dube
P.S: The view looks like the following:

def watch(request, video_id):
return HttpResponse("This is the watch page for %s") % video_id


On Sat, Aug 10, 2013 at 10:31 PM, Sithembewena Lloyd Dube  wrote:

> Hi,
>
> I am using the YouTube API to fetch video data and display it on a web
> page. As part of the html template I have an anchor tag with an href
> directing to my Django 1.5 app. as follows:
>
> 
>
> The url definition in urls.py is as follows:
>
> url(r'^(?P\w+)$', 'find_music.views.watch', name='watch'),
>
> When I load the page, I get a NoReverseMatch exception as follows:
>
> Reverse for 'watch' with arguments '()' and keyword arguments '{u'video_id': 
> 'D-dNA0NwLSw'}' not found.
>
>
> What could I be missing?
>
> Thanks.
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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: Adding YouTube video id to url

2013-08-10 Thread Sithembewena Lloyd Dube
P.S: The view looks like the following:

def watch(request, video_id):
return HttpResponse("This is the watch page for ...") % video_id


On Sat, Aug 10, 2013 at 10:31 PM, Sithembewena Lloyd Dube  wrote:

> Hi,
>
> I am using the YouTube API to fetch video data and display it on a web
> page. As part of the html template I have an anchor tag with an href
> directing to my Django 1.5 app. as follows:
>
> 
>
> The url definition in urls.py is as follows:
>
> url(r'^(?P\w+)$', 'find_music.views.watch', name='watch'),
>
> When I load the page, I get a NoReverseMatch exception as follows:
>
> Reverse for 'watch' with arguments '()' and keyword arguments '{u'video_id': 
> 'D-dNA0NwLSw'}' not found.
>
>
> What could I be missing?
>
> Thanks.
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

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




Adding YouTube video id to url

2013-08-10 Thread Sithembewena Lloyd Dube
Hi,

I am using the YouTube API to fetch video data and display it on a web
page. As part of the html template I have an anchor tag with an href
directing to my Django 1.5 app. as follows:



The url definition in urls.py is as follows:

url(r'^(?P\w+)$', 'find_music.views.watch', name='watch'),

When I load the page, I get a NoReverseMatch exception as follows:

Reverse for 'watch' with arguments '()' and keyword arguments
'{u'video_id': 'D-dNA0NwLSw'}' not found.


What could I be missing?

Thanks.

-- 
Regards,
Sithu Lloyd Dube

-- 
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 Calendar App Just Like Google Calendar

2013-08-10 Thread Margie Roswell
Does anyone have a module available that can do a calendar?

The winter thread below involved a whole bunch of coding-from scratch.

I'm not yet a super-coder... (I do have coding skillsets) and I'm just
learning django, and python. I figure I'll learn django best if I have a
real project; And the real project I have in mind would involve promoting
potluck meals. So event listings, and calendar display would be great. Also
a mapping component (type in an address, get back a map that displays with
the event detail page)

I'd like to start from as much already-available code as I can.

I like the idea, described below of:
"Tastypie makes it really easy to talk json to...backbone and plotting the
appointments in fullcalendar..."

and wow, that sample fullcalendar page looks terrific:
http://blog.shinetech.com/2011/08/05/building-a-shared-calendar-with-backbone-js-and-fullcalendar-a-step-by-step-tutorial/

but honestly, I'll do best to start with a working repo (events,
calendar, address mapping)

(It makes me wonder if anyone has wrapped up a whole bunch of sample django
apps, for easy reuse in general.)

Margie

--
http://FarmBillPrimer.org
http://www.BaltimoreUrbanAg.org (Please send events; This site is hungry.)
http://www.ExcellentNutrition.org
http://www.packtpub.com/drupal-5-views-recipes/book


On Mon, Jan 14, 2013 at 8:49 AM, Iñigo Medina  wrote:

> On Mon, Jan 14, 2013 at 09:41:47AM +1100, Mario Gudelj wrote:
> > Defined my own. Actually, i have defined a single appointment/event model
> > and then i create an instance of it with different dates and different
> slug
> > for the range specified.
> >
> > Use rrlue -
> >
> http://labix.org/python-dateutil#head-470fa22b2db72000d7abe698a5783a46b0731b57
> > to
> > calculate the date and time for every date i the range.
> >
> > So, this how I did it, but you may find a different way.
> >
> > I have an appointment model and appointment series which is linked to the
> > appointment model.
> >
> > I have an appointment creation form, which can create a single
> appointment,
> > but the customer also has an option to create recurring appointments,
> which
> > will create series.
> >
> > So, customer is filling in the form and they are asked if this is a
> > recurring appointment. I they select yes it presents them with the
> > following screen:
> >
> >
> > [image: Inline images 1]
> >
> >
> > There they can choose if they want the event to recur daily, monthly,
> > weekly or yearly.
> >
> > So, when the form is submitted with the interval selected, I create the
> > appointment, create appointment series and then use rrule to create all
> the
> > dates.
> >
> > if form.cleaned_data['is_recur'] == '1':
> >
> > # Find the interval first
> >
> > frequency_int = int(form.cleaned_data['frequency'])
> >
> > if frequency_int == rrule.DAILY:
> >
> > interval = form.cleaned_data['daily_interval']
> >
> > elif frequency_int == rrule.WEEKLY:
> >
> > interval = form.cleaned_data['weekly_interval']
> >
> > elif frequency_int == rrule.MONTHLY:
> >
> > interval = form.cleaned_data['monthly_interval']
> >
> > else:
> >
> > interval = form.cleaned_data['yearly_interval']
> >
> > Then I loop through all the dates created by rrule and create an
> > appointment instance with a different date and the slug, which is the
> > combination of appointment name and the date/time.
> >
> > e.g. slug
> > /appointment/pregnancy-yoga-dads-support-people-welcome/2013/1/23/0630PM/
> >
> > In appointment series I store this info:
> >
> > a_s = AppointmentSeries.objects.create(
> >
> > business=business,first_appointment=appt,
> >
> > frequency=form.cleaned_data['frequency'],
> >
> > is_date_or_number =
> > form.cleaned_data['is_date_or_number'],
> >
> > recurrences=form.cleaned_data['recurrences'],
> >
> > recurrence_end_date=None,
> >
> > interval=interval
> >
> > )
> >
> > You need to save the first appointment from which everything was created
> so
> > that you can later refer to it when editing the series.
> >
> > Anyway, let me know if you need further info and I'm willing to help.
> >
> > You may want to look at this post for fullcalendar.js and backbone.js
> > integration. It helped me somewhat -
> >
> http://blog.shinetech.com/2011/08/05/building-a-shared-calendar-with-backbone-js-and-fullcalendar-a-step-by-step-tutorial/
>
> Thanks a lot, Mario. It is a lot of information and it is great. I like the
> approach. I'm already coding something like that, althoug your use of
> recurrences is cleaner. :)
>
> Iñigo
>
> >
> > Cheers,
> >
> > Mario
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On 13 Jan, 2013 11:33 PM, "Iñigo Medina"  wrote:
> >
> > >
> > > On Sun, Jan 13, 2013 at 12:44:27PM +1100, Mario 

Re: django ajax runtime error - URL doesn't end in slash

2013-08-10 Thread Robin Lery
Ok! Here it is:

{% extends "base.html" %}

{% block sidebar %}

Articles
Create Article


Search
{% csrf_token %}





{% endblock %}

{% block content %}

Language is: {{language}}
Session Language is: {{session_language}}

{% if articles.count > 0 %}
{% for article in articles %}

{{article.title}}
{{article.body | lower | truncatewords:"10"}}
{{ article.likes }} people liked this article.


{% endfor %}
{% else %}
None to show.
{% endif %}

{% endblock %}


On Sat, Aug 10, 2013 at 11:22 PM, Jonathan D. Baker <
jonathandavidba...@gmail.com> wrote:

> Can you paste the markup for your search form?
>
> Sent from my iPhone
>
> On Aug 10, 2013, at 11:46 AM, Robin Lery  wrote:
>
> I am practicing from a tutorial where I have reached to create a search
> box with jquery and ajax. Every thing is going good, except, when i press
> any key in the search, I get an error,
>
> RuntimeError at /articles/search You called this URL via POST, but the URL
> doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect
> to the slash URL while maintaining POST data. Change your form to point to
> localhost:8000/articles/search/ (note the trailing slash), or set
> APPEND_SLASH=False in your Django settings.
>
> I checked for "/" in my code, but its there. Don't know what's going on.
> Please help.
>
> application's urls.py:
>
> url(r'^search/$', 'article.views.search_title'),)
>
> views.py:
>
> def search_title(request):
> if request.method == "POST":
> search_text = request.POST['search_text']
> else:
> search_text = ''
>
> articles = Article.objects.filter(title__contains=search_text)
>
> return render_to_response('ajax_search.html', {'article': article})
>
>  I'm using jquery version: jquery-2.0.0.min.js
>
> ajax.js:
>
> $(function(){
>
> $('#search').keyup(function() {
>
> $.ajax({
> type: "POST",
> url: '/articles/search/',
> data: {
> 'search_text' : $('#search').val(),
> 'csrfmiddlewaretoken' : 
> $("input[name=csrfmiddlewaretoken]").val()
> },
> success: searchSuccess,
> dataType: 'html'
> });
>
> });
> });
> function searchSuccess(data, textStatus, jqXHR){
> $('#search-results').html(data);}
>
> And even when I inspect the ajax.js, in the last line
>
> $('#search-results').html(data);
>
> It reads it as:
>
> $('#search-results').html(date);
>
> Please help me somebody. Thank you.
>
> My main url:
>
> (r'^articles/', include('article.urls')),
>
>  --
> 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.
>
>
>
>  --
> 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.
>
>
>

-- 
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 ajax runtime error - URL doesn't end in slash

2013-08-10 Thread Jonathan D. Baker
Can you paste the markup for your search form?

Sent from my iPhone

On Aug 10, 2013, at 11:46 AM, Robin Lery  wrote:

> I am practicing from a tutorial where I have reached to create a search box 
> with jquery and ajax. Every thing is going good, except, when i press any key 
> in the search, I get an error,
> 
> RuntimeError at /articles/search You called this URL via POST, but the URL 
> doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect 
> to the slash URL while maintaining POST data. Change your form to point to 
> localhost:8000/articles/search/ (note the trailing slash), or set 
> APPEND_SLASH=False in your Django settings.
> 
> I checked for "/" in my code, but its there. Don't know what's going on. 
> Please help.
> 
> application's urls.py:
> 
> url(r'^search/$', 'article.views.search_title'),
> )
> views.py:
> 
> def search_title(request):
> if request.method == "POST":
> search_text = request.POST['search_text']
> else:
> search_text = ''
> 
> articles = Article.objects.filter(title__contains=search_text)
> 
> return render_to_response('ajax_search.html', {'article': article})
> I'm using jquery version: jquery-2.0.0.min.js
> 
> ajax.js:
> 
> $(function(){
> 
> $('#search').keyup(function() {
> 
> $.ajax({
> type: "POST",
> url: '/articles/search/',
> data: { 
> 'search_text' : $('#search').val(),
> 'csrfmiddlewaretoken' : 
> $("input[name=csrfmiddlewaretoken]").val()
> },
> success: searchSuccess,
> dataType: 'html'
> });
> 
> });
> 
> });
> 
> function searchSuccess(data, textStatus, jqXHR)
> {
> $('#search-results').html(data);
> }
> And even when I inspect the ajax.js, in the last line
> 
> $('#search-results').html(data);
> 
> It reads it as:
> 
> $('#search-results').html(date);
> 
> Please help me somebody. Thank you.
> 
> My main url:
> 
> (r'^articles/', include('article.urls')),
> 
> -- 
> 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.
>  
>  

-- 
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 ajax runtime error - URL doesn't end in slash

2013-08-10 Thread Robin Lery
I am practicing from a tutorial where I have reached to create a search box
with jquery and ajax. Every thing is going good, except, when i press any
key in the search, I get an error,

RuntimeError at /articles/search You called this URL via POST, but the URL
doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect
to the slash URL while maintaining POST data. Change your form to point to
localhost:8000/articles/search/ (note the trailing slash), or set
APPEND_SLASH=False in your Django settings.

I checked for "/" in my code, but its there. Don't know what's going on.
Please help.

application's urls.py:

url(r'^search/$', 'article.views.search_title'),)

views.py:

def search_title(request):
if request.method == "POST":
search_text = request.POST['search_text']
else:
search_text = ''

articles = Article.objects.filter(title__contains=search_text)

return render_to_response('ajax_search.html', {'article': article})

I'm using jquery version: jquery-2.0.0.min.js

ajax.js:

$(function(){

$('#search').keyup(function() {

$.ajax({
type: "POST",
url: '/articles/search/',
data: {
'search_text' : $('#search').val(),
'csrfmiddlewaretoken' :
$("input[name=csrfmiddlewaretoken]").val()
},
success: searchSuccess,
dataType: 'html'
});

});
});
function searchSuccess(data, textStatus, jqXHR){
$('#search-results').html(data);}

And even when I inspect the ajax.js, in the last line

$('#search-results').html(data);

It reads it as:

$('#search-results').html(date);

Please help me somebody. Thank you.

My main url:

(r'^articles/', include('article.urls')),

-- 
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: Newbie: do I need to upload in order to access data?

2013-08-10 Thread Bob Aalsma
Thanks Nigel, this looks very promising ;)

If I interpret your text correctly, this is based on the upload/save 
example I mentioned.
I'm really interested in the meaning of parts your closing paragraph:

   - "This saves the file in 'media/documents/2013/08/10/datafile.csv'." - 
   I think this means the contents of the file is copied from the user disk to 
   my disk, right? 
   - "pointing them to the correct directory and file." - could I not 
   simply point to the *original* directory and file (on the user's 
   machine) and read the contents from that location?


Regards,
Bob

Op zaterdag 10 augustus 2013 18:39:38 UTC+2 schreef Nigel Legg:
>
> I've based my process a minimal file upload - I think based on the answer 
> to the link above.  I use:
> models.py:
> class Document(models.Model):
> docfile = models.FileField(upload_to='documents/%Y/%m/%d')
>
> views.py:
> def list(request):
> # Handle file uploadf
> if request.method == 'POST':
> form = DocumentForm(request.POST, request.FILES)
> if form.is_valid():
> newdoc = Document(docfile = request.FILES['docfile'])
> newdoc.save()
>
> # Redirect to the document list after POST
> return 
> HttpResponseRedirect(reverse('myproject.myapp.views.list'))
> else:
> form = DocumentForm() # A empty, unbound form
>
> # Load documents for the list page
> documents = Document.objects.all()
>
> # Render list page with the documents and the form
> return render_to_response(
> 'myapp/list.html',
> {'documents': documents, 'form': form},
> context_instance=RequestContext(request)
> )
>
> forms.py:
> class DocumentForm(forms.Form):
> docfile = forms.FileField(
> label='Select a file',
> help_text='max. 42 megabytes'
> )
>
> This saves the file in 'media/documents/2013/08/10/datafile.csv'.  You can 
> then access this using the normal open() and read() functions, pointing 
> them to the correct directory and file.  As far as I can see, the data 
> remains in the file you upload, but the location and name are stored in the 
> database - in this case, "documents/2013/10/08/datafile.csv". 
>
> Hope this helps 
>
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>
>
> On 10 August 2013 15:52, Bob Aalsma wrote:
>
>> Hi,
>>
>> I'm trying to achieve the following:
>>
>>- user indicates a file on his/her machine 
>>- the program opens the file, reads the data and acts on that 
>>
>>
>> So far, I can find examples of indicating the file on the user's machine, 
>> but this is always combined with saving to database (which I don't want); 
>> the clearest example I could find is 
>> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
>>
>> Question 1: is it really necessary to store the data in my database?
>>
>> If not, I've not been able to find how to actually open and read the file.
>> I've been trying out variations on reading, based on what I could find in 
>> the Tutorials and Managing files (
>> https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem 
>> to understand how to actually find the path and filename the user would 
>> have indicated. I seem to get completely lost in FileField and FieldFile 
>> and connected methods 
>>
>> Question 2: how do I find the indicated path and filename from the user?
>>
>> Regards,
>> Bob
>>
>> -- 
>> 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.
>> 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.




Re: Newbie: do I need to upload in order to access data?

2013-08-10 Thread Nigel Legg
I've based my process a minimal file upload - I think based on the answer
to the link above.  I use:
models.py:
class Document(models.Model):
docfile = models.FileField(upload_to='documents/%Y/%m/%d')

views.py:
def list(request):
# Handle file uploadf
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
newdoc = Document(docfile = request.FILES['docfile'])
newdoc.save()

# Redirect to the document list after POST
return
HttpResponseRedirect(reverse('myproject.myapp.views.list'))
else:
form = DocumentForm() # A empty, unbound form

# Load documents for the list page
documents = Document.objects.all()

# Render list page with the documents and the form
return render_to_response(
'myapp/list.html',
{'documents': documents, 'form': form},
context_instance=RequestContext(request)
)

forms.py:
class DocumentForm(forms.Form):
docfile = forms.FileField(
label='Select a file',
help_text='max. 42 megabytes'
)

This saves the file in 'media/documents/2013/08/10/datafile.csv'.  You can
then access this using the normal open() and read() functions, pointing
them to the correct directory and file.  As far as I can see, the data
remains in the file you upload, but the location and name are stored in the
database - in this case, "documents/2013/10/08/datafile.csv".

Hope this helps

Regards,
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 10 August 2013 15:52, Bob Aalsma  wrote:

> Hi,
>
> I'm trying to achieve the following:
>
>- user indicates a file on his/her machine
>- the program opens the file, reads the data and acts on that
>
>
> So far, I can find examples of indicating the file on the user's machine,
> but this is always combined with saving to database (which I don't want);
> the clearest example I could find is
> http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
>
> Question 1: is it really necessary to store the data in my database?
>
> If not, I've not been able to find how to actually open and read the file.
> I've been trying out variations on reading, based on what I could find in
> the Tutorials and Managing files (
> https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem to
> understand how to actually find the path and filename the user would have
> indicated. I seem to get completely lost in FileField and FieldFile and
> connected methods 
>
> Question 2: how do I find the indicated path and filename from the user?
>
> Regards,
> Bob
>
> --
> 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.
>
>
>

-- 
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: Iterating over fields in Formset

2013-08-10 Thread Sandeep kaur
On Sat, Aug 10, 2013 at 9:00 PM, Satinderpal Singh
 wrote:
>
> I think in the your views you are trying to save it under the formsets, try
> to save the formsets under the form to save all the required rows.
>
What should be changed?
This is my code :

def add_result(request):
class RequiredFormSet(BaseFormSet):
def __init__(self, *args, **kwargs):
super(RequiredFormSet, self).__init__(*args, **kwargs)
for form in self.forms:
form.empty_permitted = False
clas = Class.objects.get(id=request.GET['class'])
test = Tests.objects.get(id=request.GET['test'])
student = Student.objects.filter(std=clas.id)
#for students in student:
#   student_id = Student.objects.get(id=students.id)
if test.id == 3 or test.id == 6:
pass
else :
FAtestFormSet = formset_factory(FAtestForm, max_num=30,
formset=RequiredFormSet)
if request.method == 'POST':
FAtestform_formset = FAtestFormSet(request.POST, 
request.FILES)
if FAtestform_formset.is_valid() :
for form in FAtestform_formset.forms:
marks = form.save(commit=False)
marks.test = test
marks.save()
return 
render_to_response('report/marks_filled.html',
{'student':student}, 
context_instance=RequestContext(request))
else:
FAtestform_formset = FAtestFormSet()
temp = {'FAtestform_formset': FAtestform_formset, 
'student':student,
'test':test }
return render_to_response('report/add_marks.html', temp,
context_instance = RequestContext(request))


-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.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 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: Iterating over fields in Formset

2013-08-10 Thread Satinderpal Singh
On Aug 10, 2013 5:48 PM, "Sandeep kaur"  wrote:
>
> On Fri, Aug 9, 2013 at 2:50 PM, Sandeep kaur 
wrote:
> >  I have my code for formset here :
> >
> >  {% csrf_token %}
> >
> Your help would be really appreciated.
> Waiting.
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
I think in the your views you are trying to save it under the formsets, try
to save the formsets under the form to save all the required rows.

--
Satinderpal Singh

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


Newbie: do I need to upload in order to access data?

2013-08-10 Thread Bob Aalsma
Hi,

I'm trying to achieve the following:

   - user indicates a file on his/her machine 
   - the program opens the file, reads the data and acts on that


So far, I can find examples of indicating the file on the user's machine, 
but this is always combined with saving to database (which I don't want); 
the clearest example I could find 
is 
http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example

Question 1: is it really necessary to store the data in my database?

If not, I've not been able to find how to actually open and read the file.
I've been trying out variations on reading, based on what I could find in 
the Tutorials and Managing files 
(https://docs.djangoproject.com/en/1.5/topics/files/ ) but I don't seem to 
understand how to actually find the path and filename the user would have 
indicated. I seem to get completely lost in FileField and FieldFile and 
connected methods 

Question 2: how do I find the indicated path and filename from the user?

Regards,
Bob

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




how to make distinct and order_by work together

2013-08-10 Thread doniyor
I am really stuck in this problem for a while. this is really challenging 
for me. .. tough one... 

i have two models. Location and Rate. 

each location has rates, possibly multiple rates.. let me give you my 
models: 

class Location(models.Model):
  name = models.TextField()
  adres = models.TextField()
class Rate(models.Model):
  location = models.ForeignKey(Location,related_name='locations_rate')
  rate = models.IntegerField(max_length=2)

the case is: 

I am trying to write the sort function which is called when user in resultpage 
the result items sorts e.g. by rate. then the results should be sorted 
ascendingly ordered by rate. 

I tried this: 

locations = 
Location.objects.filter(**s_kwargs).order_by('-locations_rate__rate')

but this is giving me duplicate items. then i tried this: locations = 
Location.objects.filter(**s_kwargs).distinct('id').order_by('-locations_rate__rate')

but i am getting error message saying this wont work as i read in every forum. 
what can i do so that i can sort the items ordering by rates and keeping them 
distinct set? 


please help me 

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




Re: Iterating over fields in Formset

2013-08-10 Thread Sandeep kaur
On Fri, Aug 9, 2013 at 2:50 PM, Sandeep kaur  wrote:
>  I have my code for formset here :
>
>  {% csrf_token %}
>
Your help would be really appreciated.
Waiting.

--
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.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 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: How can I order my list based on a field in a different table?

2013-08-10 Thread Eric Cheung
1) The model Word does not have the votes field, you cannot order the field 
it's not possessed.

2) You have to build a relation between the models first, check the 
relationships from Django Doc 
https://docs.djangoproject.com/en/dev/topics/db/models/#relationships
  
On Friday, August 9, 2013 10:04:47 PM UTC+8, Pepsodent Cola wrote:
>
> 1.)
> How can I order my list based on a field in a different table?
>
> return Word.objects.filter(direct_transl_word='')
>
> The above I want to do something like this where the field ('-votes') is 
> located at table Altword.
> Nothing happens when I use this though, don't understand why?
>
> #return 
> Word.objects.filter(direct_transl_word='').order_by('-votes')
>
>
> 2.)
> My *altword_list.html* viewpage breaks whenever I try to use query for my 
> other table Altword.
>
> #return Altword.objects.filter(rosword__direct_transl_word='')
> #return Altword.objects.filter(word__direct_transl_word='')
>
> #___
>
> *AltwordlistView*
> class AltwordlistView(generic.DetailView):
> model = Word
> #model = Altword
> template_name = 'navi_polls/altword_list.html'
> context_object_name = 'poll'
>
> def get_queryset(self):
> # Filter 5
> return Word.objects.filter(direct_transl_word='')
> #return 
> Word.objects.filter(direct_transl_word='').order_by('-votes')
> #return Altword.objects.filter(rosword__direct_transl_word='')
> #return Altword.objects.filter(word__direct_transl_word='')
>
> #___
>
> *Models*
> class Word(models.Model):
> rosword = models.CharField(max_length=200)
> direct_transl_word = models.CharField(max_length=120, blank=True, 
> null=True)
> pub_date = models.DateTimeField('date published')
>
> def __unicode__(self):
> return self.rosword
>
> #___
>
> *Models*
> class Altword(models.Model):
> rosword = models.ForeignKey(Word)
> alt_ros_word = models.CharField(max_length=200)
> alt_transl_word = models.CharField(max_length=200)
> articulate = models.CharField(max_length=200)
> *votes* = models.IntegerField(default=0)
> pub_date = models.DateTimeField('date published')
>
> def __unicode__(self):
> return self.alt_ros_word
>
>
>
>
>

-- 
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: How to store position of current/active navigation entry

2013-08-10 Thread DJ-Tom
I now came up with this solution:

path = req.get_full_path()
if path.startswith(entry['href']):
entry['active'] = True

thanks for helping :-)

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




Problem with custom user model and built-in admin-forms...

2013-08-10 Thread DJ-Tom
Hi,

I'm trying to get a custom user model to work with the built-in admin app, 
based on the sample code in the documentation 
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#auth-custom-user

Here is my code:

https://gist.github.com/anonymous/91f2c30bdc48a4ca3248

I either get a 

FieldError at /
> Unknown field(s) (date_created) specified for UserAccount
>

or 

ImproperlyConfigured at /
> 'SpcUserAdmin.fieldsets[1][1]['fields']' refers to field 'is_admin' that 
> is missing from the form.
>


When I remove date_created form the field list of the meta class in 
UserCreationForm.

I'm sure there is a small and stupid error on my side, but I just can't 
spot it... HELP :-)



-- 
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: problem with deploying django using mod wsgi

2013-08-10 Thread Kelvin Wong
Is your form (on page /mice/search_mice/) submitting to

/mice/search

or

/search

Check your form element in the html document. Is it pointing to the right 
URL?

Maybe check your WSGIScriptAlias setting. Maybe verify your DocumentRoot 
setting.

You might also want to check the request and response using a tool like 
HttpFox

K



On Thursday, August 8, 2013 6:10:34 AM UTC-7, sah wrote:
>
> I have this error in the error_log file :
>
>  [error] [client 10.10.8.41] File does not exist: /var/www/html/search, 
> referer: http://tarinformatics03/mice/search_mice/
>
> search is one of my view function why is it looking for it in the html 
> directory ??
>

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