Re: Anyone interested in reviewing code for a hobby project - BookMarker

2014-06-10 Thread trojactory
Hi Aseem,

> Is there some other layout?

Yes. The current version of Django uses the layout mentioned in the 
tutorial itself: https://docs.djangoproject.com/en/1.6/intro/tutorial01/

> The second part about relative imports. I have never understood how 
relative imports work. I mean the syntax. I have went through the PEP to 
understand it and did a lot of google searches but that is something that I 
never got the hang of. Is there any specific reason that I should be using 
them?

Relative imports would continue to work even if your app or project name 
changes. They are also unambiguous as mentioned in the docs 
.

> Would you like to use an app that won't autocomplete?

I think the confusion was caused by your flat-style project layout. There 
is a distinction between a Django project and an app. I was referring to 
adding too much functionality into a bookmarking *app*. It is perfectly 
fine in a project though.

Cheers,
Arun

On Wednesday, 11 June 2014 00:03:30 UTC+5:30, Aseem Bansal wrote:
>
> I did not understand what you said regarding having a standard layout. I 
> mean I am already using the layout that was explained in the Django 
> tutorials. Keeping all my HTML in the template directory and all static 
> files in the static directory with namespacing with the app name which is 
> BookMarker. Is there some other layout?
>
>
>  I used CharField instead of URLField because there is a problem with 
> URLField. It is not allowing me to add local files as bookmarks which is 
> actually valid URL. I mean currently I have bookmarks in my browser like 
> file:///D:/Study/Docs/Python/python-3.4.0-docs-html/index.html 
> It is perfectly valid URL but URLField is marking it as invalid. So I used 
> CharField.
>
> The second part about relative imports. I have never understood how 
> relative imports work. I mean the syntax. I have went through the PEP to 
> understand it and did a lot of google searches but that is something that I 
> never got the hang of. Is there any specific reason that I should be using 
> them?
>
> The app's goal is for me to be able to us this app for storing and using 
> my bookmarks through the app instead of my webbrowser. The problem is that 
> I have lot of bookmarks. Both offline and online bookmarks which I am 
> currently maintaining in a multiple hierarchy of bookmark folders. It is 
> going messy. I need this app to be an application that I can use to add, 
> update, delete, view bookmarks by categories. Adding, deleting categories 
> and searching by categories is also necessary for me to switch to this app. 
> Otherwise there is no benefit. 
>
> The reason I am using autocomplete is that I want searching for categories 
> easier. Same goes for already added bookmarks.  Would you like to use an 
> app that won't autocomplete? Nobody will including myself. The reason for 
> opening a webbrowser is that I need to be able to use my bookmarks through 
> this app. I can serve the bookmarks as hyperlinks on which a simple click 
> can do the job of opening the webpage. But browser security does not allow 
> me to open locally stored bookmarks like the one I gave above to be opened 
> this way. When I came to know about this thing I had two choices - switch 
> to a GUI framework or find an acceptable workaround. As my server and 
> client or on the same machine and the security of browser do not apply to 
> my Python installation I chose to send the request of opening the bookmark 
> to server which will be able to open both offline and online bookmarks.
>
> I understand the need for documentation but I think as there is an 
> assumption of server and client on same machine for opening the bookmarks 
> no one will want to use it anyway. Bad jokes aside, I am learning Django, 
> Javscript/jQuery through this project I don't feel comfortable adding 
> another topic to learn side-by-side alongwith my job. My goal is to make an 
> app for personal use. If I add too much things to learn at the same time I 
> will lose the interest that keeps me going. I will consider making one the 
> proper way when I am more comfortable with these things and I have an idea 
> which is reusable.
>
> If there is anything else please let me know. I will try my best to 
> explain. 
>
>
> On Tuesday, June 10, 2014 6:48:59 PM UTC+5:30, trojactory wrote:
>>
>> Aseem,
>>
>> I had a quick look at your Django app and here are some of my 
>> observations:
>>
>>
>>1. Most Django apps have a standard layout with the app in a 
>>directory named after itself. See django-taggit 
>>
>> 
>>  
>>for instance.
>>2. You have made some unconventional choices which needs to be 
>>explained like using CharField instead of URLField, not using 
>>relative paths in imports etc.
>>3. An app must do one thing rea

Re: Admin site doesn't work

2014-06-10 Thread Rini Michael
while launching through the browser do u give something like
http://127.0.0.1:8000/admin/


On Wed, Jun 11, 2014 at 7:40 AM, Glen J  wrote:

> I read another post on here about how their Django site admin site would
> not come up.  In their case, they had failed to edit the urls.py and
> settings.py to enable the site.  I have done that and also done a syncdb
> after making those changes and the admin sited does not come up.  All that
> displays is the welcome site indicating that Django is working.  Like the
> other person posting, I am simply following along (or trying) with the
> Django tutorial.  What else can I look at to get to the bottom of this?
> Any help would be much appreciated!
>
> Glen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/12a96433-60d9-4f63-a3e0-0aa7685f33d9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Admin site doesn't work

2014-06-10 Thread Glen J
I read another post on here about how their Django site admin site would 
not come up.  In their case, they had failed to edit the urls.py and 
settings.py to enable the site.  I have done that and also done a syncdb 
after making those changes and the admin sited does not come up.  All that 
displays is the welcome site indicating that Django is working.  Like the 
other person posting, I am simply following along (or trying) with the 
Django tutorial.  What else can I look at to get to the bottom of this?  
Any help would be much appreciated!

Glen

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


Re: Re: Django python fuction

2014-06-10 Thread moqianc...@gmail.com
Yeah, I think hito koto need a function like copy.deepcopy.. I think he known 
copy.deepcopy before(as his example said),  just not known how to write a 
funtion work as copy.deecopy does for list.




moqianc...@gmail.com

From: François Schiettecatte
Date: 2014-06-11 00:21
To: django-users
Subject: Re: Django python fuction
Wouldn't the deep copy module handle this for you:

https://docs.python.org/2/library/copy.html

François

On Jun 10, 2014, at 12:17 PM, hito koto  wrote:

> Hi,  Qiancong :
> 
> I was looking for exactly this、
> Thank you ver much!
> 
> 
> 2014年6月10日火曜日 23時35分52秒 UTC+9 Qiancong:
> 
> Hi, hito koto:
> I think you want to deep copy the list. The following code maybe  helpful:
> def dcopy(obj):
> if not isinstance(obj, list):
> return obj
> return [dcopy(x) for x in obj]
>  
> But this function only deep copy for list.  You can change code as what I did 
> for dic, set, tuple , etc ..
> moqia...@gmail.com
>  
> From: François Schiettecatte
> Date: 2014-06-10 22:07
> To: django-users
> Subject: Re: Django python fuction
> You need to use .append() to add elements to a list, I suggest you take a 
> look at the python tutorial:
>  
> https://docs.python.org/2/tutorial/
>  
> Not quite sure what you are doing with i or elem either.
>  
> François
>  
> On Jun 10, 2014, at 10:01 AM, hito koto  wrote:
>  
> > So, I also have errors:
> >
> >
> > >>> def foo(x):
> > ... myList = []
> > ... if isinstance(x, list):
> > ... for i in x:
> > ... elem = i
> > ... return myList + foo(elem)
> > ... else:
> > ... return 1
> > ...
> > >>>
> > >>> foo(a)
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "", line 6, in foo
> >   File "", line 6, in foo
> > TypeError: can only concatenate list (not "int") to list
> >
> >
> >
> >
> >
> > 2014年6月10日火曜日 22時53分28秒 UTC+9 François Schiettecatte:
> > You are redefining 'list' on  line 2, rename list to myList as follows:
> >
> > def foo(x):
> > myList = []
> > if isinstance(x, list):
> > for i in x:
> > elem = i
> > return myList + foo(i)
> > else:
> > return 1
> >
> > And take this to a python list, this is for django.
> >
> > Cheers
> >
> > François
> >
> >
> > On Jun 10, 2014, at 9:43 AM, hito koto  wrote:
> >
> > > hi,
> > >
> > > I have this erroes:
> > >
> > > >>> def foo(x):
> > > ... list = []
> > > ... if isinstance(x, list):
> > > ... for i in x:
> > > ... elem = i
> > > ... return list + foo(i)
> > > ... else:
> > > ... return 1
> > > ...
> > > >>> foo(a)
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > >   File "", line 3, in foo
> > > TypeError: isinstance() arg 2 must be a class, type, or tuple of classes 
> > > and types
> > >
> > >
> > >
> > > 2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell:
> > > In general, I recommend adding the line "import pdb;pdb.set_trace()"
> > > to the top of your function and walking through it to see why it doesn't 
> > > work.
> > >
> > > def foo(x):
> > > import pdb;pdb.set_trace()
> > >
> > > list = []
> > > if isinstance(x, list):
> > > for i in x:
> > > elem = i
> > > return list + foo(i)
> > > else:
> > > return 1
> > >
> > > See https://docs.python.org/2/library/pdb.html on how pdb works.
> > > There are faster ways to debug, but when starting out, pdb lets you see 
> > > what is happening as you run the function.
> > >
> > >
> > > Some questions I have about this function:
> > > - What is the purpose of the "elem" function? It is never accessed.
> > > - What is the purpose of returning 1 if the argument is not a list?
> > > - Why is it named "foo" rather than something that tells me what the 
> > > purpose of the function is?
> > >
> > >
> > > On Tue, Jun 10, 2014 at 8:16 AM, hito koto  wrote:
> > > Hello,
> > >
> > > I don't know how can i do to change to write python function
> > > I want to following code change to write python function or change to 
> > > write  recursive definition
> > > >>> y = [10, 12, [13, [14, 9], 16], 7]
> > > >>> z = copy.deepcopy(y)
> > > >>> y
> > > [10, 12, [13, [14, 9], 16], 7]
> > > >>> z
> > > [10, 12, [13, [14, 9], 16], 7]
> > > >>> z[2][1][1]
> > > 9
> > > >>> z[2][1][1] = 88
> > > >>> z
> > > [10, 12, [13, [14, 88], 16], 7]
> > > [10, 12, [13, [14, 9], 16], 7]
> > > >>>
> > >
> > > this is my use function but not work:
> > >
> > > def foo(x):
> > > list = []
> > > if isinstance(x, list):
> > > for i in x:
> > > elem = i
> > > return list + foo(i)
> > > else:
> > > return 1
> > >
> > >
> > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To unsubscribe from this group and stop rec

Any interest in update_fields=dict(...)?

2014-06-10 Thread Rich Rauenzahn

I have a use case where I am retroactively adding save(update_fields=...) 
to an existing code base.  Sometimes the code is structured such that 
'self' of the model is modified in other helper methods of the model, but 
not saved immediately.  It seems like it would be useful to restructure the 
code such that these other methods modify a dict I pass around, and then 
when I am ready to save, I pass that dict to save() -- rather than guessing 
-- and hoping -- that I've listed (and kept up to date!) all of the 
relevant fields in the update_fields list.

It's kinda like:

class Foo(Model):
 
 def _go_do_the_complicated_stuff(self):
 self.a = ...
 self.b = ...
 ...

 def doit(self):
 self._go_do_the_complicated_stuff()
 self.done = True
 self.save(update_fields=[u???])

Where it could be:

class Foo(Model):
 
 def _go_do_the_complicated_stuff(self):
 return dict(a = ...,
 b = ...,
 ...)

 def doit(self):
 updates = self._go_do_the_complicated_stuff()
 updates['done'] = True
 self.save(update_fields=updates)

I like this because it is easy to inspect what is getting saved (and should 
be saved) at save time.

Implementation-wise, django would check update_fields for a dict (or just 
use another key) and do something like:

 for attr, value in d.iteritems(): 
setattr(self, attr, value)
 self.save(update_fields=d.keys())

Now, I know I can just make my own mixin (maybe add a save_dict()) to do 
this, but it seemed like something worth sharing.



Rich

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6f7f4bd1-1f63-4c16-92a8-600392792ff1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cant get to admin login page

2014-06-10 Thread Glen J
I have this exact same problem.  I'be checked both settings.py and urls.py 
and done a syncdb and still get nothing but the welcome page.  Any other 
ideas on what to check?

On Thursday, June 6, 2013 5:53:12 PM UTC-4, Rebecca wrote:
>
> I'm on part 2 of the django book tutorial (
> https://docs.djangoproject.com/en/dev/intro/tutorial02/) and am trying to 
> get onto the admin login page in my browser.  When I go to the admin site 
> on my local domain (http://127.0.0.1:8000/admin/), I dont get to the 
> login screen.  I get to something else from django 
>
> "
> It worked!Congratulations on your first Django-powered page.
>
> Of course, you haven't actually done any work yet. Here's what to do next:
>
>- If you plan to use a database, edit the DATABASES setting in 
>myproject/settings.py.
>- Start your first app by running python manage.py startapp [appname].
>
> You're seeing this message because you have DEBUG = True in your Django 
> settings file and you haven't configured any URLs. Get to work!"
>
>
>
> but not the login screen it said i would get in the tutorial.  Anyone know 
> why? or how to get to the login page?
>
>
> Thanks!!
>

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


Re: distinct().filter() applies filter before distinct

2014-06-10 Thread John Rambo
This better illustrates what I mean:

Example.objects.order_by('a','foreignkey__b').distinct('a').filter(foreignkey__b='something')

On Tuesday, June 10, 2014 4:06:50 PM UTC-5, John Rambo wrote:
>
> If we chain a call to filter() after a call to distinct(), the filter is 
> applied to the query before the distinct. How do I filter the results of a 
> query *after* applying distinct?
>
> Example.objects.order_by('a','b').distinct('a').filter(b='something)
>
> The where clause in the SQL resulting from filter() means the filter is 
> applied to the query before the distinct. I want to filter the queryset 
> resulting from the distinct.
>
> This is probably pretty easy, but I just can't quite figure it out and I 
> can't find anything on it.
>
> Another way to ask the question is how do I return a distinct QuerySet and 
> then filter it?
>

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


distinct().filter() applies filter before distinct

2014-06-10 Thread John Rambo
 

If we chain a call to filter() after a call to distinct(), the filter is 
applied to the query before the distinct. How do I filter the results of a 
query *after* applying distinct?

Example.objects.order_by('a','b').distinct('a').filter(b='something)

The where clause in the SQL resulting from filter() means the filter is 
applied to the query before the distinct. I want to filter the queryset 
resulting from the distinct.

This is probably pretty easy, but I just can't quite figure it out and I 
can't find anything on it.

Another way to ask the question is how do I return a distinct QuerySet and 
then filter it?

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


South to Migrations detail

2014-06-10 Thread Craig Labenz


In South, automatically generated migrations that add models fire the 
function send_create_signal(), which among other things, results in a 
ContentType record being written for the new model. Except that it doesn't, 
because it actually just queues up that signal to be fired at the end of 
the whole process by the function really_send_create_signal().

This is trouble for subsequent data migrations that are counting on those 
ContentType records. To date I've had to manually changesend_create_signal()
 to really_send_create_signal() to immediately fire that action and set up 
future data migrations correctly. Obviously, that is an ugly process.

My question is: In Django 1.7, where Migrations replaces the need for 
South, how will this function?

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


Re: Anyone interested in reviewing code for a hobby project - BookMarker

2014-06-10 Thread Aseem Bansal
I did not understand what you said regarding having a standard layout. I 
mean I am already using the layout that was explained in the Django 
tutorials. Keeping all my HTML in the template directory and all static 
files in the static directory with namespacing with the app name which is 
BookMarker. Is there some other layout?


 I used CharField instead of URLField because there is a problem with 
URLField. It is not allowing me to add local files as bookmarks which is 
actually valid URL. I mean currently I have bookmarks in my browser like 
file:///D:/Study/Docs/Python/python-3.4.0-docs-html/index.html 
It is perfectly valid URL but URLField is marking it as invalid. So I used 
CharField.

The second part about relative imports. I have never understood how 
relative imports work. I mean the syntax. I have went through the PEP to 
understand it and did a lot of google searches but that is something that I 
never got the hang of. Is there any specific reason that I should be using 
them?

The app's goal is for me to be able to us this app for storing and using my 
bookmarks through the app instead of my webbrowser. The problem is that I 
have lot of bookmarks. Both offline and online bookmarks which I am 
currently maintaining in a multiple hierarchy of bookmark folders. It is 
going messy. I need this app to be an application that I can use to add, 
update, delete, view bookmarks by categories. Adding, deleting categories 
and searching by categories is also necessary for me to switch to this app. 
Otherwise there is no benefit. 

The reason I am using autocomplete is that I want searching for categories 
easier. Same goes for already added bookmarks.  Would you like to use an 
app that won't autocomplete? Nobody will including myself. The reason for 
opening a webbrowser is that I need to be able to use my bookmarks through 
this app. I can serve the bookmarks as hyperlinks on which a simple click 
can do the job of opening the webpage. But browser security does not allow 
me to open locally stored bookmarks like the one I gave above to be opened 
this way. When I came to know about this thing I had two choices - switch 
to a GUI framework or find an acceptable workaround. As my server and 
client or on the same machine and the security of browser do not apply to 
my Python installation I chose to send the request of opening the bookmark 
to server which will be able to open both offline and online bookmarks.

I understand the need for documentation but I think as there is an 
assumption of server and client on same machine for opening the bookmarks 
no one will want to use it anyway. Bad jokes aside, I am learning Django, 
Javscript/jQuery through this project I don't feel comfortable adding 
another topic to learn side-by-side alongwith my job. My goal is to make an 
app for personal use. If I add too much things to learn at the same time I 
will lose the interest that keeps me going. I will consider making one the 
proper way when I am more comfortable with these things and I have an idea 
which is reusable.

If there is anything else please let me know. I will try my best to 
explain. 


On Tuesday, June 10, 2014 6:48:59 PM UTC+5:30, trojactory wrote:
>
> Aseem,
>
> I had a quick look at your Django app and here are some of my observations:
>
>
>1. Most Django apps have a standard layout with the app in a directory 
>named after itself. See django-taggit 
>
> 
>  
>for instance.
>2. You have made some unconventional choices which needs to be 
>explained like using CharField instead of URLField, not using relative 
>paths in imports etc.
>3. An app must do one thing really well in order to be most reusable. 
>I believe autocomplete and opening a web browser don't belong to a 
>bookmarking app.
>4. There needs to be more unit tests and documentation to increase 
>confidence of other developers in using the app.
>
> Sorry, if I have misunderstood the objectives of your project, but these 
> things stood out to me.
>
> Cheers,
> Arun
>
>
> On Saturday, 7 June 2014 15:37:52 UTC+5:30, Aseem Bansal wrote:
>>
>> I last asked for a review around two weeks back for my project. Is anyone 
>> interested to give a second review for this project? 
>>
>> https://github.com/anshbansal/Bookmarker
>>
>> The last thread was here 
>> https://groups.google.com/forum/#!topic/django-users/ob4fXz3GF9w in case 
>> someone wants to see that I actually respond to people's comments instead 
>> of just wasting their time.
>>
>> From last time I have done these changes -
>> 1 Bookmark update as per categories  is now working
>> 2 Used templates to make some things simpler to understand
>> 3 Refactoring of view.py to get reusable components
>> 4 Refactored jquery to make it cleaner so it is actually possible to read 
>> it
>> 5 Added CDN of librarires an

Re: Anyone interested in reviewing code for a hobby project - BookMarker

2014-06-10 Thread Aseem Bansal
Rendering the Javascript through Django template engine. Noted. I am trying 
to keep it simple but I am not an expert. Asked for a review. Chip in if 
you are interested.
 
http://codereview.stackexchange.com/questions/53896/personal-project-for-managing-my-bookmarks

On Monday, June 9, 2014 7:01:47 PM UTC+5:30, shmengie wrote:
>
>
>
> On Saturday, June 7, 2014 6:07:52 AM UTC-4, Aseem Bansal wrote:
>
>>
>> My main concern currently is that this project is turning out to have a 
>> lot more jQuery than Python/HTML.  Am I designing this incorrectly? I 
>> understand that as my requirements are mostly asynchronous so there is a 
>> need for javascript but redundancy like hard-coding URLs for autocomplete 
>> in javascript is bothering me. Also am I over-engineering the Javascript?
>>
>  
>
> Can't say I delved real deep into your efforts.  My comments on your 
> observations.
>
> A lot of us like django because there's less code involved.
>
> You can get around hard coding by rendering javascript (or some code 
> segments) through the template engine.  
>
> I find the simpler you keep javascript, the easier it is to maintain.  
> Maybe HTML7 will encompass a new scripting language. ;)
>

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


Re: Modifying the request.POST data that is received from a form; form is not getting validated then

2014-06-10 Thread Anurag Baidyanath
sorry for the unreadable code!
I have cleaned it up as suggested and posted it below.

the user is displayed only email,subject,help_topic and message fields. 
rest all the fields are hidden. when the form is submitted; in the 
submit_ticket() in views.py i have copied the request.POST into a 
dictionary and have overwritten the blank values which were in the POST 
request with dynamically generated values. 

interestingly, The form validates now but upon save i get blank values in 
the database, i.e. values for all the fields are blank!

Please help me out.
P.S. earlier the form was not getting validated due to reasons i am 
ignorant with

i am attaching the submit function in the views.py file and the forms.py 
file

forms.py file


from django import forms
from django.contrib.auth.models import User
from ac.models import UserProfile, Category
import datetime
from ac.models import *
from datetime import timedelta
class SubmitTicketForm(forms.ModelForm):
email=forms.EmailField(max_length=128,help_text="please 
enter your email address")
ticket_id=forms.IntegerField(widget=forms.HiddenInput())
subject=forms.CharField(max_length=100,help_text="subject")
help_topic=forms.ChoiceField(choices=[(x['category'], 
str(x['category'])) for x in 
Category.objects.values('category')],help_text="please enter the category 
of your problem")
message=forms.CharField(max_length=500,help_text="message")

created_date_time=forms.DateTimeField(widget=forms.HiddenInput())

overdue_date_time=forms.DateTimeField(widget=forms.HiddenInput())

closed_date_time=forms.DateTimeField(widget=forms.HiddenInput())
status=forms.IntegerField(widget=forms.HiddenInput())

reopened_date_time=forms.DateTimeField(widget=forms.HiddenInput())

topic_priority=forms.IntegerField(widget=forms.HiddenInput())

duration_for_reply=forms.IntegerField(widget=forms.HiddenInput())
class Meta:
model=Ticket#all the fields are included
fields=('email','subject','help_topic','message')


view where the form is handled

def submit(request):
context=RequestContext(request)
if(request.method=="POST"):
data = request.POST.copy()
print "\n"
print request.user.email
data['created_date_time']=datetime.datetime.now()
data['overdue_date_time']=datetime.datetime.now()
Date=datetime.datetime.now()
Enddate=Date+datetime.timedelta(days=1)
data['overdue_date_time']=Enddate
data['closed_date_time']=Enddate
data['status']=0 # 0 means that the ticket is still 
open and not yet answered
data['reopened_date_time']=Enddate
data['topic_priority']=2 # 2 is the default priority of 
medium
data['duration_for_reply']=24 #in hours
if request.user.is_authenticated():
print request.user
data['user_id']=request.user.email
else:
return HttpResponse("you need to be a valid user to 
submit a ticket. click here to go to the login page")t
from django.db.models import Max

last_ticket=int(Ticket.objects.all().aggregate(Max('ticket_id'))['ticket_id__max'])
data['ticket_id']=last_ticket+1
user_form=SubmitTicketForm(data)
if user_form.is_valid():
 user_form.save()
 return HttpResponse("Saved successfully")
else:
  return HttpResponse("Saved unsuccessfully")
  print user_form.errors
else:
 user_form=SubmitTicketForm()
 return render_to_response(
'submit.html',
{'user_form': user_form},
context)

the model upon which the form is based

class Ticket(models.Model):
user_id=models.EmailField()
topic_id=models.CharField(max_length=100,help_text="enter topic id")
message=models.TextField()
ticket_id=models.IntegerField()
file_uploads=models.FileField(upload_to='tickets/file' , blank=True)
created_date_time=models.DateTimeField(auto_now_add=True)
overdue_date_time=models.DateTimeField(auto_now_add=True)
closed_date_time=models.DateTimeField(auto_now_add=True)
status=models.IntegerField()
reopened_date_time=models.DateTimeField(auto_now_add=True)
topic_priority=models.IntegerField()
duration_for_reply=models.IntegerField()
def __unicode__(self):
return unicode(

Re: Django python fuction

2014-06-10 Thread François Schiettecatte
Wouldn't the deep copy module handle this for you:

https://docs.python.org/2/library/copy.html

François

On Jun 10, 2014, at 12:17 PM, hito koto  wrote:

> Hi,  Qiancong :
> 
> I was looking for exactly this、
> Thank you ver much!
> 
> 
> 2014年6月10日火曜日 23時35分52秒 UTC+9 Qiancong:
> 
> Hi, hito koto:
> I think you want to deep copy the list. The following code maybe  helpful:
> def dcopy(obj):
> if not isinstance(obj, list):
> return obj
> return [dcopy(x) for x in obj]
>  
> But this function only deep copy for list.  You can change code as what I did 
> for dic, set, tuple , etc ..
> moqia...@gmail.com
>  
> From: François Schiettecatte
> Date: 2014-06-10 22:07
> To: django-users
> Subject: Re: Django python fuction
> You need to use .append() to add elements to a list, I suggest you take a 
> look at the python tutorial:
>  
> https://docs.python.org/2/tutorial/
>  
> Not quite sure what you are doing with i or elem either.
>  
> François
>  
> On Jun 10, 2014, at 10:01 AM, hito koto  wrote:
>  
> > So, I also have errors:
> >
> >
> > >>> def foo(x):
> > ... myList = []
> > ... if isinstance(x, list):
> > ... for i in x:
> > ... elem = i
> > ... return myList + foo(elem)
> > ... else:
> > ... return 1
> > ...
> > >>>
> > >>> foo(a)
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "", line 6, in foo
> >   File "", line 6, in foo
> > TypeError: can only concatenate list (not "int") to list
> >
> >
> >
> >
> >
> > 2014年6月10日火曜日 22時53分28秒 UTC+9 François Schiettecatte:
> > You are redefining 'list' on  line 2, rename list to myList as follows:
> >
> > def foo(x):
> > myList = []
> > if isinstance(x, list):
> > for i in x:
> > elem = i
> > return myList + foo(i)
> > else:
> > return 1
> >
> > And take this to a python list, this is for django.
> >
> > Cheers
> >
> > François
> >
> >
> > On Jun 10, 2014, at 9:43 AM, hito koto  wrote:
> >
> > > hi,
> > >
> > > I have this erroes:
> > >
> > > >>> def foo(x):
> > > ... list = []
> > > ... if isinstance(x, list):
> > > ... for i in x:
> > > ... elem = i
> > > ... return list + foo(i)
> > > ... else:
> > > ... return 1
> > > ...
> > > >>> foo(a)
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > >   File "", line 3, in foo
> > > TypeError: isinstance() arg 2 must be a class, type, or tuple of classes 
> > > and types
> > >
> > >
> > >
> > > 2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell:
> > > In general, I recommend adding the line "import pdb;pdb.set_trace()"
> > > to the top of your function and walking through it to see why it doesn't 
> > > work.
> > >
> > > def foo(x):
> > > import pdb;pdb.set_trace()
> > >
> > > list = []
> > > if isinstance(x, list):
> > > for i in x:
> > > elem = i
> > > return list + foo(i)
> > > else:
> > > return 1
> > >
> > > See https://docs.python.org/2/library/pdb.html on how pdb works.
> > > There are faster ways to debug, but when starting out, pdb lets you see 
> > > what is happening as you run the function.
> > >
> > >
> > > Some questions I have about this function:
> > > - What is the purpose of the "elem" function? It is never accessed.
> > > - What is the purpose of returning 1 if the argument is not a list?
> > > - Why is it named "foo" rather than something that tells me what the 
> > > purpose of the function is?
> > >
> > >
> > > On Tue, Jun 10, 2014 at 8:16 AM, hito koto  wrote:
> > > Hello,
> > >
> > > I don't know how can i do to change to write python function
> > > I want to following code change to write python function or change to 
> > > write  recursive definition
> > > >>> y = [10, 12, [13, [14, 9], 16], 7]
> > > >>> z = copy.deepcopy(y)
> > > >>> y
> > > [10, 12, [13, [14, 9], 16], 7]
> > > >>> z
> > > [10, 12, [13, [14, 9], 16], 7]
> > > >>> z[2][1][1]
> > > 9
> > > >>> z[2][1][1] = 88
> > > >>> z
> > > [10, 12, [13, [14, 88], 16], 7]
> > > [10, 12, [13, [14, 9], 16], 7]
> > > >>>
> > >
> > > this is my use function but not work:
> > >
> > > def foo(x):
> > > list = []
> > > if isinstance(x, list):
> > > for i in x:
> > > elem = i
> > > return list + foo(i)
> > > else:
> > > return 1
> > >
> > >
> > >
> > >
> > >
> > > --
> > > 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.
> > > To view this discussion on the web visit 
> > > https://groups.google.com/d/msgid/django-us

runserver error

2014-06-10 Thread kim jinhoo
I installed both python and django. 
After I create a project, I try to run a server error occurred. 
So had to reinstall django. But I still see the same error. 
Let them know what is causing me.

  
  File "C:\Python27\lib\functools.py", line 56, in 
'__lt__': [('__gt__', lambda self, other: other < self),
RuntimeError: maximum recursion depth exceeded while calling a Python object

C:\Django-1.6.5\django\bin\dj_board>python manage.py runserver

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


Re: Re: Django python fuction

2014-06-10 Thread hito koto
Hi,  Qiancong :

I was looking for exactly this、
Thank you ver much!


2014年6月10日火曜日 23時35分52秒 UTC+9 Qiancong:
>
>  
> Hi, hito koto:
> I think you want to deep copy the list. The following code maybe  helpful:
>  def dcopy(obj):
> if not isinstance(obj, list):
> return obj
> return [dcopy(x) for x in obj]
>  
> But this function only deep copy for list.  You can change code as what I 
> did for dic, set, tuple , etc ..
> --
>  moqia...@gmail.com 
>  
>  *From:* François Schiettecatte 
> *Date:* 2014-06-10 22:07
> *To:* django-users 
> *Subject:* Re: Django python fuction
>  You need to use .append() to add elements to a list, I suggest you take 
> a look at the python tutorial:
>  
> https://docs.python.org/2/tutorial/
>  
> Not quite sure what you are doing with i or elem either.
>  
> François
>  
> On Jun 10, 2014, at 10:01 AM, hito koto > 
> wrote:
>  
> > So, I also have errors:
> > 
> > 
> > >>> def foo(x):
> > ... myList = []
> > ... if isinstance(x, list):
> > ... for i in x:
> > ... elem = i
> > ... return myList + foo(elem)
> > ... else:
> > ... return 1
> > ...
> > >>>
> > >>> foo(a)
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "", line 6, in foo
> >   File "", line 6, in foo
> > TypeError: can only concatenate list (not "int") to list
> > 
> > 
> > 
> > 
> > 
> > 2014年6月10日火曜日 22時53分28秒 UTC+9 François Schiettecatte:
> > You are redefining 'list' on  line 2, rename list to myList as follows: 
> > 
> > def foo(x): 
> > myList = [] 
> > if isinstance(x, list): 
> > for i in x: 
> > elem = i 
> > return myList + foo(i) 
> > else: 
> > return 1 
> > 
> > And take this to a python list, this is for django. 
> > 
> > Cheers 
> > 
> > François 
> > 
> > 
> > On Jun 10, 2014, at 9:43 AM, hito koto  wrote: 
> > 
> > > hi, 
> > > 
> > > I have this erroes: 
> > > 
> > > >>> def foo(x): 
> > > ... list = [] 
> > > ... if isinstance(x, list): 
> > > ... for i in x: 
> > > ... elem = i 
> > > ... return list + foo(i) 
> > > ... else: 
> > > ... return 1 
> > > ... 
> > > >>> foo(a) 
> > > Traceback (most recent call last): 
> > >   File "", line 1, in  
> > >   File "", line 3, in foo 
> > > TypeError: isinstance() arg 2 must be a class, type, or tuple of 
> classes and types 
> > > 
> > > 
> > > 
> > > 2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell: 
> > > In general, I recommend adding the line "import pdb;pdb.set_trace()" 
> > > to the top of your function and walking through it to see why it 
> doesn't work. 
> > > 
> > > def foo(x): 
> > > import pdb;pdb.set_trace() 
> > > 
> > > list = [] 
> > > if isinstance(x, list): 
> > > for i in x: 
> > > elem = i 
> > > return list + foo(i) 
> > > else: 
> > > return 1 
> > > 
> > > See https://docs.python.org/2/library/pdb.html on how pdb works. 
> > > There are faster ways to debug, but when starting out, pdb lets you 
> see what is happening as you run the function. 
> > > 
> > > 
> > > Some questions I have about this function: 
> > > - What is the purpose of the "elem" function? It is never accessed. 
> > > - What is the purpose of returning 1 if the argument is not a list? 
> > > - Why is it named "foo" rather than something that tells me what the 
> purpose of the function is? 
> > > 
> > > 
> > > On Tue, Jun 10, 2014 at 8:16 AM, hito koto  
> wrote: 
> > > Hello, 
> > > 
> > > I don't know how can i do to change to write python function 
> > > I want to following code change to write python function or change to 
> write  recursive definition 
> > > >>> y = [10, 12, [13, [14, 9], 16], 7] 
> > > >>> z = copy.deepcopy(y) 
> > > >>> y 
> > > [10, 12, [13, [14, 9], 16], 7] 
> > > >>> z 
> > > [10, 12, [13, [14, 9], 16], 7] 
> > > >>> z[2][1][1] 
> > > 9 
> > > >>> z[2][1][1] = 88 
> > > >>> z 
> > > [10, 12, [13, [14, 88], 16], 7] 
> > > [10, 12, [13, [14, 9], 16], 7] 
> > > >>> 
> > > 
> > > this is my use function but not work: 
> > > 
> > > def foo(x): 
> > > list = [] 
> > > if isinstance(x, list): 
> > > for i in x: 
> > > elem = i 
> > > return list + foo(i) 
> > > else: 
> > > return 1 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > -- 
> > > 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. 
> > > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/cf982ef6-1398-4292-9001-eab418f2035a

error

2014-06-10 Thread kim jinhoo
I installed both python and django. 
After I create a project, I try to run a server error occurred. 
Re-install django hayeotneunde still see the same error occurs. 
Let them know what is causing me.

  File "C:\Python27\lib\functools.py", line 56, in 
'__lt__': [('__gt__', lambda self, other: other < self),
RuntimeError: maximum recursion depth exceeded while calling a Python object

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


Re: Why doesn't saving a related model update the _id field?

2014-06-10 Thread Tom Evans
On Tue, Jun 10, 2014 at 12:25 PM, Malcolm Box  wrote:
> On Monday, 9 June 2014 03:08:21 UTC+1, Russell Keith-Magee wrote:
>>
>>
>> On Sun, Jun 8, 2014 at 10:34 PM, Malcolm Box  wrote:
>>>
>>> I'm confused by Django's behaviour when saving related models. Take for
>>> example:
>>> 
>>> I kind of understand this, but it's not obvious to me why Django doesn't
>>> at least try to save the related object first
>>
>>
>> Ok - so how does Django decide that the related object needs to be saved?
>>
>> If it saves all related objects, then saving one object could result in a
>> save call being invoked on every object in the database (since y points to
>> x, which points to a, which points to b,…). I hope we can agree that a
>> cascading save like this would be a bad idea.
>>
>> If it's not *every* related object, then we need to make a decision -
>> which ones get saved? Ok - so lets say we just save the newly created
>> objects (i.e., objects with no primary keys.
>>
>> That means that the following would work:
>>
>> x = X(value=37)
>> y = Y(x=x)
>> y.save()
>>
>> and on retrieval, y.x.value == 37. Sure - that makes sense. But what
>> about:
>>
>> x = X(value=37)
>> x.save()
>> x.value = 42
>> y = Y(x=x)
>> y.save()
>>
>> and on retrieval, y.x.value == 37. Huh? Why? Oh - it's because in *that*
>> case, x was already in existence, so it wasn't re-saved as a result of y
>> being created. So now we've got inconsistent behaviour, depending on when
>> save() has been called on an object.
>
>
> Sure, that would be the side effect of assigning a pre-existing object. The
> use case I'm thinking of is creating an entire tree of un-saved objects in
> memory, and then having save() on the root Do The Right Thing. If that was
> inconsistent with assigning pre-existing objects, I could live with it.

I almost replied to Russell's reply to make this point explicitly
clear - BDFL advice tends to be fully accurate.

It is an error to assign an unsaved object as a relation of another
object (the saved state of that object is not relevant) for the
reasons that Russell explained. I don't know why it does not raise a
runtime error at this point, it would be possible.

Once you have assigned an unsaved object, behaviour is undefined - the
behaviour is only defined when saved objects are assigned as a
relation - and therefore anything can happen after that point. When
you have undefined behaviour, DTRT is not possible (if you can do the
right thing, you can define the behaviour).

That makes trees of unsaved related objects right out!

Cheers

Tom

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


Re: Re: Django python fuction

2014-06-10 Thread moqianc...@gmail.com
Hi, hito koto:
I think you want to deep copy the list. The following code maybe  helpful:
def dcopy(obj):
if not isinstance(obj, list):
return obj
return [dcopy(x) for x in obj]

But this function only deep copy for list.  You can change code as what I did 
for dic, set, tuple , etc ..



moqianc...@gmail.com

From: François Schiettecatte
Date: 2014-06-10 22:07
To: django-users
Subject: Re: Django python fuction
You need to use .append() to add elements to a list, I suggest you take a look 
at the python tutorial:

https://docs.python.org/2/tutorial/

Not quite sure what you are doing with i or elem either.

François

On Jun 10, 2014, at 10:01 AM, hito koto  wrote:

> So, I also have errors:
> 
> 
> >>> def foo(x):
> ... myList = []
> ... if isinstance(x, list):
> ... for i in x:
> ... elem = i
> ... return myList + foo(elem)
> ... else:
> ... return 1
> ...
> >>>
> >>> foo(a)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "", line 6, in foo
>   File "", line 6, in foo
> TypeError: can only concatenate list (not "int") to list
> 
> 
> 
> 
> 
> 2014年6月10日火曜日 22時53分28秒 UTC+9 François Schiettecatte:
> You are redefining 'list' on  line 2, rename list to myList as follows: 
> 
> def foo(x): 
> myList = [] 
> if isinstance(x, list): 
> for i in x: 
> elem = i 
> return myList + foo(i) 
> else: 
> return 1 
> 
> And take this to a python list, this is for django. 
> 
> Cheers 
> 
> François 
> 
> 
> On Jun 10, 2014, at 9:43 AM, hito koto  wrote: 
> 
> > hi, 
> > 
> > I have this erroes: 
> > 
> > >>> def foo(x): 
> > ... list = [] 
> > ... if isinstance(x, list): 
> > ... for i in x: 
> > ... elem = i 
> > ... return list + foo(i) 
> > ... else: 
> > ... return 1 
> > ... 
> > >>> foo(a) 
> > Traceback (most recent call last): 
> >   File "", line 1, in  
> >   File "", line 3, in foo 
> > TypeError: isinstance() arg 2 must be a class, type, or tuple of classes 
> > and types 
> > 
> > 
> > 
> > 2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell: 
> > In general, I recommend adding the line "import pdb;pdb.set_trace()" 
> > to the top of your function and walking through it to see why it doesn't 
> > work. 
> > 
> > def foo(x): 
> > import pdb;pdb.set_trace() 
> > 
> > list = [] 
> > if isinstance(x, list): 
> > for i in x: 
> > elem = i 
> > return list + foo(i) 
> > else: 
> > return 1 
> > 
> > See https://docs.python.org/2/library/pdb.html on how pdb works. 
> > There are faster ways to debug, but when starting out, pdb lets you see 
> > what is happening as you run the function. 
> > 
> > 
> > Some questions I have about this function: 
> > - What is the purpose of the "elem" function? It is never accessed. 
> > - What is the purpose of returning 1 if the argument is not a list? 
> > - Why is it named "foo" rather than something that tells me what the 
> > purpose of the function is? 
> > 
> > 
> > On Tue, Jun 10, 2014 at 8:16 AM, hito koto  wrote: 
> > Hello, 
> > 
> > I don't know how can i do to change to write python function 
> > I want to following code change to write python function or change to write 
> >  recursive definition 
> > >>> y = [10, 12, [13, [14, 9], 16], 7] 
> > >>> z = copy.deepcopy(y) 
> > >>> y 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> z 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> z[2][1][1] 
> > 9 
> > >>> z[2][1][1] = 88 
> > >>> z 
> > [10, 12, [13, [14, 88], 16], 7] 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> 
> > 
> > this is my use function but not work: 
> > 
> > def foo(x): 
> > list = [] 
> > if isinstance(x, list): 
> > for i in x: 
> > elem = i 
> > return list + foo(i) 
> > else: 
> > return 1 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 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. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/django-users/cf982ef6-1398-4292-9001-eab418f2035a%40googlegroups.com.
> >  
> > 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...@googlegroups.com. 
> > To post to this group, send email to django...@googlegroups.com. 
> > Visit this group at http://groups.google.com/group/djang

Re: Django python fuction

2014-06-10 Thread François Schiettecatte
You need to use .append() to add elements to a list, I suggest you take a look 
at the python tutorial:

https://docs.python.org/2/tutorial/

Not quite sure what you are doing with i or elem either.

François

On Jun 10, 2014, at 10:01 AM, hito koto  wrote:

> So, I also have errors:
> 
> 
> >>> def foo(x):
> ... myList = []
> ... if isinstance(x, list):
> ... for i in x:
> ... elem = i
> ... return myList + foo(elem)
> ... else:
> ... return 1
> ...
> >>>
> >>> foo(a)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "", line 6, in foo
>   File "", line 6, in foo
> TypeError: can only concatenate list (not "int") to list
> 
> 
> 
> 
> 
> 2014年6月10日火曜日 22時53分28秒 UTC+9 François Schiettecatte:
> You are redefining 'list' on  line 2, rename list to myList as follows: 
> 
> def foo(x): 
> myList = [] 
> if isinstance(x, list): 
> for i in x: 
> elem = i 
> return myList + foo(i) 
> else: 
> return 1 
> 
> And take this to a python list, this is for django. 
> 
> Cheers 
> 
> François 
> 
> 
> On Jun 10, 2014, at 9:43 AM, hito koto  wrote: 
> 
> > hi, 
> > 
> > I have this erroes: 
> > 
> > >>> def foo(x): 
> > ... list = [] 
> > ... if isinstance(x, list): 
> > ... for i in x: 
> > ... elem = i 
> > ... return list + foo(i) 
> > ... else: 
> > ... return 1 
> > ... 
> > >>> foo(a) 
> > Traceback (most recent call last): 
> >   File "", line 1, in  
> >   File "", line 3, in foo 
> > TypeError: isinstance() arg 2 must be a class, type, or tuple of classes 
> > and types 
> > 
> > 
> > 
> > 2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell: 
> > In general, I recommend adding the line "import pdb;pdb.set_trace()" 
> > to the top of your function and walking through it to see why it doesn't 
> > work. 
> > 
> > def foo(x): 
> > import pdb;pdb.set_trace() 
> > 
> > list = [] 
> > if isinstance(x, list): 
> > for i in x: 
> > elem = i 
> > return list + foo(i) 
> > else: 
> > return 1 
> > 
> > See https://docs.python.org/2/library/pdb.html on how pdb works. 
> > There are faster ways to debug, but when starting out, pdb lets you see 
> > what is happening as you run the function. 
> > 
> > 
> > Some questions I have about this function: 
> > - What is the purpose of the "elem" function? It is never accessed. 
> > - What is the purpose of returning 1 if the argument is not a list? 
> > - Why is it named "foo" rather than something that tells me what the 
> > purpose of the function is? 
> > 
> > 
> > On Tue, Jun 10, 2014 at 8:16 AM, hito koto  wrote: 
> > Hello, 
> > 
> > I don't know how can i do to change to write python function 
> > I want to following code change to write python function or change to write 
> >  recursive definition 
> > >>> y = [10, 12, [13, [14, 9], 16], 7] 
> > >>> z = copy.deepcopy(y) 
> > >>> y 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> z 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> z[2][1][1] 
> > 9 
> > >>> z[2][1][1] = 88 
> > >>> z 
> > [10, 12, [13, [14, 88], 16], 7] 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> 
> > 
> > this is my use function but not work: 
> > 
> > def foo(x): 
> > list = [] 
> > if isinstance(x, list): 
> > for i in x: 
> > elem = i 
> > return list + foo(i) 
> > else: 
> > return 1 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 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. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/django-users/cf982ef6-1398-4292-9001-eab418f2035a%40googlegroups.com.
> >  
> > 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...@googlegroups.com. 
> > To post to this group, send email to django...@googlegroups.com. 
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/django-users/2347967a-55c4-400b-9bf3-7aacc4f27311%40googlegroups.com.
> >  
> > 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 

Re: Django python fuction

2014-06-10 Thread hito koto
So, I also have errors:


>>> def foo(x):
... myList = []
... if isinstance(x, list):
... for i in x:
... elem = i
... return myList + foo(elem)
... else:
... return 1
...
>>>
>>> foo(a)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 6, in foo
  File "", line 6, in foo
TypeError: can only concatenate list (not "int") to list





2014年6月10日火曜日 22時53分28秒 UTC+9 François Schiettecatte:
>
> You are redefining 'list' on  line 2, rename list to myList as follows: 
>
> def foo(x): 
> myList = [] 
> if isinstance(x, list): 
> for i in x: 
> elem = i 
> return myList + foo(i) 
> else: 
> return 1 
>
> And take this to a python list, this is for django. 
>
> Cheers 
>
> François 
>
>
> On Jun 10, 2014, at 9:43 AM, hito koto > 
> wrote: 
>
> > hi, 
> > 
> > I have this erroes: 
> > 
> > >>> def foo(x): 
> > ... list = [] 
> > ... if isinstance(x, list): 
> > ... for i in x: 
> > ... elem = i 
> > ... return list + foo(i) 
> > ... else: 
> > ... return 1 
> > ... 
> > >>> foo(a) 
> > Traceback (most recent call last): 
> >   File "", line 1, in  
> >   File "", line 3, in foo 
> > TypeError: isinstance() arg 2 must be a class, type, or tuple of classes 
> and types 
> > 
> > 
> > 
> > 2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell: 
> > In general, I recommend adding the line "import pdb;pdb.set_trace()" 
> > to the top of your function and walking through it to see why it doesn't 
> work. 
> > 
> > def foo(x): 
> > import pdb;pdb.set_trace() 
> > 
> > list = [] 
> > if isinstance(x, list): 
> > for i in x: 
> > elem = i 
> > return list + foo(i) 
> > else: 
> > return 1 
> > 
> > See https://docs.python.org/2/library/pdb.html on how pdb works. 
> > There are faster ways to debug, but when starting out, pdb lets you see 
> what is happening as you run the function. 
> > 
> > 
> > Some questions I have about this function: 
> > - What is the purpose of the "elem" function? It is never accessed. 
> > - What is the purpose of returning 1 if the argument is not a list? 
> > - Why is it named "foo" rather than something that tells me what the 
> purpose of the function is? 
> > 
> > 
> > On Tue, Jun 10, 2014 at 8:16 AM, hito koto  wrote: 
> > Hello, 
> > 
> > I don't know how can i do to change to write python function 
> > I want to following code change to write python function or change to 
> write  recursive definition 
> > >>> y = [10, 12, [13, [14, 9], 16], 7] 
> > >>> z = copy.deepcopy(y) 
> > >>> y 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> z 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> z[2][1][1] 
> > 9 
> > >>> z[2][1][1] = 88 
> > >>> z 
> > [10, 12, [13, [14, 88], 16], 7] 
> > [10, 12, [13, [14, 9], 16], 7] 
> > >>> 
> > 
> > this is my use function but not work: 
> > 
> > def foo(x): 
> > list = [] 
> > if isinstance(x, list): 
> > for i in x: 
> > elem = i 
> > return list + foo(i) 
> > else: 
> > return 1 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 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. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/cf982ef6-1398-4292-9001-eab418f2035a%40googlegroups.com.
>  
>
> > 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...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/2347967a-55c4-400b-9bf3-7aacc4f27311%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>

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

Re: Django python fuction

2014-06-10 Thread François Schiettecatte
You are redefining 'list' on  line 2, rename list to myList as follows:

def foo(x):
myList = []
if isinstance(x, list):
for i in x:
elem = i
return myList + foo(i)
else:
return 1

And take this to a python list, this is for django.

Cheers

François


On Jun 10, 2014, at 9:43 AM, hito koto  wrote:

> hi,
> 
> I have this erroes:
> 
> >>> def foo(x):
> ... list = []
> ... if isinstance(x, list):
> ... for i in x:
> ... elem = i
> ... return list + foo(i)
> ... else:
> ... return 1
> ...
> >>> foo(a)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "", line 3, in foo
> TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and 
> types
> 
> 
> 
> 2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell:
> In general, I recommend adding the line "import pdb;pdb.set_trace()"
> to the top of your function and walking through it to see why it doesn't work.
> 
> def foo(x):
> import pdb;pdb.set_trace()
> 
> list = []
> if isinstance(x, list):
> for i in x:
> elem = i
> return list + foo(i)
> else:
> return 1
> 
> See https://docs.python.org/2/library/pdb.html on how pdb works.
> There are faster ways to debug, but when starting out, pdb lets you see what 
> is happening as you run the function.
> 
> 
> Some questions I have about this function:
> - What is the purpose of the "elem" function? It is never accessed.
> - What is the purpose of returning 1 if the argument is not a list?
> - Why is it named "foo" rather than something that tells me what the purpose 
> of the function is?
> 
> 
> On Tue, Jun 10, 2014 at 8:16 AM, hito koto  wrote:
> Hello,
> 
> I don't know how can i do to change to write python function
> I want to following code change to write python function or change to write  
> recursive definition
> >>> y = [10, 12, [13, [14, 9], 16], 7]
> >>> z = copy.deepcopy(y)
> >>> y
> [10, 12, [13, [14, 9], 16], 7]
> >>> z
> [10, 12, [13, [14, 9], 16], 7]
> >>> z[2][1][1]
> 9
> >>> z[2][1][1] = 88
> >>> z
> [10, 12, [13, [14, 88], 16], 7]
> [10, 12, [13, [14, 9], 16], 7]
> >>>
> 
> this is my use function but not work:
> 
> def foo(x):
> list = []
> if isinstance(x, list):
> for i in x:
> elem = i
> return list + foo(i)
> else:
> return 1
> 
> 
> 
> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/cf982ef6-1398-4292-9001-eab418f2035a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/2347967a-55c4-400b-9bf3-7aacc4f27311%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/97331564-3E2E-4425-9BEA-70C932CA1064%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django python fuction

2014-06-10 Thread hito koto
hi,

I have this erroes:

>>> def foo(x):
... list = []
... if isinstance(x, list):
... for i in x:
... elem = i
... return list + foo(i)
... else:
... return 1
...
>>> foo(a)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 3, in foo
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes 
and types



2014年6月10日火曜日 22時27分42秒 UTC+9 Andrew Farrell:
>
> In general, I recommend adding the line "import pdb;pdb.set_trace()"
> to the top of your function and walking through it to see why it doesn't 
> work.
>
> def foo(x):
> import pdb;pdb.set_trace()
>
> list = []
> if isinstance(x, list):
> for i in x:
> elem = i
> return list + foo(i)
> else:
> return 1
>
> See https://docs.python.org/2/library/pdb.html on how pdb works.
> There are faster ways to debug, but when starting out, pdb lets you see 
> what is happening as you run the function.
>
>
> Some questions I have about this function:
> - What is the purpose of the "elem" function? It is never accessed.
> - What is the purpose of returning 1 if the argument is not a list?
> - Why is it named "foo" rather than something that tells me what the 
> purpose of the function is?
>
>
> On Tue, Jun 10, 2014 at 8:16 AM, hito koto  > wrote:
>
>> Hello,
>>
>> I don't know how can i do to change to write python function
>> I want to following code change to write python function or change to 
>> write  recursive definition
>> >>> y = [10, 12, [13, [14, 9], 16], 7]
>> >>> z = copy.deepcopy(y)
>> >>> y
>> [10, 12, [13, [14, 9], 16], 7]
>> >>> z
>> [10, 12, [13, [14, 9], 16], 7]
>> >>> z[2][1][1]
>> 9
>> >>> z[2][1][1] = 88
>> >>> z
>> [10, 12, [13, [14, 88], 16], 7]
>> [10, 12, [13, [14, 9], 16], 7]
>> >>>
>>
>> this is my use function but not work:
>>
>> def foo(x):
>> list = []
>> if isinstance(x, list):
>> for i in x:
>> elem = i
>> return list + foo(i)
>> else:
>> return 1
>>
>>
>>
>>
>>  -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cf982ef6-1398-4292-9001-eab418f2035a%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2347967a-55c4-400b-9bf3-7aacc4f27311%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django python fuction

2014-06-10 Thread Andrew Farrell
In general, I recommend adding the line "import pdb;pdb.set_trace()"
to the top of your function and walking through it to see why it doesn't
work.

def foo(x):
import pdb;pdb.set_trace()

list = []
if isinstance(x, list):
for i in x:
elem = i
return list + foo(i)
else:
return 1

See https://docs.python.org/2/library/pdb.html on how pdb works.
There are faster ways to debug, but when starting out, pdb lets you see
what is happening as you run the function.


Some questions I have about this function:
- What is the purpose of the "elem" function? It is never accessed.
- What is the purpose of returning 1 if the argument is not a list?
- Why is it named "foo" rather than something that tells me what the
purpose of the function is?


On Tue, Jun 10, 2014 at 8:16 AM, hito koto  wrote:

> Hello,
>
> I don't know how can i do to change to write python function
> I want to following code change to write python function or change to
> write  recursive definition
> >>> y = [10, 12, [13, [14, 9], 16], 7]
> >>> z = copy.deepcopy(y)
> >>> y
> [10, 12, [13, [14, 9], 16], 7]
> >>> z
> [10, 12, [13, [14, 9], 16], 7]
> >>> z[2][1][1]
> 9
> >>> z[2][1][1] = 88
> >>> z
> [10, 12, [13, [14, 88], 16], 7]
> [10, 12, [13, [14, 9], 16], 7]
> >>>
>
> this is my use function but not work:
>
> def foo(x):
> list = []
> if isinstance(x, list):
> for i in x:
> elem = i
> return list + foo(i)
> else:
> return 1
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cf982ef6-1398-4292-9001-eab418f2035a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Anyone interested in reviewing code for a hobby project - BookMarker

2014-06-10 Thread trojactory
Aseem,

I had a quick look at your Django app and here are some of my observations:


   1. Most Django apps have a standard layout with the app in a directory 
   named after itself. See django-taggit 
    for instance.
   2. You have made some unconventional choices which needs to be explained 
   like using CharField instead of URLField, not using relative paths in 
   imports etc.
   3. An app must do one thing really well in order to be most reusable. I 
   believe autocomplete and opening a web browser don't belong to a 
   bookmarking app.
   4. There needs to be more unit tests and documentation to increase 
   confidence of other developers in using the app.

Sorry, if I have misunderstood the objectives of your project, but these 
things stood out to me.

Cheers,
Arun


On Saturday, 7 June 2014 15:37:52 UTC+5:30, Aseem Bansal wrote:
>
> I last asked for a review around two weeks back for my project. Is anyone 
> interested to give a second review for this project? 
>
> https://github.com/anshbansal/Bookmarker
>
> The last thread was here 
> https://groups.google.com/forum/#!topic/django-users/ob4fXz3GF9w in case 
> someone wants to see that I actually respond to people's comments instead 
> of just wasting their time.
>
> From last time I have done these changes -
> 1 Bookmark update as per categories  is now working
> 2 Used templates to make some things simpler to understand
> 3 Refactoring of view.py to get reusable components
> 4 Refactored jquery to make it cleaner so it is actually possible to read 
> it
> 5 Added CDN of librarires and added backup in case no internet is present
>
>
> My main concern currently is that this project is turning out to have a 
> lot more jQuery than Python/HTML.  Am I designing this incorrectly? I 
> understand that as my requirements are mostly asynchronous so there is a 
> need for javascript but redundancy like hard-coding URLs for autocomplete 
> in javascript is bothering me. Also am I over-engineering the Javascript?
>

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


Re: execute a code at a particular date and time (aperidic task) in django

2014-06-10 Thread Javier Guerra Giraldez
On Tue, Jun 10, 2014 at 6:43 AM, Rini Michael  wrote:
> Thanks for your reply,i have been looking into celery as well,but i found
> that celery is used for periodic task and i am looking to execute aperiodic
> task.please correct me if i am wrong


check the T.apply_async(eta=) option [1]


[1]: http://docs.celeryproject.org/en/latest/userguide/calling.html#id3

-- 
Javier

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


Re: How to have two separate models authentication system in the same django project?

2014-06-10 Thread graeme
Have you tried copying the content of contrib/auth and placing it in a 
directory in your app? It should work (perhaps with a bit of tweaking) BUT 
you will have to be careful where they both use the same data (for example 
the setting for the login url) and may have other problems. 

I cannot see what possible benefit you will got from this, and it is 
probably the wrong thing to do. You should almost certainly either:

1) user a custom user 
model: 
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#specifying-a-custom-user-model
 
or,
2) create a model within your app with a onetoone field pointing at the 
user for extra information

On Tuesday, June 10, 2014 5:49:04 PM UTC+5:30, Carlos Perche wrote:
>
> Hi, 
>
> Is there a way to have multiple implementations of django's 
> authentication/authorization system? In my practice blog-type site, 
> I've implemented django's auth/auth system as is. I'd like to use the 
> default implementation solely for administrators of the site. For 
> users of the site, on the other hand, I'd like to have a derivation of 
> django's auth/auth system - which will have the same functionality as 
> the default implementation, but have a separate set of user tables and 
> different fields. 
>
> I need to use the auth.user default just for admin user and I need to use 
> my custom.user for the others usuarios in the same project and database.
>
> It's possible?
>
> Anyone know how to do what I've described? Thanks. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc4e3c49-663f-42dc-bb36-07daf66014e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Modifying the request.POST data that is received from a form; form is not getting validated then

2014-06-10 Thread Daniel Roseman
On Tuesday, 10 June 2014 12:25:10 UTC+1, Anurag Baidyanath wrote:
>
> i am having difficulty in saving the form data to the database.
>

And we are having difficulty reading your code. If you can't be bothered to 
clean it up enough (eg removing all the commented-out lines) to make it 
easy to read before posting your question, you'll not find many people that 
can be bothered to answer it.

Also, you should read the very useful documentation on using a form in a 
view 
(https://docs.djangoproject.com/en/1.6/topics/forms/#using-a-form-in-a-view) 
and compare it with your view code, which might give you a hint as to where 
you are going wrong.
--
DR.

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


Django python function

2014-06-10 Thread hito koto
Hello,

I don't know how can i do to change to write python function
I want to following code change to write python function or change to 
write  recursive definition
>>> y = [10, 12, [13, [14, 9], 16], 7]
>>> z = copy.deepcopy(y)
>>> y
[10, 12, [13, [14, 9], 16], 7]
>>> z
[10, 12, [13, [14, 9], 16], 7]
>>> z[2][1][1]
9
>>> z[2][1][1] = 88
>>> z
[10, 12, [13, [14, 88], 16], 7]
[10, 12, [13, [14, 9], 16], 7]
>>>

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


How to have two separate models authentication system in the same django project?

2014-06-10 Thread Carlos Perche
Hi, 

Is there a way to have multiple implementations of django's 
authentication/authorization system? In my practice blog-type site, 
I've implemented django's auth/auth system as is. I'd like to use the 
default implementation solely for administrators of the site. For 
users of the site, on the other hand, I'd like to have a derivation of 
django's auth/auth system - which will have the same functionality as 
the default implementation, but have a separate set of user tables and 
different fields. 

I need to use the auth.user default just for admin user and I need to use 
my custom.user for the others usuarios in the same project and database.

It's possible?

Anyone know how to do what I've described? Thanks. 

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


Django python fuction

2014-06-10 Thread hito koto
Hello,

I don't know how can i do to change to write python function
I want to following code change to write python function or change to 
write  recursive definition
>>> y = [10, 12, [13, [14, 9], 16], 7]
>>> z = copy.deepcopy(y)
>>> y
[10, 12, [13, [14, 9], 16], 7]
>>> z
[10, 12, [13, [14, 9], 16], 7]
>>> z[2][1][1]
9
>>> z[2][1][1] = 88
>>> z
[10, 12, [13, [14, 88], 16], 7]
[10, 12, [13, [14, 9], 16], 7]
>>>

this is my use function but not work:

def foo(x):
list = []
if isinstance(x, list):
for i in x:
elem = i
return list + foo(i)
else:
return 1




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


Re: How to receive json data using HTTP POST request in Django 1.6?

2014-06-10 Thread Alok Singh Mahor
thank you Malcolm, I will try that too


On Tue, Jun 10, 2014 at 4:47 PM, Malcolm Box  wrote:

> Simplest answer is to use Django Rest Framework, which makes this
> extremely easy.
>
> Malcolm
>
>
> On Monday, 9 June 2014 11:20:05 UTC+1, Alok Singh Mahor wrote:
>>
>> Hi all,
>>
>> I am trying to receive JSON data using HTTP POST in django 1.6.
>> I tried using request.POST['data'], request.raw_post_data, request.body
>> but none is working for me.
>> I have posted question and code at http://stackoverflow.com/
>> questions/24068576/how-to-receive-json-data-using-http-
>> post-request-in-django-1-6
>>
>> please tell me how to achieve this in django 1.6
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/78563526-cf0a-4cfc-b8f4-e1551eb4fa51%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: execute a code at a particular date and time (aperidic task) in django

2014-06-10 Thread Rini Michael
Hi Malcolm
Thanks for your reply,i have been looking into celery as well,but i found 
that celery is used for periodic task and i am looking to execute aperiodic 
task.please correct me if i am wrong

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1027f151-b6c7-46a7-a95a-4e6fceca72e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Modifying the request.POST data that is received from a form; form is not getting validated then

2014-06-10 Thread Anurag Baidyanath
i am having difficulty in saving the form data to the database.

After the user submits the form; fields such as ticket_id , created_date, 
etc have to be added to the POST request which is generated as a result of 
the form submission. I have copied the POST data to another dictionary and 
appended the other fields. The form isn't getting validated when the 
is_valid() fn is called.

i am attaching the submit function in the views.py file and the forms.py 
file


def submit(request):
context=RequestContext(request)
if(request.method=="POST"):
print request.POST
print "\n"
data = request.POST.copy()
#data=request.POST

print "\n"
print request.user.email
data['created_date_time']=datetime.datetime.now()
data['overdue_date_time']=datetime.datetime.now()
Date=datetime.datetime.now()
Enddate=Date+datetime.timedelta(days=1)
data['overdue_date_time']=Enddate
data['closed_date_time']=Enddate
data['status']=0 # 0 means that the ticket is still 
open and not yet answered
data['reopened_date_time']=Enddate
data['topic_priority']=2 # 2 is the default priority of 
medium
data['duration_for_reply']=24 #in hours
if request.user.is_authenticated():
print request.user
data['user_id']=request.user.email
#returns a user object if the user is logged in. 
@login_required is thus necessary
else:
return HttpResponse("you need to be a valid user to 
submit a ticket. click here to go to the login page")
#let the help topic remain the same
#category_selected=data['help_topic']

#data['help_topic']=Category.objects.get(category="android")#category_selected)#get
 
is used to get a single object
from django.db.models import Max

last_ticket=int(Ticket.objects.all().aggregate(Max('ticket_id'))['ticket_id__max'])
data['ticket_id']=last_ticket+1
#if 'submit' in data: del data['submit']
#if 'csrfmiddlewaretoken' in data: del 
data['csrfmiddlewaretoken']

#user_form=SubmitTicketForm(data)
print data
user_form=SubmitTicketForm(data)
#how to validate the form for yourself
if user_form.is_valid():
 print user_form.cleaned_data
  #   user_form=Ticket.objects.set(topic_id=data['user_id'])
 user_form.save()
 return HttpResponse("Saved successfully")
#else:
 # print data
  # return HttpResponse("Saved unsuccessfully")
   # print "the errors are"
# print user_form.errors
else:
 user_form=SubmitTicketForm()
 return render_to_response(
'submit.html',
{'user_form': user_form},
context)

from user_tickets.models import *
from django import forms
from django.contrib.auth.models import User
import datetime
from datetime import timedelta
from django.db.models import Max
class SubmitTicketForm(forms.ModelForm):
status=forms.IntegerField(widget=forms.HiddenInput(),initial=0)
topic_priority=forms.IntegerField(widget=forms.HiddenInput(),initial=2)

duration_for_reply=forms.IntegerField(widget=forms.HiddenInput(),initial=24)

ticket_id=forms.IntegerField(widget=forms.HiddenInput(),initial=786)#(int(Ticket.objects.all().aggregate(Max('ticket_id'))['ticket_id__max']))+1)

created_date_time=forms.DateTimeField(widget=forms.HiddenInput(),initial=datetime.datetime.now())

overdue_date_time=forms.DateTimeField(widget=forms.HiddenInput(),initial=datetime.datetime.now())

closed_date_time=forms.DateTimeField(widget=forms.HiddenInput(),initial=datetime.datetime.now())

reopened_date_time=forms.DateTimeField(widget=forms.HiddenInput(),initial=datetime.datetime.now())
class Meta:
model=Ticket

fields=('user_id','topic_id','message','ticket_id','status','topic_priority','duration_for_reply','created_date_time','overdue_date_time','closed_date_time','reopened_date_time')

#'created_date_time','overdue_date_time','closed_date_time','reopened_date_time',


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

Re: Why doesn't saving a related model update the _id field?

2014-06-10 Thread Malcolm Box
On Monday, 9 June 2014 03:08:21 UTC+1, Russell Keith-Magee wrote:

>
> On Sun, Jun 8, 2014 at 10:34 PM, Malcolm Box  > wrote:
>
>> I'm confused by Django's behaviour when saving related models. Take for 
>> example:
>> 
>> I kind of understand this, but it's not obvious to me why Django doesn't 
>> at least try to save the related object first
>>
>
> Ok - so how does Django decide that the related object needs to be saved? 
>
> If it saves all related objects, then saving one object could result in a 
> save call being invoked on every object in the database (since y points to 
> x, which points to a, which points to b,…). I hope we can agree that a 
> cascading save like this would be a bad idea.
>
> If it's not *every* related object, then we need to make a decision - 
> which ones get saved? Ok - so lets say we just save the newly created 
> objects (i.e., objects with no primary keys. 
>
> That means that the following would work:
>
> x = X(value=37)
> y = Y(x=x)
> y.save()
>
> and on retrieval, y.x.value == 37. Sure - that makes sense. But what about:
>
> x = X(value=37)
> x.save()
> x.value = 42
> y = Y(x=x)
> y.save()
>
> and on retrieval, y.x.value == 37. Huh? Why? Oh - it's because in *that* 
> case, x was already in existence, so it wasn't re-saved as a result of y 
> being created. So now we've got inconsistent behaviour, depending on when 
> save() has been called on an object.
>

Sure, that would be the side effect of assigning a pre-existing object. The 
use case I'm thinking of is creating an entire tree of un-saved objects in 
memory, and then having save() on the root Do The Right Thing. If that was 
inconsistent with assigning pre-existing objects, I could live with it.


> The only way I can see to rectify *this* problem would be to keep a track 
> of every value that has been modified, and save any "modified" objects. 
> This is in the realm of the possible -- and it has been proposed in the 
> past -- but it means carrying a lot of accounting baggage around on *every* 
> attribute change. 
>

Surely the extra baggage is a modified flag, set on each object when any 
attribute is changed? Then  save() can "simply" follow relationships and 
save any modified objects.

 
>
>> B) y.x.save(); y.save() also throws an integrity error because y.x_id is 
>> None. 
>>
>> However, y.x.id is not None, so I don't understand why it can't update 
>> y.x_id (and thus make the save succeed).
>>
>> C) y.x.save(); y.x = y.x; y.save() - succeeds, but I don't see why the 
>> y.x = y.x is needed.
>>
>> Is this a deliberate design decision, something I'm misunderstanding, or 
>> a bug/implementation artefact?
>>
>
> It's a deliberate design decision, for reasons that my example above 
> hopefully makes clear. The reason the re-assignment is needed in your 
> example is because y.x implies a query; if you directly save the original 
> object (i.e., x.save(), not y.x.save()), you should find the reassignment 
> isn't needed.
>

Ah, the issue I'm running into is that the point at which y.save() is 
called is separated from where y.x was assigned - so I no longer have a 
reference to the original object (except ... via y.x, so I guess I don't 
understand why that doesn't work the same as saving the original x...) 

Thanks for the explanation Russ, much appreciated.

Cheers,

Malcolm

>

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


Re: How to receive json data using HTTP POST request in Django 1.6?

2014-06-10 Thread Malcolm Box
Simplest answer is to use Django Rest Framework, which makes this extremely 
easy.

Malcolm

On Monday, 9 June 2014 11:20:05 UTC+1, Alok Singh Mahor wrote:
>
> Hi all,
>
> I am trying to receive JSON data using HTTP POST in django 1.6.
> I tried using request.POST['data'], request.raw_post_data, request.body 
> but none is working for me. 
> I have posted question and code at 
> http://stackoverflow.com/questions/24068576/how-to-receive-json-data-using-http-post-request-in-django-1-6
>
> please tell me how to achieve this in django 1.6
>

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


Re: execute a code at a particular date and time (aperidic task) in django

2014-06-10 Thread Malcolm Box
The canonical answer to this is to use Celery, which provides a task queue 
for any background/scheduled tasks you want to use.

It's pretty easy to get set up, and works well.

Malcolm

On Tuesday, 10 June 2014 06:37:46 UTC+1, Rini Michael wrote:
>
> Hi,
> i am looking for a way where i can execute a task at a particular date and 
> time, i tried apscheduler for this purpose but i am finding some difficulty 
> while integerating with django. can anyone help me with this
> the flow is
> user will specify a particular date and time through GUI --> submit --> 
> the task will be executed at the particular date and time the user mentioned
> i have tried the following in django (Apscheduler approach)
>
> import time
> from datetime import datetime
> from apscheduler.scheduler import Scheduler
> import os
> def func1(self,exec_date):
> from_time = datetime.datetime.strptime("2014-05-29 13:56:59",'%Y-%m-%d 
> %H:%M:%S')
> self.exec_date = datetime.datetime ( 
> from_time.year,from_time.month,from_time.day,from_time.hour,from_time.minute)
> return exec_date
> sched = Scheduler()
> sched.start()
> def my_job(test,exec_date):
> print test
> os.system("python C://Python27/Lib/idlelib/tim.py")
> job = sched.add_date_job(my_job,exec_date, ['hello'])
>
>
> the issue i am facing is the input that the user gives (date n time) is in 
> forms.py ,i have written the code for apscheduler in views.py and i call 
> the function through urls.py but the code doesn't really seem to work,can 
> anyone suggest me how apscheduler works with django or guide me with some 
> links which give information about that
>
> Thanks in advance
>
> Thanks and regards 
> Rini
>

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


Re: UserProfile.user" must be a "User" instance. django-registration

2014-06-10 Thread Jimish Parekh
Hey Nikhil,
I might be wrong but please check your UserProfile model

   - In your __Unicode(something) function check for syntax error. i think 
   it should be __Unicode__
   - And why are you trying to return full name of User. I think you should 
   return self.user there so that when you are requesting back you can get 
   User Object back

If these answers are wrong and feels like bullshit then pls ignore... I am 
also trying to learn:)
Thanks,

On Monday, July 2, 2012 6:47:03 PM UTC+5:30, Nikhil Verma wrote:
>
> HI All
>
> I am applying an django-registration in my app. So i create a UserProfile 
> Model and  a ModelForm after clicking on the email link
> the user is redirected to the ModelForm page of UserProfile. I am filling 
> the details and trying to save it, however i am getting the above error.
>
>
> Traceback:-
>
>
> Exception Type: ValueError at /myprofile/completingprofile/
> Exception Value: Cannot assign " object at 0x3487c10>": "UserProfile.user" must be a "User" instance.
>
>
> model
>
> class UserProfile(models.Model):
> user = models.ForeignKey(User, blank=True, null=True, unique=True)
> first_name = models.CharField(max_length=30)
> last_name = models.CharField(max_length=30, blank=True)
> gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
> mobile = models.CharField(max_length=15, blank=True)
> primary_email = models.EmailField(max_length=60, blank=True)
>
> # For professional Account
> institution_name = 
> models.CharField(max_length=100,blank=True,null=True)
>
> street = models.CharField(max_length=75)
> state = models.CharField(max_length=30)
> zip_code = models.IntegerField(max_length=7, blank=True, null=True)
> country = models.CharField(max_length=30, blank=True)
> 
>
> def __unicode(self):
> name = self.first_name + self.last_name
> return name
>
>
> form.py
>
> class UserProfileForm(ModelForm):
> class Meta:
> model = UserProfile
> exclude = ('user',)
> 
> def __init__(self, *args, **kwargs):
> super(UserProfileForm, self).__init__(*args, **kwargs)
>
>
>
> views.py 
>
> def completingprofile(request):
> """
> Creating Profile
> """
> print request
> if request.method == "POST":
> 
> form = UserProfileForm(request.POST)
> if form.is_valid():
> userprofile_obj = UserProfile(
> first_name = form.cleaned_data['first_name'],
> last_name = 
> form.cleaned_data['last_name'],
> gender = form.cleaned_data['gender'],
> mobile = form.cleaned_data['mobile'],
> institution_name = form.cleaned_data['institution_name'],
> street = form.cleaned_data['street'],
> zip_code = form.cleaned_data['zip_code'],
> state = form.cleaned_data['state'],
> country = form.cleaned_data['country'],
> user = request.user,# here i am trying to add user from 
> request who is coming from RegistrationForm from django -registration
># I am getting the error in this above line  
> )
> userprofile_obj.save()
> logger.info("Save profile for user: %s" % request.user)
> 
> return HttpResponseRedirect('/thanks/')
> else:
> form = UserProfileForm()
> return render_to_response("myprofile/profile_page.html", 
> {"form": form },
> context_instance=RequestContext(request)
> )
>  
> How can i save the user field ?
>
>
> Thanks for help in advance
>
> -- 
> Regards
> Nikhil Verma
> +91-958-273-3156
>
>

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


Re: Can't get MySQLdb

2014-06-10 Thread Alan Sawyer

>
> I believe I got it to work. I had to change the Engine per this article.
>

http://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html
 


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


Re: Question about moving code to product from local or development server.

2014-06-10 Thread Tomas Ehrlich
Hi there,
since all have already mentioned Fabric, take a look at Ansible which
is a bit more sophisticated tool, but can be used efficiently even for
small setups.

Depends on your requirements, you can create simple "deployment"
playbook, which just takes your code, push it to the server, update
database, static files (and/or locales) and restarts wsgi. However,
if you need to setup whole server, Ansible is perfect tool for that.
But that would be beyond the scope of this question.


Cheers,
  Tom

Dne Sat, 7 Jun 2014 16:50:58 -0400
Chen Xu  napsal(a):

> I am building a django website, and wondering what is an easy way to move
> all of my code to production, is there a tool for doing that, or maybe
> write my own script?
> 
> 
> Thanks
> 


signature.asc
Description: PGP signature


Re: Question about moving code to product from local or development server.

2014-06-10 Thread Phang Mulianto
Hi there,

The easy way just copy /transfer your code to your production server
manually.

To more automate the process, you can use some script .

To more advanced and not repeating your self, you can use fabric and create
a deployment script for your project.
After finish this effort , your fabric will be reusable in other project.
You would like to automate and simplfy the workflow to upload your
production and can be repeated easily.

Fabric is more python for deployment.

Regards,

Mulianto
http://muliantophang.blogspot.com


On Tue, Jun 10, 2014 at 3:11 PM, Johannes Schneider <
johannes.schnei...@galileo-press.de> wrote:

> you can use 'Fabric' to deploy your code. But In this case you still have
> to write some parts on your own.
>
> https://pypi.python.org/pypi/Fabric/
>
> bg,
> Johannes
>
>
>
> On 07.06.2014 22:50, Chen Xu wrote:
>
>> I am building a django website, and wondering what is an easy way to
>> move all of my code to production, is there a tool for doing that, or
>> maybe write my own script?
>>
>>
>> Thanks
>>
>> --
>> ⚡ Chen Xu ⚡
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to django-users+unsubscr...@googlegroups.com
>> .
>>
>> To post to this group, send email to django-users@googlegroups.com
>> .
>>
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CACac-
>> qY8nbj6uiPyvkorvARAqZ%2Bej7rAty_CtdkHnz5bXBKBKQ%40mail.gmail.com
>> > qY8nbj6uiPyvkorvARAqZ%2Bej7rAty_CtdkHnz5bXBKBKQ%
>> 40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Johannes Schneider
> Webentwicklung
> johannes.schnei...@galileo-press.de
> Tel.: +49.228.42150.xxx
>
> Galileo Press GmbH
> Rheinwerkallee 4 - 53227 Bonn - Germany
> Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
> http://www.galileo-press.de/
>
> Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
> HRB 8363 Amtsgericht Bonn
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/5396AF94.5040509%40galileo-press.de.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BSr5mS6WSRMsxLdqk6aOAXUpLMPurco-pDE%2BRA3Ev5CQ7P%2BKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login/Session Not Sticking

2014-06-10 Thread Erik Cederstrand
Den 10/06/2014 kl. 09.08 skrev Juergen Schackmann 
:

> I do have the same issue with django admin, and definitely no custom js 
> there. any other ideas???

You need to reduce the problem. Scale down to only one app server and re-run 
your tests. If the problem disappears, it's a concurrency issue (e.g. not using 
transactions, race conditions in your session code etc.). If not, something is 
invalidating your sessions.

Log any db activity related to the session table to rule out actual changes to 
your session data. Then, review any code related to session handling and 
cookies, including session and cookie timeouts. Also, re-run your tests in a 
browser where javascript is turned off to rule out client-side session mangling.

Erik

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


Re: Question about moving code to product from local or development server.

2014-06-10 Thread Johannes Schneider
you can use 'Fabric' to deploy your code. But In this case you still 
have to write some parts on your own.


https://pypi.python.org/pypi/Fabric/

bg,
Johannes


On 07.06.2014 22:50, Chen Xu wrote:

I am building a django website, and wondering what is an easy way to
move all of my code to production, is there a tool for doing that, or
maybe write my own script?


Thanks

--
⚡ Chen Xu ⚡

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



--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

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


Re: Django Login/Session Not Sticking

2014-06-10 Thread Juergen Schackmann
I do have the same issue with django admin, and definitely no custom js 
there. any other ideas???

Am Freitag, 6. Juni 2014 13:50:31 UTC+2 schrieb Juergen Schackmann:
>
> none of my js is fiddling with sessions/cookies. but there are numerous 
> third party js packages included (for ads etc). so any of those could do 
> strange things, this would also explain why it broke all of a sudden. could 
> you provide more details on the underlying issue that you had. this would 
> help me to search for the issue.
>
> Am Freitag, 6. Juni 2014 06:32:30 UTC+2 schrieb somecallitblues:
>>
>> I know this may sound silly but is there some kind of JavaScript code 
>> that may be messing things up? Had a similar issue before and it was 
>> related to JavaScript stupidity. 
>> On 05/06/2014 10:39 pm, "Juergen Schackmann"  
>> wrote:
>>
>>> - all app servers are running the same code with same settings.
>>> - DNS load balancing was never used
>>> - just did a htop, no unexpected or old processes
>>>
>>> Am Donnerstag, 5. Juni 2014 11:37:30 UTC+2 schrieb Erik Cederstrand:

 Den 04/06/2014 kl. 13.55 skrev Juergen Schackmann <
 juergen.s...@gmail.com>: 

 > The production site is served via a load balancer and 8 application 
 servers. Even stranger: if I test the same code (with the same settings) 
 on 
 a test server, that is not load balanced and basically has not traffic, 
 everything is working fine. 

 Are you sure all app servers are running the same code? Same 
 settings.py? DNS load balancing you forgot about? Maybe you have some 
 lingering app server processes that were never shut down? Check the start 
 date of all WSGI processes to be sure. 

 Erik 


 PS: You may have sweaty palms, but please don't triple post the same 
 question to the list.
>>>
>>>  -- 
>>> 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.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/593d1369-a6a2-4457-b911-952bb0576877%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

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


execute a code at a particular date and time (aperidic task) in django

2014-06-10 Thread Rini Michael
Hi,
i am looking for a way where i can execute a task at a particular date and 
time, i tried apscheduler for this purpose but i am finding some difficulty 
while integerating with django. can anyone help me with this
the flow is
user will specify a particular date and time through GUI --> submit --> the 
task will be executed at the particular date and time the user mentioned
i have tried the following in django (Apscheduler approach)

import time
from datetime import datetime
from apscheduler.scheduler import Scheduler
import os
def func1(self,exec_date):
from_time = datetime.datetime.strptime("2014-05-29 13:56:59",'%Y-%m-%d 
%H:%M:%S')
self.exec_date = datetime.datetime ( 
from_time.year,from_time.month,from_time.day,from_time.hour,from_time.minute)
return exec_date
sched = Scheduler()
sched.start()
def my_job(test,exec_date):
print test
os.system("python C://Python27/Lib/idlelib/tim.py")
job = sched.add_date_job(my_job,exec_date, ['hello'])


the issue i am facing is the input that the user gives (date n time) is in 
forms.py ,i have written the code for apscheduler in views.py and i call 
the function through urls.py but the code doesn't really seem to work,can 
anyone suggest me how apscheduler works with django or guide me with some 
links which give information about that

Thanks in advance

Thanks and regards 
Rini

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