Re: In my django web app i wannt show time in user timezone

2018-12-07 Thread Vovk Donets
>From docs: "...there’s no equivalent of the Accept-Language HTTP header
that Django could use to determine the user’s time zone automatically.
Instead, Django provides time zone selection functions
<https://docs.djangoproject.com/en/dev/ref/utils/#time-zone-selection-functions>.
Use them to build the time zone selection logic that makes sense for you."

There is two paths.
First. You can store time on the server in UTC, detect user timezone and
then do conversion to this timezone on your backend. You can also look at
https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#localtime
Second path is that you can do time conversion on the frontend using
whatever you like JS library to do this work. But in both cases you should
determine users timezone yourself or ask user in which TZ he is.

сб, 8 дек. 2018 г. в 07:02, :

> Hello,
> I think you can use "request.META" django. (request.META['TZ']). It is
> timezone user submit request.
>
> :D
>
> On Saturday, December 8, 2018 at 8:39:29 AM UTC+7, Deniz Bazan wrote:
>>
>> Hello everybody,
>> I have a django web app, in my app i want to show in the page where the
>> time information is, with user timezone.
>>
>> I have a form with start_time and end_time(Timefield) user send this with
>> a specific timezone(Berlin/Europa) after this when a user go to the page,
>> the user should see the page with his own timezone.
>>
>> I use Django 2.1 with postgresql database.
>>
>> Thanks for any recommendation!
>> Regards,
>> Deniz
>>
> --
> 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/eaa47d65-8bd5-4a9d-95a4-28bc5761317c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/eaa47d65-8bd5-4a9d-95a4-28bc5761317c%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Vovk Donets*
 python developer

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


Re: Is it secure to have IDs show up in URLs?

2012-03-23 Thread Vovk Donets
Hello, why not use _slug_ then?? You can show in URLs whatever you want.

2012/3/23 Bastien <bastien.roche...@gmail.com>

> I am concerned about seeing the IDs of objects appearing in the URL and in
> a totally predictable manner. It is very convenient and clean to do all
> sorts of things but can be abused very easily to retrieve all the content
> of the site, ie: photos...
> Is it a good idea to try to change this behavior? Maybe with some sort of
> middleware? Is there any project doing it already? For instance the urls in
> Instagram seem to be encoded at least.
>
> --
> 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/-/UBBLhaPnHf4J.
> 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.
>



-- 
*Vovk Donets*
 python developer

-- 
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: Comments form customization

2012-02-13 Thread Vovk Donets
It's not really great solution, but maybe it will give you a hint: you can
add/remove fileds to the form on the fly. And for not logged in users show
all fields, but for authenticated only subset of the all form fields.

2012/2/13 Fabio Natali <fa...@fnstudio.it>

> Hi everybody,
>
> I am using comments app from contrib in Django 1.3.
>
> In my website I let only authenticated users to leave a comment so I'd
> like to get rid of those "name", "email" and "url" fields that come with
> the standard comment form. Indeed, I already know the name and email of
> current logged user, there's no need for the user to submit his/her name
> and email again.
>
> So, I'd just like a FK field to the user that left the comment. More of
> that, I would like that field to be automatically populated while the user
> submit the comment.
>
> Could you give me some hints for such customization?
>
> Thank you very much,
> Fabio.
>
> --
> Fabio Natali
>
>
-- 
*Vovk Donets*
 python developer

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



accessing template context from inside a custom filter

2012-01-13 Thread Vovk Donets
Hello,

I want to make a filter with access to template context, like simple_tag
with takes_context=True

Is there a way do that?

-- 
*Vovk Donets*

-- 
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: how to use asyncore socket in django views.py

2011-12-27 Thread Vovk Donets
To accepts socket connetction you need always listen some port. Othewise
you will be trying hit a bulls eye when sending data to this port (if you
would listen port only when view was called) View is a function it's not a
webserver that runs and listen to port.
You need to decouple working with sockets from view and place it somewere
outside django

2011/12/27 Vovk Donets <donets.vladi...@gmail.com>

> For what you need this?
> Maybe you should consider using Celery for doing background jobs.
>
>
> 2011/12/23 Kay <fcapba1...@gmail.com>
>
>> if I have easy asyncore socket code as follow:
>>
>>
>> --
>>
>> import socket
>> import asyncore
>>
>> class asysocket(asyncore.dispatcher):
>>
>>def __init__(self,host,port):
>>asyncore.dispatcher.__init__(self)
>>self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
>>self.set_reuse_addr()
>>self.bind((host, port))
>>self.listen(10)
>>print 'server is waiting for socket connection...'
>>
>>def handle_accept(self):
>>new,addr = self.accept()
>>print 'received from address', addr
>>data = new.recv(1024)
>>print repr(data)
>>
>>def handle_close(self):
>>self.close()
>>
>> server = asysocket('127.0.0.1',1234)
>> asyncore.loop()
>>
>>
>> ----
>>
>> then how to use this in my django project views.py to let it
>> automatically work for receiving connection
>>
>> while i start the project as "python manage.py runserver [port]"??
>>
>> thanks
>>
>>
> --
> *Vovk Donets*
>  python developer
>
> skype:  suunbeeam
> icq:  232490857
> mail:donets.vladi...@gmail.com
> www:  jetfix.ru
>
>


-- 
*Vovk Donets*
 python developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com
www:  jetfix.ru

-- 
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: how to use asyncore socket in django views.py

2011-12-27 Thread Vovk Donets
For what you need this?
Maybe you should consider using Celery for doing background jobs.

2011/12/23 Kay <fcapba1...@gmail.com>

> if I have easy asyncore socket code as follow:
>
>
> --
>
> import socket
> import asyncore
>
> class asysocket(asyncore.dispatcher):
>
>def __init__(self,host,port):
>asyncore.dispatcher.__init__(self)
>self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
>self.set_reuse_addr()
>self.bind((host, port))
>self.listen(10)
>print 'server is waiting for socket connection...'
>
>def handle_accept(self):
>new,addr = self.accept()
>print 'received from address', addr
>data = new.recv(1024)
>print repr(data)
>
>def handle_close(self):
>self.close()
>
> server = asysocket('127.0.0.1',1234)
> asyncore.loop()
>
>
> 
>
> then how to use this in my django project views.py to let it
> automatically work for receiving connection
>
> while i start the project as "python manage.py runserver [port]"??
>
> thanks
>
>
-- 
*Vovk Donets*
 python developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com
www:  jetfix.ru

-- 
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: What's the django convention for templates?

2011-12-09 Thread Vovk Donets
>
>
> As you can see the templates directory is stored inside the app directory.
>
> Reading the django documentation instead they says that the templates dir
> should live inside the root directory of the projects.
>
> I'm wondering, what's is the common convention about it?
>
> I thought to store the templates dir inside each apps, because in this way
> the apps are more pluggables...I'm going wrong?
>
> Thank you
>

Your way is right, nothing wrong wth storing templates in app directory.
For this purpose django even has special app loader, wich loads templates
stored in the app directory.

And this way your app would be closer to "just plug in and use"

As for me, i'm deciding where to store templates basing on app or project
requirements.
-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

-- 
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: Django + CSS

2011-01-19 Thread Vovk Donets
Man, this is just a quote from Django Documentation.

2011/1/20 Osiaq <osiaq.net...@gmail.com>

> Same problem here. Follow those rules, is simple and is working
> perfect.
>
>
> http://twigstechtips.blogspot.com/2009/08/django-how-to-serve-media-files-css.html
>
>


-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

-- 
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: listpage question

2011-01-17 Thread Vovk Donets
2011/1/18 Bobby Roberts 

> let's say  i have two simple models
>
>
> model a
> id=IntegerField...
> description = CharField...
>
>
> model b
> id=IntegerField...
> modelavalue=IntegerField...   (a value form modela.id)
> description=CharField...
>
>
> ok in the /admin listing page for model B, how can i return
> modela.description  for modelb.modelavalue
>
>
you can do it by inserting "modelAvalue__description" in the admin.py in the
list_display for modelB model.Admin:

class modelBAdmin(admin.ModelAdmin):
list_display = ( 'id','modelAvalue__description', 'description')
admin.site.register(modelB, modelBAdmin)

-- 
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: Problem with overriding the default Django admin page.

2011-01-17 Thread Vovk Donets
2011/1/18 Chen Xu <xuche...@gmail.com>

> I did try this, and I tried again, but it still doesn't work.
> Do I need to do something extra like quit the server, and restart again? By
> the way I did try this too.
>
> Now, I am totally lost.
>
>
Django dev server restarts itself, but sometimes you have to manually
restart it.
Well, if you specify paths right and create there is a directory nothing
would go wrong:

TEMPLATE_DIRS = (
"/templates/",
}
and your project for example is here "/var/www/project/" than you go to this
dir and in the dir "templates" create dir "admin" and place here thoose
admin templates that would replace default admin templates. As i have done
it many times if it is done right things works from the start.

for debugging you can delete default admin templates and when Django spills
error that template does not exist's look at path's in traceback where
django searched templates
it can help to understand problem better
-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

-- 
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: override save()

2011-01-17 Thread Vovk Donets
if self.posrx is not the model field then this is the cause.

*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

-- 
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: a chicken and egg - help please?

2011-01-17 Thread Vovk Donets
>
> additional to this the categories per video need to be detailed as well
> (category the video belongs to is a ManyToMany)
>

If i understand you correctly then If you want some aditional information
to be
putted on the ManyToMany relationship then u need to use "through" parametr
and one more table.
look in docs.

>
> so my question is how to I order the query set by a foreign key that has a
> function to get the surname and also output on the template all the
> categories that the video belongs to?
>
>
>
To get all categories of the Video item u can do:
video.category.all()

About your wish to use method of get_surname to sort queryst - i think it's
not possible to do in this ORM.(well, i'll be happy if im wrong)
But you can sort queryset after you get it or you could subclass
models.query.QuerySet to add you own functionality like
 Item.objects.filter(...).order_by_surname(item.get_surname()) or smth like
this
-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com
www:   vovk.org.ru

-- 
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: jquery problem

2011-01-17 Thread Vovk Donets
2011/1/17 Tony 

> I did what you've recommended, I put in the jquery.js file that I used
> while testing outside of django.  There was still no success.  Thus
> far I cant get any other plugin to work beside the one it dynamic
> formset one I started with.  I even deleted that file temporarily to
> see if it was "blocking" the other files somehow.  It didn't work.
> Are there any other suggestions on how to get these jquery files to
> work in my django project?
>
>
1) When debugging problems related to Java Script it's a good practice
to look at browser JS console to see if there something is wrong.

2) You didnt say a thing about how you JS scripts loaded in your page.
via 

Re: Current Django 1.3 Alpha 2 Documentation as PDF

2011-01-17 Thread Vovk Donets
2011/1/17 ckar...@googlemail.com <ckar...@googlemail.com>

> Sry for the wrong url. It's now
> http://g2007.ch/media/static/uploads/django.pdf
>
>
Great work, many thanks!

-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com
www:   vovk.org.ru

-- 
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: Execute code after the model with m2m is completely saved

2011-01-17 Thread Vovk Donets
2011/1/17 Martin Tiršel <dja...@blackpage.eu>

> I found two ways how to do it:
>
> *) m2m_changed signal - this is the best way
>
> *) save_model(self, request, obj, form, change) method for ModelAdmin - obj
> has current relations, form contains the new relations
>
> Martin
>
> The third way would be creating a custom model field that handle work with
images

-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

-- 
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: Problem with overriding the default Django admin page.

2011-01-17 Thread Vovk Donets
You must specify in the TEMPLATE_DIRS path to the dir where templates were
placed, not abs path file
So
TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/",

)
should work, coz'  "In order to override one or more of them, first create
an admin directory in your project's templates directory. This can be any of
the directories you specified in
TEMPLATE_DIRS<http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATE_DIRS>
."

2011/1/17 Chen Xu <xuche...@gmail.com>

> Hi, Django group:
> I am floowing the tutorial 1 on Django site, which is a poll application
> I have problem with overriding the admin page
> I copied   admin/base_site.html   from (django/contrib/admin/templates)
> to   /Users/xuchen81/Django/mysite/admin/base_site.html
>
> and add this line "/Users/xuchen81/Django/mysite/admin/base_site.html"
> to TEMPLATE_DIRS in my settings.py file. It looks like the following:
>
> TEMPLATE_DIRS = (
> "/Users/xuchen81/Django/mysite/admin/base_site.html",
> )
>
> but the admin is just doesn't use this file, it still uses the default
> base_site.html.
>
> Could anyone please help me?
>
> --
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

-- 
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: urgent, undo delete

2011-01-17 Thread Vovk Donets
.delete() performs SQL DELETE command on DB so there is no "undo"  to this
operation.

On Jan 17, 10:18 am, gintare <g.statk...@gmail.com> wrote:
> > Is it possible to undo  model.filter( field_gte = datemin ).delete()
> > if it was the action, which happened from function in views.py, by
> > accidentaly uncommenting the line
>


-- 
*Vovk Donets*
 python/django developer

-- 
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: JavaScript src files not found.

2010-12-17 Thread Vovk Donets
2010/12/17 Robert Steckroth <robertsteckr...@gmail.com>

> Hey coders, Where would stuff like .js src files go in a Django powered
> Website?
> ERROR -->  09:20:08.016: Network: GET
> http://localhost:8000/users/PBUi/mouse.js [HTTP/1.0 404 NOT FOUND 30ms]
> ERROR --> 09:20:07.823: Network: GET
> http://localhost:8000/users/sylvester.js [HTTP/1.0 404 NOT FOUND 11ms]
>
> There is many of these files to include for a entire program included in my
> home page.
> This is in the mySite/templates/users directory in the index.html file.
> What is my fundamental design flaw?
>

if i understand you correctly:
in settings.py theres is a lines
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = /absolute/path
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com;
MEDIA_URL = "/media/"
**so in a template you need specify path to media like this:
{{MEDIA_URL}}path/to/my/cript.js
But keep in mind that this variable must be passed into template via context
processor ("django.core.context_processors.media", ) or directly from view.
As for regular design flow read django manual. There is to much to say in
one letter.
*
Vovk Donets*
 python developer

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.