Re: Can't submit picture through generic view form

2012-05-19 Thread Jian Chang
Your form need a attribute named enctype, and the value is
multipart/form-data, try it.
在 2012-5-19 晚上10:55,"Michael Ackerman" 写道:
>
> I have a generic view:
>
> class create_ticket(CreateView):
> model = ticket
> form_class = ticket_form
> template_name = "create_ticket.html"
> success_url = "/tickets/thanks/"
>
> and a form:
>
> class ticket_form(ModelForm):
> class Meta:
> model = ticket
> fields = ('title','description','picture')
>
> But when I try to submit the data, it get a "This field is required" for
the picture, so I think I'm missing something in order to take in the
picture.
>
> and for reference:
>
> #create_ticket.html:
> {% extends "base.html" %}
> {% block main %}
> {% csrf_token %}
> {{ form.as_table}}
> 
> 
> {% endblock %}
>
> #models.py
> class ticket(models.Model):
> title = models.CharField(max_length = 100)
> date_created = models.DateTimeField(auto_now_add=True)
> description = models.TextField()
> ranking = models.PositiveIntegerField(default=0)
> picture = models.ImageField(
> upload_to ='pictures' )
>
> def __unicode__(self):
> return self.title
>
> All help is appreciated, thank you.
>
> --
> 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.

-- 
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: login or login_decorator issue

2012-08-08 Thread Jian Chang
what's your  '@login_required(login_url='/login/')'?
seems like the decorator leads to the redirection.

2012/8/8 mapapage 

>  for the login I do (username must be the id field(pk) of an 'owners'
> table and password is a  field of the same table):
>
> def login_user(request):
> c = {}
> c.update(csrf(request))
> state = ""
>
> if request.POST:
> password = request.POST.get('password')
> id = request.POST.get('id')
> try:
> user = Owners.objects.get(id = id)
> if user:
> if user.simple_check_password(password):
> url = reverse('main', kwargs={ 'user_id': user.id })
> return HttpResponseRedirect(url)
> else:
> state = 'Incorrect username or password'
> else:
> state = 'Incorrect username or password'
> except Exception as e:
> state = 'Incorrect username or password'
> print state
>  return render_to_response('index.html', locals(), context_instance=
> RequestContext(request))
>
> and I also define:
>
> def set_password(self, raw_password):
> self.password = make_password(raw_password)
>
> def check_password(self, raw_password):
> """
> Returns a boolean of whether the raw_password was correct. Handles
> hashing formats behind the scenes.
> """
> def setter(raw_password):
> self.set_password(raw_password)
> self.save()
> return check_password(raw_password, self.password, setter=None)
>
> def simple_check_password(self,raw_password):
>
> return raw_password == self.password
>
> and at least it seems to me that it works, I mean the user logs in to the
> main.html page.
>
>
>
> --
> 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/-/oPmX_2NBchQJ.
>
> 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.
>

-- 
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: Separate file stream from request input stream while upload

2012-08-08 Thread Jian Chang
是不是可以用异步来完成? ajax upload

2012/8/8 Russell Keith-Magee 

> On Wed, Aug 8, 2012 at 2:42 PM, 春燕 李  wrote:
> > Thanks !
> >
> > In my application, I want to upload  image files(such as *.iso) which
> > are always large, it will take long time before the uploading
> > completed. During this time, I cannot  send out other request on
> > current page, because a new request will refresh the current page and
> > make the uploading failed. My aim is that after I click the Upload
> > button, the file uploading is processed in backend, I can send out
> > other request  simutanously. Firstly , I tried to get the stream, and
> > write  new handler to replace the exsiting processing. But after I
> > read the source code , I find that the input stream got by django is
> > activity limited,  it only can be read once, once reading is started,
> > the current page shouldn't be refresh, or else the stream reading will
> > be failed.
> >
> > Is it realizable to  uploading backend and simutanously send other
> > request on current page, and the uploading won't interrupt because of
> > leaving this page?
>
> Not really. This isn't something that's Django specific -- it's a
> general problem with web browsers. Web browsers make requests.
> Background requests are still requests, and they need to happen in the
> context of a page that is in the foreground. If you change the
> foreground page, you're going to stop any background activity that is
> underway.
>
> That said, there might be something you can do by breaking the
> background task into a large number of smaller requests using the HTTP
> Range header, and then recombining the file on the server side from
> all the individual chunks. That won't stop the background request from
> being killed, but it will give you an opportunity to resume the upload
> on a new page.
>
> However, this isn't something where I can point you at a simple page
> of documentation and say "just call these three lines of Python". What
> you're proposing isn't a simple task. You're going to need to become
> very familiar with the HTTP specification, and work out how to put the
> pieces together yourself.
>
> Yours,
> Russ Magee %-)
>
> --
> 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.
>
>

-- 
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: Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-11 Thread Jian Chang
"d:/wwwroot/djtest/djtest/" was already in system path, so I think you
should set DJANGO_SETTINGS_MODULE like this:
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"settings")

try it![?][?][?]

2012/9/11 DJ-Tom 

> Am Dienstag, 11. September 2012 00:43:44 UTC+2 schrieb Mike Dewhirst:
>
>>
>> Try dropping this down to "djtest.settings". Also make sure you have a
>> file in each of your folders called __init__.py
>>
>> This tells Python the folder is part of the package.
>>
>
> Sorry - but this does not help. Just to be sure that I'm not missing
> anything essential, this is all I have so far:
>
> d:\djtest\
>manage.py
>data.sql
>\djtest\
>   __init__.py
>   settings.py
>   urls.py
>   wsgi.py
>
> Am I correct to assume that this should be sufficient to call at least the
> /admin/ interface?
>
> I have activated this in urls.py:  url(r'^admin/',
> include(admin.site.urls)),
>
> And this in settings.py: 'django.contrib.admin',
>
> But as django does not seem to be able to find settings.py... hm
>
>  --
> 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/-/tEB1E_DacVAJ.
>
> 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.
>

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

<<330.gif>>

Re: authentication in django

2011-08-28 Thread Jian Chang
decorator?

2011/8/27 NISA BALAKRISHNAN 

> Hi,
>
> I am new to django.
> i am making a django app for a logged in user to add movies he
> watched.
>
> how can i block a logged in user from accessing the log in form ?
> the url .../accounts/login
>
> --
> 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.
>
>

-- 
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: Wired image file upload problem

2011-09-29 Thread Jian Chang
size limitation?
it is wired.
[?]

2011/9/28 @@ 

> Hi
> I got a image can't upload while other image works fine, and i use paint
> open this image and save it as another file, then the other file can be
> uploaded.
> The debug page shows the request.FILES is None.
> The attachment is the image can't upload. Sorry for sending a mail with
> attachment.
>
> Is this problem related to the image exif info?
> Thanks.
>
> --
> 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.
>

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

<<342.gif>>

Re: can't get STATICFILES to work (Django dev version)

2011-10-01 Thread Jian Chang
Did you set Debug=False?
在 2011-9-27 上午4:21,"nara" 写道:
> I am having trouble getting STATICFILES to work. I have read the docs,
> and followed the instructions, but I never get my css files to load.
> My current workaround is to put all the css inline in my template
> file, but that should not be a permanent solution.
>
> I am running the django dev version, and I am using the built-in
> server. Here are my changes:
>
> 1. I placed my media (css) files under /home/nara/media
> 2. I added '/home/nara/media' under STATICFILES_DIRS
> (django.contrib.staticfiles is already in INSTALLED_APPS)
> 3. I added {{STATIC_URL}} (no spaces) in front of the reference to
> static files in my template file.
> 4. I restarted the server.
>
> No further changes. I don't have additional copies of the static files
> anywhere else, such
> us under my project, or app.
>
> Looking at the result in firebug within firefox, I get an HTTP
> response of 200 on my css files
> (happen to be css/blueprint/screen.css and print.css), but the files
> are null. Clearing
> the cache, restarting Firefox etc. do not help.
>
> I have been fighting this issue for several days now, and have tried
> many things,
> but the above description is for my current state.
>
> Thanks
> Nara
>
>
> --
> 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.
>

-- 
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: Multiple forms with same name.

2011-10-01 Thread Jian Chang
Fisrt,it's not multiple forms as your description.
You can use request.GET.getlist('text','') to get the every text in one list
在 2011-9-26 下午11:34,"sakthi" 写道:
> In a page i made multiple text forms with the same name. i cannot get
> the values of all the forms. only the last form's value is available.
>
> my html looks like this
>  
> 
> 
> 
> 
> 
>
> how can i get the values of all the forms having the same name.
>
> Thank you.
>
> --
> 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.
>

-- 
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: Multiple forms with same name.

2011-10-01 Thread Jian Chang
request.GET.getlist('txt','')
sorry!
在 2011-10-2 上午4:37,"Jian Chang" 写道:
> Fisrt,it's not multiple forms as your description.
> You can use request.GET.getlist('text','') to get the every text in one
list
> 在 2011-9-26 下午11:34,"sakthi" 写道:
>> In a page i made multiple text forms with the same name. i cannot get
>> the values of all the forms. only the last form's value is available.
>>
>> my html looks like this
>> > 
>> 
>> 
>> 
>> 
>> 
>>
>> how can i get the values of all the forms having the same name.
>>
>> Thank you.
>>
>> --
>> 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.
>>

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

2011-11-17 Thread Jian Chang
yes, you need the decorator @models.permalink

2011/11/15 Rubén Dugo Martín 

> You forget the decorator:
>
> @models.permalink
> def get_absolute_url(self):
>   return ('blog_post_detail', None, {
>'year': self.publish.year,
>'month': self.publish.strftime('%b').lower(),
>'day': self.publish.day,
>'slug': self.slug
> })
>
> 2011/11/15 Fredrik Grahn 
>
>> Hello,
>> I'm trying to get my head around some of the basics of Django and I've
>> run into the strangest problem. Can't figure out what the problem is,
>> the URL from my get_absolute_url() function in my model just refuses
>> to turn into a proper URL. I'll post the code so hopefully it will be
>> obvious for someone with more experience.
>>
>> My url :
>> url(r'^(?P\d{4})/(?P\w{3})/(?P\d{1,2})/(?P[-\w]
>> +)/$',
>>   PostDetailView.as_view(),
>>   name='blog_post_detail'
>> ),
>>
>> My generic view:
>> class PostDetailView(DetailView):
>>queryset= Post.objects.filter(status__gte=2)
>>context_object_name = 'post_detail'
>>template_name   = 'blog/post_detail.html'
>>
>> and finally, the get_absolute_url() function in my model.
>>
>> def get_absolute_url(self):
>>   return ('blog_post_detail', None, {
>>'year': self.publish.year,
>>'month': self.publish.strftime('%b').lower(),
>>'day': self.publish.day,
>>'slug': self.slug
>> })
>>
>> --
>> 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.
>>
>>
>  --
> 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.
>

-- 
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: Cache timeout

2011-11-30 Thread Jian Chang
u can test by yourself.
yes, i don't know the answer, neather
在 2011-11-27 上午12:08,"Addy Yeow" 写道:

> If I use cache_page() decorator for my view function, will the TIMEOUT be
> able to take precedence over CACHE_MIDDLEWARE_SECONDS?
>
> In my settings.py,
>
> CACHES = {
> 'default': {
> 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
> 'LOCATION': os.path.join(WEB_ROOT, "django_cache"),
> 'TIMEOUT': 5184000,
> }
> }
> CACHE_MIDDLEWARE_SECONDS = 86400
>
>  --
> 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.
>

-- 
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: OnChange or OnBlur event in javascript to run python function in Django and return the results???

2012-12-13 Thread Jian Chang
Yes, you need ajax
在 2012-12-13 中午12:29,"Mario Gudelj" 写道:
>
> Hey,
>
> First you need to add some id to that field and then use a jQuery
selector to get the value from it on blur or input:
>
> $('#some_id).on("blur", function(){
>//make your ajax call here
> });
>
> To make the Ajax call you can use jQuery's .post() or .get(). I guess
post method would make a bit more sense in this case. Look up
http://api.jquery.com/jQuery.post/
>
> So your JS looks something like this now:
>
> $('#some_id).on("blur", function(){
> $.post('your-url/', function(data) {
>$('.result').html(data); // do whatever you want with the
returned data
>  });
> });
>
> You need to know how you want to process your data in JS, because you can
return a string or JSON.
>
> At Django's end you need to create your url in the view and create a view
that captures that post.
>
> Your view could look like this:
>
> @csrf_exempt
> def your_view(request):
> if request.is_ajax() and request.method == 'POST':
> captured_post_parameter = request.POST.get('you_field_name')
> # blah blah - do your logic here
> # you can return either HttpResponse(response) or use simplejson
to return json response
>
> That's really all there is to it. I hope it helps!
>
> -mario
> www.zenbookings.com
>
>
>
>
> On 13 December 2012 14:06, Murtaza  wrote:
>>
>> Hello All,
>>
>> I have developed an internal tool with Django and Python in the backend,
now it seems like I have hit a road block.
>>
>> I am very new to Javascript. And the site has to be very dynamic and it
needs to be able to do something like the following:
>>
>> In the input box,
>>
>>   1. The user has entered data
>>
>>   2. When the user moves out from the box, it runs an onBlur or onChange
or some event function which calls a python code that takes some arguments,
and takes other data from the page and Inserts that data in the database
and saves.
>>
>>   3. It does that with out changing the url/refreshing the page or
anything just staying on the same page.
>>
>> Any ideas how to accomplish this with Python and Django.
>>
>> Thanks, any help is appreciated.
>> Murtaza Pitalwala
>>
>>
>> --
>> 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/-/rTK5hli6aJIJ.
>> 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.
>
>
> --
> 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.

-- 
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: only utf-8 letters regex pattern

2013-01-16 Thread Jian Chang
you can use unicode.

2013/1/16 armagan 

> Turkish chars

-- 
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: Database Transaction

2013-01-21 Thread Jian Chang
you mean two different databases?
you can't do the transaction between two different databases.
Anyway you can control the transactions by yourself.
like:
commit all or rollback all if all actions are ok or not,

2013/1/21 Sandeep kaur 

> Hello Django users,
> I have created a django application whose database is totally
> different(different foreign keys, fields, tables etc.) from that of
> old application. But now when I have created the application I require
> the data from old application too. How can I do the data transaction
> among the two applications?
> Your help will be appreciated.
> Thank you.
>
> --
> 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 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.
>
>

-- 
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: Goodbye, Malcolm

2013-03-20 Thread Jian Chang
Rest in peace

2013/3/21 Ernest Mundia 

> M.H.S.R.I.P
>
>
> On Wed, Mar 20, 2013 at 6:16 PM, Javi Romero wrote:
>
>> El martes, 19 de marzo de 2013 18:01:39 UTC+1, Jacob Kaplan-Moss escribió:
>>
>> Hello fellow Djangonauts,
>>>
>>> We have difficult news: Malcolm Tredinnick has passed away.
>>>
>>> Malcolm was a long-time contributor to Django, a model community member,
>>> a brilliant mind, and a friend. His contributions to Django — and to
>>> many other open source projects — are nearly impossible to enumerate.
>>> Many on the core Django team had their first patches reviewed by him;
>>> his mentorship enriched us. His consideration, patience, and dedication
>>> will always be an inspiration to us.
>>>
>>> To say we'll miss him is an understatement.
>>>
>>> Our thoughts are with Malcolm's friends, colleagues, and family at this
>>> difficult time.
>>>
>>> This came as quite a shock, and we're still sorting out details. We'll
>>> update our blog,
>>> https://www.djangoproject.com/**weblog/2013/mar/19/goodbye-**malcolm/,
>>>
>>> once we know the details of how you can express your condolences to
>>> Malcolm's friends and family.
>>>
>>> — The Django Core Team
>>>
>>
>> R.I.P. Thanks for all you've done for the community.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Ernest Mundia
> "Keep lookingDon't settle"
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: PostgresSQL or MySql with django?

2013-03-20 Thread Jian Chang
postgres!
do what you like

2013/3/18 frocco 

> Hello,
>
> What is the recommended database for django?
>
> I have used MySQL, but am interested in Postgres.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: need help with calling following complex query

2011-07-10 Thread Jian Chang
Using raw sql is a better idea

2011/7/11 Jonas Geiregat 

>
>
> In order to find the places in near by area I want to make following
> mysql query. but I am not sure how should I translate it using django
> models and managers.
>
>
> You could execute the raw sql query string, see:
> https://docs.djangoproject.com/en/dev/topics/db/sql/
> for more information on the subject. Seeing the complexity of the query and
> knowing it's a good working version why should you even bother translating
> it to django's ORM framework ?
>
>
> orig.lat = x
> orig.lon = y
>
> "SELECT  destination.*,
> 3956 * 2 * ASIN(SQRT(  POWER(SIN((orig.lat - dest.lat) * pi()/180 /
> 2), 2) +
> COS(orig.lat * pi()/180) *  COS(dest.lat * pi()/180) *
> POWER(SIN((orig.lon -dest.lon) * pi()/180 / 2), 2)  )) as
> distance
> FROM place as dest
> WHERE  dest.longitude
> BETWEEN lon1 and lon2
> AND dest.latitude
> BETWEEN lat1 and lat2
> "
>
> the model which talks to database is called Place in my case.
>
> Thank you all for the help,
> sanket
>
> --
> 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.
>
>
>
> Jonas Geiregat
> jo...@geiregat.org
>
>
>
>
>
>  --
> 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.
>

-- 
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: something about django mysql database long connection

2011-07-13 Thread Jian Chang
Try DBUtils
http://www.webwareforpython.org/DBUtils/Docs/UsersGuide.html

2011/7/13 Kejun He 

> hi,
> I am sorry. My English is very bad.
>
> Yes, i want to make persistent databases connection on each session.
>
>
> and yesterday i try to modify the  code on
> "site-packages\django\db\__init__.py"
>
> 
> def close_connection(**kwargs):
> for conn in connections.all():
> conn.close()
> #signals.request_finished.connect(close_connection) <---
>
> 
>
> could it work?
>
> regards,
> he
>
>
>
>
> On Mon, Jul 11, 2011 at 7:31 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>>
>>
>> On Mon, Jul 11, 2011 at 4:49 AM, oops  wrote:
>>
>>> hi,
>>> Now, i am doing a django project, and use models to do all operation
>>> about data in mysql db.
>>>
>>> and i think that it would connect to database whenever  do some
>>> operation like 'XXX.objects.all()' , may be it would cast much of
>>> resource on database connection. So i need a connection never being
>>> desconnected.
>>>
>>
>> At as best guess (as the question is somewhat broken), are you asking how
>> to make persistent connections which are guaranteed to never time out in a
>> single session?
>>
>> Could you clarify a little more on your question please?
>>
>> Cal
>>
>>
>>>
>>> Does django has this function?  And how to do for it??
>>>
>>> thank you
>>> rgs,
>>> he
>>>
>>> --
>>> 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.
>>>
>>>
>>  --
>> 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.
>>
>
>  --
> 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.
>

-- 
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: blog breack after 10 post x__x

2011-07-15 Thread Jian Chang
django doesn't have,
but you can extent  based on django.core.paginator.Paginator.The attachment
is what i use, you can change it by your needs



2011/7/16 Kase 

> realy i dont know how to expres this..
>
> i need this
> (is a blog app)
>
> 1) post
> 2)post
> 3)post
> ...
> 10)post
> page 1,2,3,4,5,6,7,8.last
>
> when clic 2  list of post are
> 11)post
> 12)post
> 
> 20)post
>
> django  have somthing to do this in the easiest
>
> my code is the (obius)
>
> {%for x in post%}
> {{x.title}}
> {{x.post}}
> by:{{x.user.username}} about  {(x.time|timesince)} ago
> {%endfor%}
>
> --
> 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.
>
>

-- 
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: blog breack after 10 post x__x

2011-07-15 Thread Jian Chang
2011/7/16 Jian Chang 

> django doesn't have,
> but you can extent  based on django.core.paginator.Paginator.The attachment
> is what i use, you can change it by your needs
>
>
>
>
> 2011/7/16 Kase 
>
>> realy i dont know how to expres this..
>>
>> i need this
>> (is a blog app)
>>
>> 1) post
>> 2)post
>> 3)post
>> ...
>> 10)post
>> page 1,2,3,4,5,6,7,8.last
>>
>> when clic 2  list of post are
>> 11)post
>> 12)post
>> 
>> 20)post
>>
>> django  have somthing to do this in the easiest
>>
>> my code is the (obius)
>>
>> {%for x in post%}
>> {{x.title}}
>> {{x.post}}
>> by:{{x.user.username}} about  {(x.time|timesince)} ago
>> {%endfor%}
>>
>> --
>> 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.
>>
>>
>

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



pagination.py
Description: Binary data


Re: django.core.urlresolvers.reverse capturing group before include behavior

2011-07-15 Thread Jian Chang
try this: reverse("mysites.views.index")

2011/7/16 Squeesh 

> I have run into an issue using reverse() to lookup named urls with
> capturing groups before an include().
>
> Code:
>
> mysite/urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
>url(r'^$',  'views.index',
> name='root'),
>url(r'^(?P\w+)/test/',   include('test.urls',
> namespace='test')),
> )
> end mysite/urls.py
>
>
> mysite/test/urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
>url(r'^$',  'test.views.index',
> name='index'),
> )
> end mysite/test/urls.py
>
>
> mysite/views.py
> from django.core.urlresolvers import reverse
> from django.http import HttpResponse
>
> def index(request):
># Works: returns '/(?P\w+)/test/'
>test_url = reverse('test:index')
>
># NoReverseMatch: Reverse for 'index' with arguments '('slug',)'
>#and keyword arguments '{}' not found.
>test_url = reverse('test:index', args=['slug'])
>
># NoReverseMatch: Reverse for 'index' with arguments '()'
>#and keyword arguments '{'some_slug': 'slug'}' not found.
>test_url = reverse('test:index', kwargs={'some_slug': 'slug'})
>
># Desired output is '/slug/test/'
>
>return HttpResponse("""
>root index
>Test
>""".format(test_url=test_url))
> end mysite/views.py
>
>
> mysite/test/views.py
> from django.http import HttpResponse
>
> def index(request, some_slug):
>return HttpResponse('test index: %s' % some_slug)
> end mysite/test/views.py
>
>
> reverse('test:index') will only resolve if you don't pass it any
> arguments. And then the result is the original regex... The desired
> behavior is for it to either accept args or kwargs of 'slug' and
> return '/slug/test/'.
>
> Is there a setting that I am missing to allow for this behavior? Is
> this a known bug?
>
> Any information would be greatly appreciated.
>
>
> Derek
>
> --
> 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.
>
>

-- 
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: Is there a way to insert data from a csv file into my database?

2011-07-24 Thread Jian Chang
Using copy_from is easy to solve it. And if you want to a get a speical
format file from that csv, use a scirpt to handle it.
http://www.initd.org/psycopg/docs/cursor.html#cursor.copy_from
2011/7/25 nixlists 

> On Sun, Jul 24, 2011 at 2:46 PM, Jarilyn Hernandez
>  wrote:
> > Hi, Thanks for the response. My problem is that I have my tables created
> on
> > django. All I want is to import some data from a csv file to these tables
>
> I am using HeidiSQL with MySQL for this, but a script could do much
> more than simple single table loads.
>
> --
> 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.
>
>

-- 
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: Using Form Elements Widgets direclty in HTML

2011-08-09 Thread Jian Chang
Since you don't want to use forms class, you can write elements in your
templates directly.

2011/8/9 Hayyan Rafiq 

>  Hi I wanted to know if there was a way in which we could use widget
> directly in an HTML file
> By widget i mean elements of a form such as input boxes,calendars,Buttons
> etc without using the forms class.
>
> For example A default normal html input box is :
> 
> I wanted to replace it with a fancier (more interesting and professional)
> input box..
> any suggestions on how i could do that would be appreciated..
>
> I  also wanted to use a table in my HTML to display contents from my DB. Do
> you guys have anything in mind which might be useful for me...
> I currently am generating the table dynamically using  tag
>
>  --
> 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.
>

-- 
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 order "links" in the Admin?

2011-08-09 Thread Jian Chang
you should figure out what it is based on to order these urls.

i use time stamp to order them.


2011/8/10 Andre Lopes 

> Hi,
>
> I'm testing Django for my first project using it.
>
> I have a model like this:
> 
> from django.db import models
> import datetime
>
> class Directory(models.Model):
>   website_name = models.CharField(max_length=200)
>   website_url = models.CharField(max_length=200)
>   website_position = models.IntegerField()
>   pub_date = models.DateTimeField('date published')
> 
>
> Basicaly this model is for storing URL's, but I need to order them,
> and for that I use "website_position" to control if the link will be
> at the top or at the end or in the middles...
>
> My question is, there is a better way to control the positions of the
> links? Django Admin have any feature that could help to deal with this
> specific case?
>
> Please let me know.
>
> Best Regards,
>
> --
> 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.
>
>

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