Export table created in Views to a CSV with a button

2023-01-09 Thread Tristan Tucker
Hello,

I have built a view that takes in dataframes, runs them through a function 
and then ultimately pumps out a results dataframe that is transformed into 
a HTML object and displayed on the webapp homepage. Now, I am trying to add 
in an "Export as CSV" button that upon being clicked will download that 
table/dataframe to a .csv file to the user's downloads folder. Any help on 
how to do this? I am struggling to find anything on how specifically to do 
this.

I was thinking maybe create a new view or function within HTML code that 
uses some sort of write csv function but not sure.

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc48decd-31b8-4435-a6e5-9e57ba263b9dn%40googlegroups.com.


First View

2018-05-21 Thread Tristan Demot
Hello,

I use tutorial 1.11

beaumarche (startproject)

from django.conf.urls import include, url
from django.contrib import admin


urlpatterns = [

url(r'^boutique/', include('boutique.urls')) ,
url(r'^admin/', admin.site.urls),
]


boutique (app)


urls.py


from django.conf.urls import url


from . import views


urlpatterns = [
  url(r'^$', views.index, name='index'),
]




views.py
from django.http import HttpResponse


def index(request):
 return HttpResponse ("Hello, world...")


127.0.0.1:8000
Using the URLconf defined in beaumarche.urls, Django tried these URL 
patterns, in this order:


1.^boutique/
2^admin/


The empty path didn't match any of these

An idea maybe

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5431a0c8-1365-4a73-8026-25c57c2f775b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ImportError : cannot import name include

2018-05-17 Thread Tristan Demot
Hello,

 I use docs.djangoproject.co/en/2.0
 Python 2 7 13
Gjango 1.11.13

Creating the Polls app OK
Write your first view OK
But python manage runserver don't work
With : python -Wall manage.py test

ImportError : cannot import name include

If you want to see something, ask me

Many thanks


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


Re: Django Channels: Multiple 'send' calls in the same consumer

2017-05-16 Thread Tristan Barry
Thank you very much for clarifying - I wasn't exactly sure how to approach 
this, but your response makes sense.

Cheers!

On Saturday, May 13, 2017 at 6:09:14 PM UTC-7, Andrew Godwin wrote:
>
> Hi Tristan,
>
> All messages sent from a consumer are delayed for sending until the 
> consumer exits to keep things atomic - long-running consumers is bad for 
> performance, as they'll hog an entire thread (they run synchronously) and 
> so you'll quickly run out of threads/processes as you'll end up using one 
> per connection.
>
> Instead, you should do your task and exit out of the consumer as quickly 
> as possible to free the worker space for something else to run. To achieve 
> repeated execution with delays, you can either look at the delay server (
> http://channels.readthedocs.io/en/stable/delay.html) or write your own 
> consumer code that talks to channels that uses an asynchronous framework 
> (asyncio, twisted)
>
> Andrew
>
> On Sat, May 13, 2017 at 11:29 AM, Tristan Barry  > wrote:
>
>> Hi - I'm working with Django Channels (1.1.3) on a Django project and I 
>> have some questions about how to send multiple messages from the same 
>> consumer.
>>
>> The idea is the consumer will receive a request to do some work, and will 
>> send incremental results back to user. I've attached a simplified example 
>> below with some questions. I'm hoping someone can steer me in the right 
>> direction.
>>  
>>
>> Django Channels:
>>
>>>
>>> def do_some_work(message):
>>> for i in range(3):
>>> time.sleep(2)
>>> message.reply_channel.send({"text": 'Finished work ' + str(i)})
>>>
>>> def ws_connect(message):
>>> message.reply_channel.send({"accept": True})
>>>
>>> channel_routing = [
>>> route('websocket.connect', ws_connect),
>>> route('websocket.receive', do_some_work, path=r'/todo')
>>> ]
>>
>>
>> Javascript (borrowed mostly from the docs):
>>
>> socket = new WebSocket("ws://" + window.location.host + "/todo/");
>>> socket.onmessage = function(e) {
>>> console.log(e.data);
>>> }
>>> socket.onopen = function() {
>>> socket.send("hello world");
>>> }
>>> // Call onopen directly if socket is already open
>>> if (socket.readyState == WebSocket.OPEN) socket.onopen();
>>
>>
>>
>> Expected results: Every two seconds the browser would receive a reply 
>> from the consumer saying 'Finished work x'. 
>>
>> What I observe is a delay for ~6 seconds and then all results returned at 
>> the same time. Are the response on the reply channel blocked somehow? Is 
>> there I way I can yield, or release the message before doing the next 
>> increment of work?
>>
>> I've also tried setting up a new consumer that *only* replies via a 
>> Group. So instead of *message.reply_channel.send, *I would 
>> *Channel('reply-channel').send({results: 
>> ...})* and have a new consumer defined on channel_routing for the 
>> *'reply-channel'*. But the results are the same - all the 'work' is 
>> completed before the browser receives a response. 
>>
>> Any hints on how to send multiple message in the same consumer?
>>
>> Thanks in advance.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@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/4bf7d2ce-9a13-4f85-9933-cb8496e1f59d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/4bf7d2ce-9a13-4f85-9933-cb8496e1f59d%40googlegroups.com?utm_medium=email&utm_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/ff7db442-5444-4ff2-ae27-3abd18695b94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels: Multiple 'send' calls in the same consumer

2017-05-13 Thread Tristan Barry
Hi - I'm working with Django Channels (1.1.3) on a Django project and I 
have some questions about how to send multiple messages from the same 
consumer.

The idea is the consumer will receive a request to do some work, and will 
send incremental results back to user. I've attached a simplified example 
below with some questions. I'm hoping someone can steer me in the right 
direction.
 

Django Channels:

>
> def do_some_work(message):
> for i in range(3):
> time.sleep(2)
> message.reply_channel.send({"text": 'Finished work ' + str(i)})
>
> def ws_connect(message):
> message.reply_channel.send({"accept": True})
>
> channel_routing = [
> route('websocket.connect', ws_connect),
> route('websocket.receive', do_some_work, path=r'/todo')
> ]


Javascript (borrowed mostly from the docs):

socket = new WebSocket("ws://" + window.location.host + "/todo/");
> socket.onmessage = function(e) {
> console.log(e.data);
> }
> socket.onopen = function() {
> socket.send("hello world");
> }
> // Call onopen directly if socket is already open
> if (socket.readyState == WebSocket.OPEN) socket.onopen();



Expected results: Every two seconds the browser would receive a reply from 
the consumer saying 'Finished work x'. 

What I observe is a delay for ~6 seconds and then all results returned at 
the same time. Are the response on the reply channel blocked somehow? Is 
there I way I can yield, or release the message before doing the next 
increment of work?

I've also tried setting up a new consumer that *only* replies via a Group. 
So instead of *message.reply_channel.send, *I would 
*Channel('reply-channel').send({results: 
...})* and have a new consumer defined on channel_routing for the 
*'reply-channel'*. But the results are the same - all the 'work' is 
completed before the browser receives a response. 

Any hints on how to send multiple message in the same consumer?

Thanks in advance.

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


How to Allow "-" character in usernames in the admin application

2009-07-31 Thread tristan

In our webapp we needed to allow dashes "-" in our usernames. I've
enabled that for the consumer signup process just fine with this regex
r'^[\w-]+$'

How can I tell the admin app so that I can edit usernames in auth >
users to allows the "-" character in usernames?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Show user page on first login.

2009-04-23 Thread tristan

Hi there,

I'm build a Django web-app with some pinax components, and would like
to show to take the user to a specific page on their first login, and
afterwards not show them that page again.
Has anyone implemented this, or seen any example code for it?

Thanks,

Tristan
--~--~-~--~~~---~--~~
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: allowing a user to delete their own account and associated data.

2009-03-18 Thread tristan

Guys,

thank you, both of you, I have searched hi and low for examples of
this and found none.
A question, would the example code you have posted behave in the same
way as the delete function does in the Auth admin application, in that
it would not just delete the user, but also all the profile objects
and things like that that are associated with that username?

I got a response in a post here:

http://groups.google.com/group/pinax-users/browse_thread/thread/deda8f90e2581bc7/678332bf89130740?lnk=gst&q=delete+usres#678332bf89130740

That mentioned use of a Forien Key to get this data?

On Mar 18, 3:16 am, Tim Chase  wrote:
> > From the interactive shell, it's easy to delete a user::
>
> >     >>> from django.contrib.auth.models import User
> >     >>> u = User.objects.get(username='jacob')
> >     >>> u.delete()
>
> > So, you'd need to write a view that essentially does the above.
> > Remember that in views, the currently-logged-in user is available as
> > `request.user`, so::
>
> >     def delete_me(request):
> >         request.user.delete()
> >         return render_to_response('youve_been_deleted.html')
>
> > You'll probably want to implement some sort of "are you sure?"
> > confirmation page, but I'll leave that up to you.
>
> I'd also ensure that it's a POST method (you don't want weird
> behaviors from caching since data is changed) and that the
> confirmation form has some sort of signed token in it (involving
> the username to be deleted) to prevent XSS bugs.  It would stink
> to have a page that deletes users, and could be silently scripted
> from remote sites...
>
> -tim
--~--~-~--~~~---~--~~
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: allowing a user to delete their own account and associated data.

2009-03-17 Thread tristan

I don't suppose anyone has any insight into this do they?
A pointer to where I might find the python that deletes an account in
the "Auth" admin app would be great, because then I could just copy
that... I've found that does everything I need, but I need to expose
it to my users so they can do it themselves...


On Mar 12, 10:12 am, tristan  wrote:
> Hello there,
> I'm currently learning Django by re-implementing a site based on
> Pinax.
> In the Django admin site, I candeleteanaccountand all its
> associated data by going into auth >accountname and deleting it.
> This works just dandy.
> What I would like to do is to expose this same functionality to the
> user on the main site.
> Can anyone point me to what views I might copy, and where from in
> order to achieve this, or give me any other tips?
>
> Thank you in advance.
>
> Tristan
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



allowing a user to delete their own account and associated data.

2009-03-12 Thread tristan

Hello there,
I'm currently learning Django by re-implementing a site based on
Pinax.
In the Django admin site, I can delete an account and all its
associated data by going into auth > account name and deleting it.
This works just dandy.
What I would like to do is to expose this same functionality to the
user on the main site.
Can anyone point me to what views I might copy, and where from in
order to achieve this, or give me any other tips?

Thank you in advance.

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



An easy way to work with webservices and create template tags.

2009-03-04 Thread tristan

I'm a designer learning python and Django by example, and its a
brilliant system.
On my project I have a set of our own XML webservices to call using a
variety of methods. The aim is to then get access to the data returned
and expose the individual elements in the XML as Django template tags
that I can then manipulate in my web application.
I have looked at the amazon web service example, but its a little over
my head. I wondered if anyone had any libraries that I might be able
to adapt to do this without having to write too much python?


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



FileField upload directory

2007-12-12 Thread Tristan King

Hi,

Is there a way to point the FileField upload directory to somewhere that
isn't under the MEDIA_ROOT ?

I want this because i want to be able to upload files, but not have them
accessible via the web.

I've worked around this by making a new url to the upload directory and
making a view which raises a Http404, which works fine, but I don't
think is an ideal solution.

I think having the upload_to directory point to a absolute file path
rather than one relative the the media_root dir would make more sense,
since users can specify the media_root if they wish, but it's not
enforced.

Any thoughts?
Thanks,
-Tristan


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---