Re: Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-06-30 Thread s
Great
On Jun 30, 2012 6:10 PM, "Cal Leeming [Simplicity Media Ltd]" <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Hi all,
>
> As some of you know, I did a live webcast last year (July 2011) on our LLG
> project, which explained how we overcome some of the problems associated
> with large data processing.
>
> After reviewing the video, I found that the sound quality was very
> poor, the slides weren't very well structured, and some of the information
> is now out of date (at the time it was 40mil rows, now we're dealing with
> 700+mil rows).
>
> Therefore, I'm considering doing another live webcast (except this time
> it'll be recorded+posted the next day, the stream will be available in
> 1080p, it'll be far better structured, and will only last 50 minutes).
>
> The topics I'd like to cover are:
>
> * Bulk data processing where bulk_insert() is still not viable (we went
> from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still
> using the ORM - no raw sql here!!)
> * Applying faux child/parent relationship when standard ORM is too
> expensive (allows for ORM approach without the cost)
> * Applying faux ORM read-only structure to legacy applications (allows ORM
> usage on schemas that weren't properly designed, and cannot be changed -
> for example, vendor software with no source code).
> * New Relic is beautiful, but expensive. Hear more about our plans to make
> an open source version.
> * Appropriate use cases for IAAS vs colo with SSDs.
> * Percona is amazing, some of the tips/tricks we've learned over.
>
> If you'd like to see this happen, please leave a reply in the thread - if
> enough people want this, then we'll do public vote for the scheduled date.
>
> Cheers
>
> Cal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-06-30 Thread Mario Gudelj
+1

On 1 July 2012 10:40, Setiaman Lee  wrote:

> Hi Cal,
> Interesting topic. Count me in.
> On Jun 30, 2012 11:10 PM, "Cal Leeming [Simplicity Media Ltd]" <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Hi all,
>>
>> As some of you know, I did a live webcast last year (July 2011) on our
>> LLG project, which explained how we overcome some of the problems
>> associated with large data processing.
>>
>> After reviewing the video, I found that the sound quality was very
>> poor, the slides weren't very well structured, and some of the information
>> is now out of date (at the time it was 40mil rows, now we're dealing with
>> 700+mil rows).
>>
>> Therefore, I'm considering doing another live webcast (except this time
>> it'll be recorded+posted the next day, the stream will be available in
>> 1080p, it'll be far better structured, and will only last 50 minutes).
>>
>> The topics I'd like to cover are:
>>
>> * Bulk data processing where bulk_insert() is still not viable (we went
>> from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still
>> using the ORM - no raw sql here!!)
>> * Applying faux child/parent relationship when standard ORM is too
>> expensive (allows for ORM approach without the cost)
>> * Applying faux ORM read-only structure to legacy applications (allows
>> ORM usage on schemas that weren't properly designed, and cannot be changed
>> - for example, vendor software with no source code).
>> * New Relic is beautiful, but expensive. Hear more about our plans to
>> make an open source version.
>> * Appropriate use cases for IAAS vs colo with SSDs.
>> * Percona is amazing, some of the tips/tricks we've learned over.
>>
>> If you'd like to see this happen, please leave a reply in the thread - if
>> enough people want this, then we'll do public vote for the scheduled date.
>>
>> Cheers
>>
>> Cal
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: advantages and disadvantages of Raw sql queries in django

2012-06-30 Thread Nick Apostolakis

On 01/07/2012 06:25 πμ, Javier Guerra Giraldez wrote:


in short: an application model is _not_ an OOP view of the database;
it's the implementation of the conceptual data objects as handled by
the application.

   


All right, I see the advantages. Nice technique.
Thanks a lot.

--
 --
   Nick Apostolakis
  e-mail: nicka...@oncrete.gr
 Web Site: http://nick.oncrete.gr
 --


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



Re: SimpleListFilter filter UserProfile

2012-06-30 Thread Sunny Nanda
In the filter, you are trying the filter User objects on timestamp field 
which does not exist.

In line 42 of admin.py, try filtering on "userprofile__timestamp__gte"

-Sandeep

On Thursday, June 28, 2012 1:20:03 PM UTC+5:30, yillkid wrote:
>
> Hi all !
>
> I want filter a field of UserProfile (field name: timestamp),
>
> models.py:   http://dpaste.com/764723/
>
> admin.py:   http://dpaste.com/764724/
>
> But when I press the filter, browser show:   http://dpaste.com/764725/
>
> --- --- --- --- --- --- --- --- --- ---
>
> According the error message, I can get class "UserProfile", 
> but if I want to  filter timestamp, how should I do ?
>
> thx :-)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/RqU1cpZr3CAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-06-30 Thread Sunny Nanda
Count me in please.



On Saturday, June 30, 2012 8:40:27 PM UTC+5:30, Cal Leeming [Simplicity 
Media Ltd] wrote:
>
> Hi all,
>
> As some of you know, I did a live webcast last year (July 2011) on our LLG 
> project, which explained how we overcome some of the problems associated 
> with large data processing.
>
> After reviewing the video, I found that the sound quality was very 
> poor, the slides weren't very well structured, and some of the information 
> is now out of date (at the time it was 40mil rows, now we're dealing with 
> 700+mil rows).
>
> Therefore, I'm considering doing another live webcast (except this time 
> it'll be recorded+posted the next day, the stream will be available in 
> 1080p, it'll be far better structured, and will only last 50 minutes).
>
> The topics I'd like to cover are:
>
> * Bulk data processing where bulk_insert() is still not viable (we went 
> from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still 
> using the ORM - no raw sql here!!)
> * Applying faux child/parent relationship when standard ORM is too 
> expensive (allows for ORM approach without the cost)
> * Applying faux ORM read-only structure to legacy applications (allows ORM 
> usage on schemas that weren't properly designed, and cannot be changed - 
> for example, vendor software with no source code).
> * New Relic is beautiful, but expensive. Hear more about our plans to make 
> an open source version.
> * Appropriate use cases for IAAS vs colo with SSDs.
> * Percona is amazing, some of the tips/tricks we've learned over.
>
> If you'd like to see this happen, please leave a reply in the thread - if 
> enough people want this, then we'll do public vote for the scheduled date.
>
> Cheers
>
> Cal
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Dp3MO3-Qh6UJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Management form in Model Formsets

2012-06-30 Thread Knight Samar
Hi,

I am using Django 1.2 and developing using Model formsets. Using 
JavaScript, I am allowing the user to dynamically "Add another" formset on 
the template, but I can't figure out what exactly I have to modify in the 
management forms, for all the formsets to be successfully saved.

The documentation points out to three properties in the management form - 
form-TOTAL_FORMS, form-INITIAL_FORMS and form-MAX_NUM_FORMS. But I don't 
understand, which properties I have to exactly modify and how, when a new 
formset is being added dynamically using JavaScript ?

Thanks :)

Regards,
Samar

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Ecs6EVDku_YJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: i want to display a student profile from the database and am unable to do that.plz help

2012-06-30 Thread manish girdhar
hii..thanks for your concern friendi did not able to get your
point..can you please tell this in little more briefactually i want
to enter the roll number from the user and then that number could filter
the data from the database and display the whole profile of the student..

On Sun, Jul 1, 2012 at 1:12 AM, Dennis Lee Bieber wrote:

> On Sat, 30 Jun 2012 11:54:35 -0700 (PDT), rick
>  declaimed the following in
> gmane.comp.python.django.user:
>
> >
> > this is my views.py.
> >
> > def studentid(request):
> > if request.method == 'POST':
> > form = Student_loginForm(request.POST)
> > if form.is_valid():
> > cd = form.cleaned_data
> > rollno = cd['rollno']
> > p = form.save()
> > rollno = request.POST.get('rollno')
> > rollno=int(rollno)
> > results = Add_record.objects.filter(Student_ID=rollno)
> > return HttpResponseRedirect(reverse('record_system.views.search',
> > args=(results)))
>
> Note: if args is supposed to be a tuple, you need to include a
> trailing ,
>
> args = (results, )
>
> Otherwise, each item (if there are more than one) in results is
> being treated as a separate positional argument.
>
> Other than that minor syntactic nit, one may need to see
> "Add_record"...
>
> Also, what is the expected behavior if .is_valid() comes back
> false?
>
> As coded, regardless of the .is_valid() return, you appear to fetch
> "rollno" from the request object (replacing any value saved from the
> clean data branch).
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: advantages and disadvantages of Raw sql queries in django

2012-06-30 Thread Javier Guerra Giraldez
On Sat, Jun 30, 2012 at 5:26 PM, Nick Apostolakis  wrote:
> Interesting idea, I haven't used that yet, could you give an example of
> that?
> Would you use a method calling the ORM that would include something like
> self.objects.select_related().bla bla?

for example: when modelling the requested/accepted/rejected of a
'friendship' relation between 'person' records, you have to design the
exact DB representation, but later on you might want to modify that
representation.  Ideally, such changes shouldn't impact _all_ your
code.

specifically: my Person model has a ManyToManyField to 'self' called
'friends', where the intermediate table ('Friendship' model) has a
'state' field.  These are implementation details, so i added some
methods to get the list of friends, list of unanswered requests sent,
received, and rejections sent and received:

  def get_friends(self):
return self.friends.filter(as_B__state=Friendship.ACCEPTED)

  def get_sent_requests_unanswered(self):
return self.friends.filter(as_B__state=Friendship.REQUESTED)

  def get_rcvd_requests_unanswered(self):
return self.receivedRequests.filter(as_A__state=Friendship.REQUESTED)

  def get_sent_requests_rejected(self):
return self.friends.filter(as_B__state=Friendship.REJECTED)

  def get_rcvd_requests_rejected(self):
return self.receivedRequests.filter(as_A__state=Friendship.REJECTED)

as you can see, these queries are readable enough to be used anywhere;
but if later on i want to replace the single 'friends' link field with
several independent relationships, i don't have to search through all
my code, just the models.py

similarly, there are methods to send a request and to accept or reject
it.  Again, the code is simple enough that it could be used directly;
but encapsulating it with the Person model makes it easy to maintain
consistency:

for example, the friendship request method:

  def send_friend_request(self, target):
try:
  f = Friendship.objects.get(personA=self, personB=target)
  return f in (Friendship.REQUESTED, Friendship.ACCEPTED)
except Friendship.DoesNotExist:
  Friendship.objects.create(
personA=self, personB=target,
state=Friendship.REQUESTED)
  return True

doesn't allow a second request if one is already pending or rejected.
if later on this policy is changed (maybe a rejector could change
mind, or an old request could expire, etc), i know where to do the
changes.

also, this lets the views be _really_ thin. since the interface
presented by the models is really close to the conceptual data objects
presented to the users.  After that, adding for example a REST layer
isn't hard; since it only has to use the same high-level methods as
the HTML views.  again, consistency is guaranteed by the common
underlying implementation.

in short: an application model is _not_ an OOP view of the database;
it's the implementation of the conceptual data objects as handled by
the application.

-- 
Javier

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



Re: Optimistic Locking in Django?

2012-06-30 Thread Steven Cummings
If you read over the linked discussion it's quite possible, just an issue
of how disruptive it would be to the ORM APIs.

On Saturday, June 30, 2012, Dennis Lee Bieber wrote:

> On Sat, 30 Jun 2012 15:24:59 -0700 (PDT), ydjango 
> 
> >
> declaimed the following in gmane.comp.python.django.user:
>
> >
> > I did google search on "optimistic locking". Most discussion are very
> old.
> >
> > Has Django added any features to support it or what are folks generally
> > doing?
>
>Since the locking relies upon the database engine itself, Django
> probably can't do anything for it -- it would require the front-end to
> know about features of the engine, and that could be a significant
> impact if one changes the engine later (not to mention the overhead of
> looking up some feature list for each engine so it can execute different
> code based on what type of locking is available).
> --
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.com 
> HTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to 
> django-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
--
Steven

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



Re: Optimistic Locking in Django?

2012-06-30 Thread Steven Cummings
I started looking into it a while back:
https://code.djangoproject.com/ticket/16549

The work broke down into ensuring that the updated/deleted/matched counts
were returned from the internal ORM objects. Then there was a fair amount
of discussion of what the public API of the ORM could provide on top of
that. It's kind of died out a bit, I'd like to get back to it and rekindle
the discussion when I can find some time.
--
Steven


On Sat, Jun 30, 2012 at 5:24 PM, ydjango  wrote:

>
> I did google search on "optimistic locking". Most discussion are very old.
>
> Has Django added any features to support it or what are folks generally
> doing?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/oaykVwXK58wJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Query with GeoDjango

2012-06-30 Thread Ethan Jucovy
On Sat, Jun 30, 2012 at 8:31 PM, Odagi  wrote:

> It's working! Thanks a lot.
> Is There a problem with mixing regular models fields with geomodels ones?
>

No, there's no problem, as long as you remember to use a GeoManager on
every model that ever does geospatial queries (whether or not it has any
geospatial fields itself)

-Ethan

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



Re:Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-06-30 Thread Setiaman Lee
Hi Cal,
Interesting topic. Count me in.
On Jun 30, 2012 11:10 PM, "Cal Leeming [Simplicity Media Ltd]" <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Hi all,
>
> As some of you know, I did a live webcast last year (July 2011) on our LLG
> project, which explained how we overcome some of the problems associated
> with large data processing.
>
> After reviewing the video, I found that the sound quality was very
> poor, the slides weren't very well structured, and some of the information
> is now out of date (at the time it was 40mil rows, now we're dealing with
> 700+mil rows).
>
> Therefore, I'm considering doing another live webcast (except this time
> it'll be recorded+posted the next day, the stream will be available in
> 1080p, it'll be far better structured, and will only last 50 minutes).
>
> The topics I'd like to cover are:
>
> * Bulk data processing where bulk_insert() is still not viable (we went
> from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still
> using the ORM - no raw sql here!!)
> * Applying faux child/parent relationship when standard ORM is too
> expensive (allows for ORM approach without the cost)
> * Applying faux ORM read-only structure to legacy applications (allows ORM
> usage on schemas that weren't properly designed, and cannot be changed -
> for example, vendor software with no source code).
> * New Relic is beautiful, but expensive. Hear more about our plans to make
> an open source version.
> * Appropriate use cases for IAAS vs colo with SSDs.
> * Percona is amazing, some of the tips/tricks we've learned over.
>
> If you'd like to see this happen, please leave a reply in the thread - if
> enough people want this, then we'll do public vote for the scheduled date.
>
> Cheers
>
> Cal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-06-30 Thread Rafael Durán Castañeda

El 30/06/12 17:10, Cal Leeming [Simplicity Media Ltd] escribió:

Hi all,

As some of you know, I did a live webcast last year (July 2011) on our 
LLG project, which explained how we overcome some of the problems 
associated with large data processing.


After reviewing the video, I found that the sound quality was very 
poor, the slides weren't very well structured, and some of the 
information is now out of date (at the time it was 40mil rows, now 
we're dealing with 700+mil rows).


Therefore, I'm considering doing another live webcast (except this 
time it'll be recorded+posted the next day, the stream will be 
available in 1080p, it'll be far better structured, and will only last 
50 minutes).


The topics I'd like to cover are:

* Bulk data processing where bulk_insert() is still not viable (we 
went from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst 
still using the ORM - no raw sql here!!)
* Applying faux child/parent relationship when standard ORM is too 
expensive (allows for ORM approach without the cost)
* Applying faux ORM read-only structure to legacy applications (allows 
ORM usage on schemas that weren't properly designed, and cannot be 
changed - for example, vendor software with no source code).
* New Relic is beautiful, but expensive. Hear more about our plans to 
make an open source version.

* Appropriate use cases for IAAS vs colo with SSDs.
* Percona is amazing, some of the tips/tricks we've learned over.

If you'd like to see this happen, please leave a reply in the thread - 
if enough people want this, then we'll do public vote for the 
scheduled date.


Cheers

Cal
--
You received this message because you are subscribed to the Google 
Groups "Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

That would be great!

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



Re: Query with GeoDjango

2012-06-30 Thread Odagi
It's working! Thanks a lot. 
Is There a problem with mixing regular models fields with geomodels ones?


The single underscore is correct: 
> https://docs.djangoproject.com/en/dev/ref/contrib/gis/geoquerysets/#distance-lte
>
> But, you need to use a `objects = GeoManager()` on the Restaurants model 
> (as well as the Place model) per the docs: 
> https://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#django.contrib.gis.db.models.GeoManager
>
>  -Ethan
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/4FdC-Q1mfuUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Query with GeoDjango

2012-06-30 Thread Ethan Jucovy
On Sat, Jun 30, 2012 at 8:19 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> Try a double underscore between distance and lte.
>

The single underscore is correct:
https://docs.djangoproject.com/en/dev/ref/contrib/gis/geoquerysets/#distance-lte

But, you need to use a `objects = GeoManager()` on the Restaurants model
(as well as the Place model) per the docs:
https://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#django.contrib.gis.db.models.GeoManager

 -Ethan


> _Nik
>
> On 6/30/2012 5:18 PM, Odagi wrote:
> > Hello all. I'm wondering how to resolve this problem with a
> > GeoDjango.This are my models:
> >
> >
> > from django.db import models
> > from django.contrib.gis.db import models as geomodels
> > from django.contrib.gis.geos import Point
> > from django.contrib.gis.measure import D
> >
> > class Place(geomodels.Model):
> > name = models.CharField(max_length=50)
> > point = geomodels.PointField(null=True)
> > objects = geomodels.GeoManager()
> >
> > def __unicode__(self):
> > return u"%s the place" % self.name
> >
> >
> > class Restaurant(models.Model):
> > place = models.OneToOneField(Place, primary_key=True)
> > serves_hot_dogs = models.BooleanField()
> > serves_pizza = models.BooleanField()
> >
> > def __unicode__(self):
> > return u"%s the restaurant" % self.place.name
> >
> >
> >
> > How can I get all Restaurants that serve pizza in a radio of 45km of a
> > given (geolocation) point?
> > I'm trying something like:
> >
> > pnt = Point(-34.5875015259, -58.6725006104)
> > Restaurant.objects.all().filter(place__point__distance_lte=(pnt,
> > D(km=45)))
> >
> > But it's not working:
> > Join on field 'point' not permitted. Did you misspell 'distance_lte' for
> the lookup type?
> >
> > Any ideas?
> > Thanks in advance.
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/django-users/-/eGmII8v1GMMJ.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Query with GeoDjango

2012-06-30 Thread Nikolas Stevenson-Molnar
Try a double underscore between distance and lte.

_Nik

On 6/30/2012 5:18 PM, Odagi wrote:
> Hello all. I'm wondering how to resolve this problem with a
> GeoDjango.This are my models:
>
>
> from django.db import models
> from django.contrib.gis.db import models as geomodels
> from django.contrib.gis.geos import Point
> from django.contrib.gis.measure import D
>
> class Place(geomodels.Model):
> name = models.CharField(max_length=50)
> point = geomodels.PointField(null=True)
> objects = geomodels.GeoManager()
>
> def __unicode__(self):
> return u"%s the place" % self.name
>
>
> class Restaurant(models.Model):
> place = models.OneToOneField(Place, primary_key=True)
> serves_hot_dogs = models.BooleanField()
> serves_pizza = models.BooleanField()
>
> def __unicode__(self):
> return u"%s the restaurant" % self.place.name
>
> 
>
> How can I get all Restaurants that serve pizza in a radio of 45km of a
> given (geolocation) point?
> I'm trying something like:
>
> pnt = Point(-34.5875015259, -58.6725006104)
> Restaurant.objects.all().filter(place__point__distance_lte=(pnt,
> D(km=45)))
>
> But it's not working:
> Join on field 'point' not permitted. Did you misspell 'distance_lte' for the 
> lookup type?
>
> Any ideas?
> Thanks in advance.
>
>
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/eGmII8v1GMMJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.


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



Query with GeoDjango

2012-06-30 Thread Odagi
Hello all. I'm wondering how to resolve this problem with a GeoDjango.This 
are my models:


from django.db import models
from django.contrib.gis.db import models as geomodels
from django.contrib.gis.geos import Point
from django.contrib.gis.measure import D

class Place(geomodels.Model):
name = models.CharField(max_length=50)
point = geomodels.PointField(null=True)
objects = geomodels.GeoManager()

def __unicode__(self):
return u"%s the place" % self.name


class Restaurant(models.Model):
place = models.OneToOneField(Place, primary_key=True)
serves_hot_dogs = models.BooleanField()
serves_pizza = models.BooleanField()

def __unicode__(self):
return u"%s the restaurant" % self.place.name



How can I get all Restaurants that serve pizza in a radio of 45km of a 
given (geolocation) point?
I'm trying something like:

pnt = Point(-34.5875015259, -58.6725006104)
Restaurant.objects.all().filter(place__point__distance_lte=(pnt, D(km=45)))

But it's not working:

Join on field 'point' not permitted. Did you misspell 'distance_lte' for the 
lookup type?


Any ideas?
Thanks in advance.




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/eGmII8v1GMMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: advantages and disadvantages of Raw sql queries in django

2012-06-30 Thread Nick Apostolakis

On 30/06/2012 10:58 μμ, Javier Guerra Giraldez wrote:


Even when using the ORM, any complex query is a good candidate to be
encapsulated as part of the model.  Ideally, the model should expose a
high level view of your data objects, not simply an easy to use view
of the database.

   


Interesting idea, I haven't used that yet, could you give an example of 
that?
Would you use a method calling the ORM that would include something like 
self.objects.select_related().bla bla?


Thanks

--
 --
   Nick Apostolakis
  e-mail: nicka...@oncrete.gr
 Web Site: http://nick.oncrete.gr
 --


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



Optimistic Locking in Django?

2012-06-30 Thread ydjango

I did google search on "optimistic locking". Most discussion are very old.

Has Django added any features to support it or what are folks generally 
doing? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/oaykVwXK58wJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: advantages and disadvantages of Raw sql queries in django

2012-06-30 Thread Javier Guerra Giraldez
On Sat, Jun 30, 2012 at 1:33 AM, Mike Dewhirst  wrote:
> I firmly believe in using the ORM for everything until i am forced to use
> handwritten SQL.

absolutely agree


> I could also argue against custom SQL because it contains business logic and
> i prefer to keep that all in one place, ie., in models in python code.

of course, when you have to use SQL, the best place to put it is in
the models file, either on the model itself or on a custom manager.
That way, if/when you modify the database representation, you don't
have to change other parts of the code.

Even when using the ORM, any complex query is a good candidate to be
encapsulated as part of the model.  Ideally, the model should expose a
high level view of your data objects, not simply an easy to use view
of the database.

-- 
Javier

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



i want to display a student profile from the database and am unable to do that.plz help

2012-06-30 Thread rick

this is my views.py.

def studentid(request):
if request.method == 'POST':
form = Student_loginForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
rollno = cd['rollno']
p = form.save()
rollno = request.POST.get('rollno')
rollno=int(rollno)
results = Add_record.objects.filter(Student_ID=rollno)
return HttpResponseRedirect(reverse('record_system.views.search', 
args=(results)))


def search(request,Student_ID ):
p = get_object_or_404(Add_record, pk=Student_ID)
p.save()
return render_to_response('add_record/search.html', locals(), 
context_instance=RequestContext(request))


and am getting error on browser that 

NoReverseMatch at /record_system/studentid/ 

Reverse for 'record_system.views.search' with arguments '(,)' and keyword arguments '{}' not found.


thanks in advance..


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UwDmhLfnsyUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: settings and constants on a reusable app

2012-06-30 Thread Bill Freeman
Support an additional variable MY_APP_USE_OTHER_CONSTANT (MY and
MY_APP, are, I hope, not the prefixes you are actually using), which
defaults to False and which the project settings file can override to
True.

On Fri, Jun 29, 2012 at 9:06 AM, Marc Aymerich  wrote:
> On Fri, Jun 29, 2012 at 11:08 AM, Thomas Rega  wrote:
>> Am 28.06.12 17:30, schrieb Marc Aymerich:
>>
>>> Hi,
>>> I'm developing a reusable application and I'm having troubles with
>>> constant values on settings.
>>>
>>> Imagine that the reusable application comes with the following settings.py
>>>
>>> # MY_APP/settings.py
>>> from django.conf import settings
>>> MY_CONSTANT = 'C1'
>>> MY_OTHER_CONSTANT =  'C2'
>>> MY_SETTING = getattr(settings, 'MY_SETTING', CONSTANT)
>>>
>>>
>>> But for your project you want to override the default value of
>>> MY_SETTING by MY_OTHER_CONSTANT. So you edit your project settings.py
>>> and adds these two lines:
>>>
>>> # Project settings.py
>>> 
>>> from MY_APP.settings import settings as my_app_settings
>>> MY_SETTING = my_app_settings.MY_OTHER_SETTING
>>>
>>>
>>> But this is going to fail because of the import order.
>>>
>>> Is there any consistent way to handle this situation?
>>>
>>> Thanks!
>>
>> Hi,
>>
>> what about the idea to overwrite these values via a 'local_settings.py'
>> file?
>>
>> An example can be found here:
>> https://bitbucket.org/chris1610/satchmo/src/1255b19295c7/satchmo/projects/skeleton/settings.py
>
> Hi thomas, thanks :)
>
> Yeah, actually I'm using a local_settings.py file, but at the end it
> will be the same as using settings.py since local_settings.py is
> imported by settings.py. :(
>
>
> --
> Marc
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-30 Thread Larry Martell
On Sat, Jun 30, 2012 at 11:54 AM, Psamathos  wrote:
> If your web server is in fact serving the content with the incorrect
> Content-Type header (You can verify this by inspecting the response in the
> Net tab of Firebug or Chrome) jQuery can convert the response regardless of
> the content-type if you specify a two space-separated values in your
> dataType. Try dataType: "text html" in your $.ajax function.

I've been poking around with the debugger. For reference, here's the code:

var $form = $('form.roll');
url = $form.attr('action');

var $report = $('#report');

$.ajax({
url: url,
data: $form.serialize(),
dataType: 'html',
success: function (html, textStatus) {
$report
.html($('#report', html).html())
.css({
opacity: 1.0
});
style_preview_table();
}


The html variable passed into the success function contains the entire
page, including the javascript. I tried doing:

$report.html(html)

But the parts of the page that were not the results (i.e. #report) all
were duplicated (the page was displayed within the page). But even
there, the javascript wasn't included in the page, even though is was
in the html variable.

$('#report', html).html() contained just the html, without the
javascript. What I need is some way to get both the javascript and the
html of $('#report') and then pass that into $report.html(). Are there
javascript or jQuery methods that will allow me to do that?

Alternatively I could extract the javascript from the html variable
passed into the success function. But then how would I make that part
of  $report.html()?

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-30 Thread Bill Freeman
curl (or its windows equivalents) will tell you exactly what django sent, as
would poking around from a suitably placed pdb.set_trace()

On Fri, Jun 29, 2012 at 8:42 PM, Larry Martell  wrote:
> On Fri, Jun 29, 2012 at 4:54 PM, Jani Tiainen  wrote:
>> I meant that if for some reason Django sends incorrect content type from a
>> view or something like that your javascript framework might guess
>> incorrectly your ajax request content type and not parse script tags.
>
> Is there a way I can test to see if this is occurring?
>
>
>>
>>
>> On Sat, Jun 30, 2012 at 1:51 AM, Jani Tiainen  wrote:
>>>
>>> It's known limitation of your ajax request and has nothing to do with
>>> Django nor templates. Or well it might do.
>>>
>>> Most of the javascript frameworks can extract script and inject it
>>> correctly to current DOM. Since you mention jquery I guess that you're using
>>> that for ajax queries so make sure that your $.ajax() has dataType attribute
>>> to set as 'html'. It should (according to docs) parse script parts
>>> correctly.
>>>
>>>
>>> On Fri, Jun 29, 2012 at 11:45 PM, Larry Martell 
>>> wrote:

 I have a django template that has some javascript/jQuery code in it
 that defines some keyup event handers. If a user goes to the URL
 directly the javascript is executed, and the event handers all work
 fine. There is also a field that they can type in that triggers the
 same URL request to be sent via ajax. When they do this, it seems that
 the html is rendered, but the javascript is not executed. I discovered
 this by noticing that the page was rendered, but none of the
 javascript event handers were being called. I proved this by adding:



alert('here we are');


 to the template, and the alert doesn't show when the request comes
 from ajax. But if I go to the URL directly it does.

 Is this a known issue? Is there some way I can get my javascript code
 to run to install my event handlers when the request comes from ajax?

 TIA!
 -larry

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

>>>
>>>
>>>
>>> --
>>> Jani Tiainen
>>>
>>> - Well planned is half done, and a half done has been sufficient before...
>>>
>>
>>
>>
>> --
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-30 Thread Psamathos
If your web server is in fact serving the content with the incorrect 
Content-Type header (You can verify this by inspecting the response in the 
Net tab of Firebug or Chrome) jQuery can convert the response regardless of 
the content-type if you specify a two space-separated values in your 
dataType. Try dataType: "text html" in your $.ajax function.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XB_Q1y7lXlQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: adding fields into another apps forms (in plugin style)

2012-06-30 Thread spu
I think he wants to load the plugins in a dynamic way. If you look how the 
admin package of django works you will have the answer:

The class AdminSite has a method register, which adds a model, on which the 
site builds itself. So each plugin can register its own admin stuff in a 
admin module. 

Your task is to write your own class that registers plugins and to make a 
global instance of it.

Am Mittwoch, 19. Januar 2011 15:38:07 UTC+1 schrieb Shawn Milochik:
>
> You can just subclass the form or modelform.
>
> Shawn
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/tkvtGsvvXm8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: invalid keyword argument for this function

2012-06-30 Thread Nikhil Verma
Yes its different.I was trying to say i tried your way and get rid of that
error.

Thanks

On Sat, Jun 30, 2012 at 8:56 PM, Sunny Nanda  wrote:

> This is a different error, and I don't see anything in the code snippet
> that might have caused this error (except if you are doing something in the
> Event model's save method)
>
> You would need to debug it further, and pinpoint the location of this
> error.
>
>
> On Saturday, June 30, 2012 8:37:34 PM UTC+5:30, Nikhil Verma wrote:
>
>> Yes its with the braces ")" also.
>>
>> On Sat, Jun 30, 2012 at 8:36 PM, Nikhil Verma 
>> wrote:
>>
>>> Hi Sunny
>>>
>>> I am trying with this
>>>
>>> *event_genre = event_form.cleaned_data['event_genre']
>>> event_public = event_form.cleaned_data['event_public']
>>> event_obj.save()*
>>> *category_obj.event_genre.add(event_genre),
>>>   category_obj.event_public.add(event_public*
>>>
>>>
>>> and getting this traceback:-
>>>
>>>
>>> Exception Type: TypeError at /event/createevent/
>>> Exception Value: int() argument must be a string or a number, not
>>> 'QuerySet'
>>>
>>>
>>> On Sat, Jun 30, 2012 at 8:30 PM, Sunny Nanda  wrote:
>>>
>>> Hi Nikhil,

 Just to reiterate :), you need to remove both event_public & even_genre 
 while
 creating the instance of the model, since both of them are M2M Fields. Take
 a look at the example in my previous mail.

 If you are getting this exception somewhere else, please send that code
 snippet so we might able to see the problem.

 Thanks,
 Sandeep


 On Saturday, June 30, 2012 8:14:28 PM UTC+5:30, Nikhil Verma wrote:

> Hi Sunny
>
> I realized that earlier sunny, and cleared that defect but i get stuck
> into this error
>
> Traceback:
>
> Exception Type: TypeError at /event/createevent/
> Exception Value: 'event_genre' is an invalid keyword argument for this
> function
>
> Any help ?
>
> Thanks in advance
>
>
> On Sat, Jun 30, 2012 at 7:08 PM, Sunny Nanda  wrote:
>
> Hi Nikhil,
>>
>> You can not use an object's M2M field until it has been saved to the
>> db.
>> So, you would have to call the "save" method on the instance, or use
>> "create" method to create the instance.
>>
>>> category_obj = Category.objects.create(
>>> type = categoryform.cleaned_data['**typ*
>>> ***e']
>>> )
>>> event_public = categoryform.cleaned_data['**eve
>>> nt_public']
>>> event_genre = categoryform.cleaned_data['**eve
>>> nt_genre']
>>> category_obj.event_genre.add(**event_genre),
>>> category_obj.event_public.add(**event_public),
>>> # No need to call save here
>>> # category_obj.save()
>>
>>
>> The reason behind this is that M2M Fields are represented
>> by intermediate tables with references to the two linked objects. If you
>> need to add a row in it, both referenced objects should already be saved 
>> in
>> the db with valid primary keys.
>>
>> H2H
>> -Sandeep
>>
>>
>> On Saturday, June 30, 2012 1:21:30 PM UTC+5:30, Nikhil Verma wrote:
>>>
>>> Hi All
>>>
>>> I have the following models like this :-
>>>
>>>
>>> class EventGenre(models.Model):
>>> genre_choices = models.CharField(max_length=**255)
>>>
>>> def __unicode__(self):
>>> return self.genre_choices
>>>
>>> class EventPublic(models.Model):
>>> choicelist = models.CharField(max_length=**255)
>>>
>>> def __unicode__(self):
>>> return self.choicelist
>>>
>>> class Category(models.Model):
>>> """
>>> Describes the Event Category
>>> """
>>>
>>> type = models.CharField(max_length=**20,\
>>>   **choices=EVENT_TYPE,\
>>>   **help_text = "type of event"
>>>   **)
>>> # Genre of event like classical,rock,pop ,indie etc
>>> event_genre = models.ManyToManyField(**EventGenre)
>>>
>>> # audience for this event like adults ,children etc
>>> event_public = models.ManyToManyField(**EventPublic)
>>>
>>> def __unicode__(self):
>>> return self.type
>>>
>>> This is my category form
>>>
>>> class CategoryForm(forms.Form):
>>> type = forms.CharField(max_length=80, \
>>>widget=RadioSelect(choices=**EVE
>>> NT_TYPE)
>>>)
>>> event_genre = forms.**ModelMultipleChoiceField(
>>> queryset = EventGenre.objects.all(),
>>> widget

Re: Use regular expression to retrieve all image tags from a given content

2012-06-30 Thread Maksim Schepelin
Why not use html parse lib? BeautifulSoup(
http://www.crummy.com/software/BeautifulSoup/) for expample

from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup('put_youp_html_code_as_string')
images = soup.find_all('img')

If you need exactly regular expressions, watch this video: 
http://www.youtube.com/watch?v=kWyoYtvJpe4

суббота, 30 июня 2012 г., 20:37:13 UTC+8 пользователь mo.mughrabi написал:
>
> Hello, 
>
> am really a noob with regular expressions, I tried to do this on my own 
> but I couldn't understand from the manuals how to approach it. Am trying to 
> find all img tags of a given content, I wrote the below but its returning 
> None
>
>  content = i.content[0].value
>
> prog = re.compile(r'^
> result = prog.match(content)
>
> print result
>
>
>  any suggestions?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/wAd5IjIA8ngJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: invalid keyword argument for this function

2012-06-30 Thread Sunny Nanda
This is a different error, and I don't see anything in the code snippet 
that might have caused this error (except if you are doing something in the 
Event model's save method)

You would need to debug it further, and pinpoint the location of this error.

On Saturday, June 30, 2012 8:37:34 PM UTC+5:30, Nikhil Verma wrote:
>
> Yes its with the braces ")" also.
>
> On Sat, Jun 30, 2012 at 8:36 PM, Nikhil Verma wrote:
>
>> Hi Sunny
>>
>> I am trying with this
>>
>> *event_genre = event_form.cleaned_data['event_genre']
>> event_public = event_form.cleaned_data['event_public']
>> event_obj.save()*
>> *category_obj.event_genre.add(event_genre),
>>   category_obj.event_public.add(event_public*
>>
>>
>> and getting this traceback:-
>>
>>
>> Exception Type: TypeError at /event/createevent/
>> Exception Value: int() argument must be a string or a number, not 
>> 'QuerySet'
>>
>>
>> On Sat, Jun 30, 2012 at 8:30 PM, Sunny Nanda  wrote:
>>
>>> Hi Nikhil,
>>>
>>> Just to reiterate :), you need to remove both event_public & even_genre 
>>> while 
>>> creating the instance of the model, since both of them are M2M Fields. Take 
>>> a look at the example in my previous mail.
>>>
>>> If you are getting this exception somewhere else, please send that code 
>>> snippet so we might able to see the problem.
>>>
>>> Thanks,
>>> Sandeep
>>>
>>>
>>> On Saturday, June 30, 2012 8:14:28 PM UTC+5:30, Nikhil Verma wrote:
>>>
 Hi Sunny 

 I realized that earlier sunny, and cleared that defect but i get stuck 
 into this error

 Traceback:

 Exception Type: TypeError at /event/createevent/
 Exception Value: 'event_genre' is an invalid keyword argument for this 
 function

 Any help ?

 Thanks in advance


 On Sat, Jun 30, 2012 at 7:08 PM, Sunny Nanda  wrote:

 Hi Nikhil,
>
> You can not use an object's M2M field until it has been saved to the 
> db.
> So, you would have to call the "save" method on the instance, or use 
> "create" method to create the instance.
>
>> category_obj = Category.objects.create(
>> type = categoryform.cleaned_data['**typ**
>> e']
>> )
>> event_public = categoryform.cleaned_data['**eve**
>> nt_public']
>> event_genre = categoryform.cleaned_data['**eve**
>> nt_genre']
>> category_obj.event_genre.add(**e**vent_genre),
>> category_obj.event_public.add(event_public),
>> # No need to call save here
>> # category_obj.save() 
>
>   
> The reason behind this is that M2M Fields are represented 
> by intermediate tables with references to the two linked objects. If you 
> need to add a row in it, both referenced objects should already be saved 
> in 
> the db with valid primary keys.
>
> H2H
> -Sandeep
>
>
> On Saturday, June 30, 2012 1:21:30 PM UTC+5:30, Nikhil Verma wrote:
>>
>> Hi All
>>
>> I have the following models like this :-
>>
>>
>> class EventGenre(models.Model):
>> genre_choices = models.CharField(max_length=**25**5)
>> 
>> def __unicode__(self):
>> return self.genre_choices
>> 
>> class EventPublic(models.Model):
>> choicelist = models.CharField(max_length=**25**5)
>>
>> def __unicode__(self):
>> return self.choicelist
>>
>> class Category(models.Model):
>> """
>> Describes the Event Category
>> """
>> 
>> type = models.CharField(max_length=**20**,\
>>   choices=EVENT_TYPE,\
>>   help_text = "type of event"
>>   )
>> # Genre of event like classical,rock,pop ,indie etc
>> event_genre = models.ManyToManyField(**EventGe**nre)
>> 
>> # audience for this event like adults ,children etc
>> event_public = models.ManyToManyField(**EventPu**blic)
>> 
>> def __unicode__(self):
>> return self.type
>>
>> This is my category form
>>
>> class CategoryForm(forms.Form):
>> type = forms.CharField(max_length=80, \
>>widget=RadioSelect(choices=**EVE**NT_TYPE)
>>)
>> event_genre = forms.**ModelMultipleChoiceField**(
>> queryset = EventGenre.objects.all(),
>> widget=CheckboxSelectMultiple,
>> required=False
>> )
>> event_public = forms.**ModelMultipleChoiceField**(
>> queryset = EventPublic.objects.all(),
>>   
>>
>>  

Handling millions of rows + large bulk processing (now 700+ mil rows)

2012-06-30 Thread Cal Leeming [Simplicity Media Ltd]
Hi all,

As some of you know, I did a live webcast last year (July 2011) on our LLG
project, which explained how we overcome some of the problems associated
with large data processing.

After reviewing the video, I found that the sound quality was very
poor, the slides weren't very well structured, and some of the information
is now out of date (at the time it was 40mil rows, now we're dealing with
700+mil rows).

Therefore, I'm considering doing another live webcast (except this time
it'll be recorded+posted the next day, the stream will be available in
1080p, it'll be far better structured, and will only last 50 minutes).

The topics I'd like to cover are:

* Bulk data processing where bulk_insert() is still not viable (we went
from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still
using the ORM - no raw sql here!!)
* Applying faux child/parent relationship when standard ORM is too
expensive (allows for ORM approach without the cost)
* Applying faux ORM read-only structure to legacy applications (allows ORM
usage on schemas that weren't properly designed, and cannot be changed -
for example, vendor software with no source code).
* New Relic is beautiful, but expensive. Hear more about our plans to make
an open source version.
* Appropriate use cases for IAAS vs colo with SSDs.
* Percona is amazing, some of the tips/tricks we've learned over.

If you'd like to see this happen, please leave a reply in the thread - if
enough people want this, then we'll do public vote for the scheduled date.

Cheers

Cal

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



Re: invalid keyword argument for this function

2012-06-30 Thread Nikhil Verma
Yes its with the braces ")" also.

On Sat, Jun 30, 2012 at 8:36 PM, Nikhil Verma wrote:

> Hi Sunny
>
> I am trying with this
>
> *event_genre = event_form.cleaned_data['event_genre']
> event_public = event_form.cleaned_data['event_public']
> event_obj.save()*
> *category_obj.event_genre.add(event_genre),
>   category_obj.event_public.add(event_public*
>
>
> and getting this traceback:-
>
>
> Exception Type: TypeError at /event/createevent/
> Exception Value: int() argument must be a string or a number, not
> 'QuerySet'
>
>
> On Sat, Jun 30, 2012 at 8:30 PM, Sunny Nanda  wrote:
>
>> Hi Nikhil,
>>
>> Just to reiterate :), you need to remove both event_public & even_genre while
>> creating the instance of the model, since both of them are M2M Fields. Take
>> a look at the example in my previous mail.
>>
>> If you are getting this exception somewhere else, please send that code
>> snippet so we might able to see the problem.
>>
>> Thanks,
>> Sandeep
>>
>>
>> On Saturday, June 30, 2012 8:14:28 PM UTC+5:30, Nikhil Verma wrote:
>>
>>> Hi Sunny
>>>
>>> I realized that earlier sunny, and cleared that defect but i get stuck
>>> into this error
>>>
>>> Traceback:
>>>
>>> Exception Type: TypeError at /event/createevent/
>>> Exception Value: 'event_genre' is an invalid keyword argument for this
>>> function
>>>
>>> Any help ?
>>>
>>> Thanks in advance
>>>
>>>
>>> On Sat, Jun 30, 2012 at 7:08 PM, Sunny Nanda  wrote:
>>>
>>> Hi Nikhil,

 You can not use an object's M2M field until it has been saved to the db.
 So, you would have to call the "save" method on the instance, or use
 "create" method to create the instance.

> category_obj = Category.objects.create(
> type = categoryform.cleaned_data['**typ**
> e']
> )
> event_public = categoryform.cleaned_data['**eve**
> nt_public']
> event_genre = categoryform.cleaned_data['**eve**nt_genre']
> category_obj.event_genre.add(**e**vent_genre),
> category_obj.event_public.add(event_public),
> # No need to call save here
> # category_obj.save()


 The reason behind this is that M2M Fields are represented
 by intermediate tables with references to the two linked objects. If you
 need to add a row in it, both referenced objects should already be saved in
 the db with valid primary keys.

 H2H
 -Sandeep


 On Saturday, June 30, 2012 1:21:30 PM UTC+5:30, Nikhil Verma wrote:
>
> Hi All
>
> I have the following models like this :-
>
>
> class EventGenre(models.Model):
> genre_choices = models.CharField(max_length=**25**5)
>
> def __unicode__(self):
> return self.genre_choices
>
> class EventPublic(models.Model):
> choicelist = models.CharField(max_length=**25**5)
>
> def __unicode__(self):
> return self.choicelist
>
> class Category(models.Model):
> """
> Describes the Event Category
> """
>
> type = models.CharField(max_length=**20**,\
>   choices=EVENT_TYPE,\
>   help_text = "type of event"
>   )
> # Genre of event like classical,rock,pop ,indie etc
> event_genre = models.ManyToManyField(**EventGe**nre)
>
> # audience for this event like adults ,children etc
> event_public = models.ManyToManyField(**EventPu**blic)
>
> def __unicode__(self):
> return self.type
>
> This is my category form
>
> class CategoryForm(forms.Form):
> type = forms.CharField(max_length=80, \
>widget=RadioSelect(choices=**EVE**NT_TYPE)
>)
> event_genre = forms.**ModelMultipleChoiceField**(
> queryset = EventGenre.objects.all(),
> widget=CheckboxSelectMultiple,
> required=False
> )
> event_public = forms.**ModelMultipleChoiceField**(
> queryset = EventPublic.objects.all(),
>
> widget=CheckboxSelectMultiple,
> required=False
> )
>
> This is my views.py
>
> def eventcreation(request):
> if request.method == "POST":
> event_form = EventForm(request.POST,**request**.FILES,prefix="
> **eventform")
> categoryform = CategoryForm(request.POST)
> if event_form.is_valid():
> event_obj = Event(
> venue_name = event_form.cleaned_data['**venue**_name'],
> date_cr

Re: invalid keyword argument for this function

2012-06-30 Thread Nikhil Verma
Hi Sunny

I am trying with this

*event_genre = event_form.cleaned_data['event_genre']
event_public = event_form.cleaned_data['event_public']
event_obj.save()*
*category_obj.event_genre.add(event_genre),
  category_obj.event_public.add(event_public*


and getting this traceback:-

Exception Type: TypeError at /event/createevent/
Exception Value: int() argument must be a string or a number, not 'QuerySet'

On Sat, Jun 30, 2012 at 8:30 PM, Sunny Nanda  wrote:

> Hi Nikhil,
>
> Just to reiterate :), you need to remove both event_public & even_genre while
> creating the instance of the model, since both of them are M2M Fields. Take
> a look at the example in my previous mail.
>
> If you are getting this exception somewhere else, please send that code
> snippet so we might able to see the problem.
>
> Thanks,
> Sandeep
>
>
> On Saturday, June 30, 2012 8:14:28 PM UTC+5:30, Nikhil Verma wrote:
>
>> Hi Sunny
>>
>> I realized that earlier sunny, and cleared that defect but i get stuck
>> into this error
>>
>> Traceback:
>>
>> Exception Type: TypeError at /event/createevent/
>> Exception Value: 'event_genre' is an invalid keyword argument for this
>> function
>>
>> Any help ?
>>
>> Thanks in advance
>>
>>
>> On Sat, Jun 30, 2012 at 7:08 PM, Sunny Nanda  wrote:
>>
>> Hi Nikhil,
>>>
>>> You can not use an object's M2M field until it has been saved to the db.
>>> So, you would have to call the "save" method on the instance, or use
>>> "create" method to create the instance.
>>>
 category_obj = Category.objects.create(
 type = categoryform.cleaned_data['**typ**
 e']
 )
 event_public = categoryform.cleaned_data['**eve**
 nt_public']
 event_genre = categoryform.cleaned_data['**eve**nt_genre']
 category_obj.event_genre.add(**e**vent_genre),
 category_obj.event_public.add(event_public),
 # No need to call save here
 # category_obj.save()
>>>
>>>
>>> The reason behind this is that M2M Fields are represented
>>> by intermediate tables with references to the two linked objects. If you
>>> need to add a row in it, both referenced objects should already be saved in
>>> the db with valid primary keys.
>>>
>>> H2H
>>> -Sandeep
>>>
>>>
>>> On Saturday, June 30, 2012 1:21:30 PM UTC+5:30, Nikhil Verma wrote:

 Hi All

 I have the following models like this :-


 class EventGenre(models.Model):
 genre_choices = models.CharField(max_length=**25**5)

 def __unicode__(self):
 return self.genre_choices

 class EventPublic(models.Model):
 choicelist = models.CharField(max_length=**25**5)

 def __unicode__(self):
 return self.choicelist

 class Category(models.Model):
 """
 Describes the Event Category
 """

 type = models.CharField(max_length=**20**,\
   choices=EVENT_TYPE,\
   help_text = "type of event"
   )
 # Genre of event like classical,rock,pop ,indie etc
 event_genre = models.ManyToManyField(**EventGe**nre)

 # audience for this event like adults ,children etc
 event_public = models.ManyToManyField(**EventPu**blic)

 def __unicode__(self):
 return self.type

 This is my category form

 class CategoryForm(forms.Form):
 type = forms.CharField(max_length=80, \
widget=RadioSelect(choices=**EVE**NT_TYPE)
)
 event_genre = forms.**ModelMultipleChoiceField**(
 queryset = EventGenre.objects.all(),
 widget=CheckboxSelectMultiple,
 required=False
 )
 event_public = forms.**ModelMultipleChoiceField**(
 queryset = EventPublic.objects.all(),

 widget=CheckboxSelectMultiple,
 required=False
 )

 This is my views.py

 def eventcreation(request):
 if request.method == "POST":
 event_form = EventForm(request.POST,**request**.FILES,prefix="*
 *eventform")
 categoryform = CategoryForm(request.POST)
 if event_form.is_valid():
 event_obj = Event(
 venue_name = event_form.cleaned_data['**venue**_name'],
 date_created = event_form.cleaned_data['**event**
 _start_date'],
 date_completed = event_form.cleaned_data['**event**
 _end_date'],
 event_ticket_price = event_form.cleaned_data['**event**
 _ticket_price'],
  

Re: invalid keyword argument for this function

2012-06-30 Thread Sunny Nanda
Hi Nikhil,

Just to reiterate :), you need to remove both event_public & even_genre while 
creating the instance of the model, since both of them are M2M Fields. Take 
a look at the example in my previous mail.

If you are getting this exception somewhere else, please send that code 
snippet so we might able to see the problem.

Thanks,
Sandeep

On Saturday, June 30, 2012 8:14:28 PM UTC+5:30, Nikhil Verma wrote:
>
> Hi Sunny 
>
> I realized that earlier sunny, and cleared that defect but i get stuck 
> into this error
>
> Traceback:
>
> Exception Type: TypeError at /event/createevent/
> Exception Value: 'event_genre' is an invalid keyword argument for this 
> function
>
> Any help ?
>
> Thanks in advance
>
>
> On Sat, Jun 30, 2012 at 7:08 PM, Sunny Nanda  wrote:
>
>> Hi Nikhil,
>>
>> You can not use an object's M2M field until it has been saved to the db.
>> So, you would have to call the "save" method on the instance, or use 
>> "create" method to create the instance.
>>
>>> category_obj = Category.objects.create(
>>> type = categoryform.cleaned_data['**type']
>>> )
>>> event_public = categoryform.cleaned_data['**event_public']
>>> event_genre = categoryform.cleaned_data['**event_genre']
>>> category_obj.event_genre.add(**event_genre),
>>> category_obj.event_public.add(**event_public),
>>> # No need to call save here
>>> # category_obj.save() 
>>
>>   
>> The reason behind this is that M2M Fields are represented 
>> by intermediate tables with references to the two linked objects. If you 
>> need to add a row in it, both referenced objects should already be saved in 
>> the db with valid primary keys.
>>
>> H2H
>> -Sandeep
>>
>>
>> On Saturday, June 30, 2012 1:21:30 PM UTC+5:30, Nikhil Verma wrote:
>>>
>>> Hi All
>>>
>>> I have the following models like this :-
>>>
>>>
>>> class EventGenre(models.Model):
>>> genre_choices = models.CharField(max_length=**255)
>>> 
>>> def __unicode__(self):
>>> return self.genre_choices
>>> 
>>> class EventPublic(models.Model):
>>> choicelist = models.CharField(max_length=**255)
>>>
>>> def __unicode__(self):
>>> return self.choicelist
>>>
>>> class Category(models.Model):
>>> """
>>> Describes the Event Category
>>> """
>>> 
>>> type = models.CharField(max_length=**20,\
>>>   **choices=EVENT_TYPE,\
>>>   **help_text = "type of event"
>>>   **)
>>> # Genre of event like classical,rock,pop ,indie etc
>>> event_genre = models.ManyToManyField(**EventGenre)
>>> 
>>> # audience for this event like adults ,children etc
>>> event_public = models.ManyToManyField(**EventPublic)
>>> 
>>> def __unicode__(self):
>>> return self.type
>>>
>>> This is my category form
>>>
>>> class CategoryForm(forms.Form):
>>> type = forms.CharField(max_length=80, \
>>>widget=RadioSelect(choices=**EVENT_TYPE)
>>>)
>>> event_genre = forms.**ModelMultipleChoiceField(
>>> queryset = EventGenre.objects.all(),
>>> widget=CheckboxSelectMultiple,
>>> required=False
>>> )
>>> event_public = forms.**ModelMultipleChoiceField(
>>> queryset = EventPublic.objects.all(),** 
>>>  
>>>
>>> widget=CheckboxSelectMultiple,
>>> required=False
>>> )
>>>
>>> This is my views.py
>>>
>>> def eventcreation(request):
>>> if request.method == "POST":
>>> event_form = EventForm(request.POST,**request.FILES,prefix="**
>>> eventform")
>>> categoryform = CategoryForm(request.POST)
>>> if event_form.is_valid():
>>> event_obj = Event(
>>> venue_name = event_form.cleaned_data['**venue_name'],
>>> date_created = event_form.cleaned_data['**
>>> event_start_date'],
>>> date_completed = event_form.cleaned_data['**
>>> event_end_date'],
>>> event_ticket_price = event_form.cleaned_data['**
>>> event_ticket_price'],
>>> eventwebsite = event_form.cleaned_data['**eventwebsite'],
>>> keyword = event_form.cleaned_data['**keyword'],
>>> description = event_form.cleaned_data['**description'],
>>> status = event_form.cleaned_data['**status'],
>>> event_poster = event_form.cleaned_data['**event_poster']
>>> )
>>> if categoryform.is_valid():
>>> category_obj = Category(
>>> type = categoryform.cleaned_data['**type'],
>>> event_public = categoryform.cleaned_data['**
>>> event_public'], # It is giving error
>>>

Re: invalid keyword argument for this function

2012-06-30 Thread Nikhil Verma
Hi Sunny

I realized that earlier sunny, and cleared that defect but i get stuck into
this error

Traceback:

Exception Type: TypeError at /event/createevent/
Exception Value: 'event_genre' is an invalid keyword argument for this
function

Any help ?

Thanks in advance


On Sat, Jun 30, 2012 at 7:08 PM, Sunny Nanda  wrote:

> Hi Nikhil,
>
> You can not use an object's M2M field until it has been saved to the db.
> So, you would have to call the "save" method on the instance, or use
> "create" method to create the instance.
>
>> category_obj = Category.objects.create(
>> type = categoryform.cleaned_data['**type']
>> )
>> event_public = categoryform.cleaned_data['**event_public']
>> event_genre = categoryform.cleaned_data['**event_genre']
>> category_obj.event_genre.add(**event_genre),
>> category_obj.event_public.add(**event_public),
>> # No need to call save here
>> # category_obj.save()
>
>
> The reason behind this is that M2M Fields are represented
> by intermediate tables with references to the two linked objects. If you
> need to add a row in it, both referenced objects should already be saved in
> the db with valid primary keys.
>
> H2H
> -Sandeep
>
>
> On Saturday, June 30, 2012 1:21:30 PM UTC+5:30, Nikhil Verma wrote:
>>
>> Hi All
>>
>> I have the following models like this :-
>>
>>
>> class EventGenre(models.Model):
>> genre_choices = models.CharField(max_length=**255)
>>
>> def __unicode__(self):
>> return self.genre_choices
>>
>> class EventPublic(models.Model):
>> choicelist = models.CharField(max_length=**255)
>>
>> def __unicode__(self):
>> return self.choicelist
>>
>> class Category(models.Model):
>> """
>> Describes the Event Category
>> """
>>
>> type = models.CharField(max_length=**20,\
>>   **choices=EVENT_TYPE,\
>>   **help_text = "type of event"
>>   **)
>> # Genre of event like classical,rock,pop ,indie etc
>> event_genre = models.ManyToManyField(**EventGenre)
>>
>> # audience for this event like adults ,children etc
>> event_public = models.ManyToManyField(**EventPublic)
>>
>> def __unicode__(self):
>> return self.type
>>
>> This is my category form
>>
>> class CategoryForm(forms.Form):
>> type = forms.CharField(max_length=80, \
>>widget=RadioSelect(choices=**EVENT_TYPE)
>>)
>> event_genre = forms.**ModelMultipleChoiceField(
>> queryset = EventGenre.objects.all(),
>> widget=CheckboxSelectMultiple,
>> required=False
>> )
>> event_public = forms.**ModelMultipleChoiceField(
>> queryset = EventPublic.objects.all(),**
>>
>> widget=CheckboxSelectMultiple,
>> required=False
>> )
>>
>> This is my views.py
>>
>> def eventcreation(request):
>> if request.method == "POST":
>> event_form = EventForm(request.POST,**request.FILES,prefix="**
>> eventform")
>> categoryform = CategoryForm(request.POST)
>> if event_form.is_valid():
>> event_obj = Event(
>> venue_name = event_form.cleaned_data['**venue_name'],
>> date_created = event_form.cleaned_data['**event_start_date'],
>> date_completed = event_form.cleaned_data['**event_end_date'],
>> event_ticket_price = event_form.cleaned_data['**
>> event_ticket_price'],
>> eventwebsite = event_form.cleaned_data['**eventwebsite'],
>> keyword = event_form.cleaned_data['**keyword'],
>> description = event_form.cleaned_data['**description'],
>> status = event_form.cleaned_data['**status'],
>> event_poster = event_form.cleaned_data['**event_poster']
>> )
>> if categoryform.is_valid():
>> category_obj = Category(
>> type = categoryform.cleaned_data['**type'],
>> event_public = categoryform.cleaned_data['**
>> event_public'], # It is giving error
>> event_genre = 
>> categoryform.cleaned_data['**event_genre'],
>> # It is giving error
>> )
>>
>> category_obj.event_genre.add(**event_genre),
>> category_obj.event_public.add(**event_public),
>> category_obj.save()
>>
>>
>> else:
>> print "Form is getting Invalid"
>> else:
>>
>> event_form = EventForm()
>> categoryform = CategoryForm()
>> return render_to_response('event/**event.html',
>>   {
>>   'eventform':event_form,
>>  

Re: advantages and disadvantages of Raw sql queries in django

2012-06-30 Thread Nick Apostolakis

On 30/06/2012 07:36 πμ, vijay shanker wrote:

hi
i want to know pros and cons associated with running raw sql queries
over django's ORM .
googled it out but couldn find many useful links.

   
At some point in the future you may find yourself in a position when you 
will need to change the underlying DB engine.

In these cases ORM is a life saver.

This scenario is not far-fetched it is very common actually. I use 
sqlite to develop my app, but in the production server I use mysql.

The code is the same, I have to change only 2 lines in settings.py
This makes development very easy and very portable.
I can reproduce my development environment in 10mins (with the use of 
pip and virtualenv of course) and start working in a new machine with 
minimum hassle.


--
 --
   Nick Apostolakis
  e-mail: nicka...@oncrete.gr
 Web Site: http://nick.oncrete.gr
 --


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



What kind of authorization I should use for my Django facebook app

2012-06-30 Thread surya
I am building a facebook application using Django where I am using Google 
Data API (Blogger API) to read website's content.

So, what kind of authorization I should use in Google Data API to read the 
website.. To be specific, what kind of OAuth authorization I should use and 
how? 
(I want my users to use my app without any login credentials)..

Can anyone help me on it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dwjcrkvB5xIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: invalid keyword argument for this function

2012-06-30 Thread Sunny Nanda
Hi Nikhil,

You can not use an object's M2M field until it has been saved to the db.
So, you would have to call the "save" method on the instance, or use 
"create" method to create the instance.

> category_obj = Category.objects.create(
> type = categoryform.cleaned_data['type']
> )
> event_public = categoryform.cleaned_data['event_public']
> event_genre = categoryform.cleaned_data['event_genre']
> category_obj.event_genre.add(event_genre),
> category_obj.event_public.add(event_public),
> # No need to call save here
> # category_obj.save() 


The reason behind this is that M2M Fields are represented 
by intermediate tables with references to the two linked objects. If you 
need to add a row in it, both referenced objects should already be saved in 
the db with valid primary keys.

H2H
-Sandeep

On Saturday, June 30, 2012 1:21:30 PM UTC+5:30, Nikhil Verma wrote:
>
> Hi All
>
> I have the following models like this :-
>
>
> class EventGenre(models.Model):
> genre_choices = models.CharField(max_length=255)
> 
> def __unicode__(self):
> return self.genre_choices
> 
> class EventPublic(models.Model):
> choicelist = models.CharField(max_length=255)
>
> def __unicode__(self):
> return self.choicelist
>
> class Category(models.Model):
> """
> Describes the Event Category
> """
> 
> type = models.CharField(max_length=20,\
>   choices=EVENT_TYPE,\
>   help_text = "type of event"
>   )
> # Genre of event like classical,rock,pop ,indie etc
> event_genre = models.ManyToManyField(EventGenre)
> 
> # audience for this event like adults ,children etc
> event_public = models.ManyToManyField(EventPublic)
> 
> def __unicode__(self):
> return self.type
>
> This is my category form
>
> class CategoryForm(forms.Form):
> type = forms.CharField(max_length=80, \
>widget=RadioSelect(choices=EVENT_TYPE)
>)
> event_genre = forms.ModelMultipleChoiceField(
> queryset = EventGenre.objects.all(),
> widget=CheckboxSelectMultiple,
> required=False
> )
> event_public = forms.ModelMultipleChoiceField(
> queryset = 
> EventPublic.objects.all(),  
> widget=CheckboxSelectMultiple,
> required=False
> )
>
> This is my views.py
>
> def eventcreation(request):
> if request.method == "POST":
> event_form = 
> EventForm(request.POST,request.FILES,prefix="eventform")
> categoryform = CategoryForm(request.POST)
> if event_form.is_valid():
> event_obj = Event(
> venue_name = event_form.cleaned_data['venue_name'],
> date_created = event_form.cleaned_data['event_start_date'],
> date_completed = event_form.cleaned_data['event_end_date'],
> event_ticket_price = 
> event_form.cleaned_data['event_ticket_price'],
> eventwebsite = event_form.cleaned_data['eventwebsite'],
> keyword = event_form.cleaned_data['keyword'],
> description = event_form.cleaned_data['description'],
> status = event_form.cleaned_data['status'],
> event_poster = event_form.cleaned_data['event_poster']
> )
> if categoryform.is_valid():
> category_obj = Category(
> type = categoryform.cleaned_data['type'],
> event_public = 
> categoryform.cleaned_data['event_public'], # It is giving error
> event_genre = 
> categoryform.cleaned_data['event_genre'],   # It is giving error
> )
> 
> category_obj.event_genre.add(event_genre),
> category_obj.event_public.add(event_public),
> category_obj.save()
> 
> 
> else:
> print "Form is getting Invalid"
> else:
>
> event_form = EventForm()
> categoryform = CategoryForm()
> return render_to_response('event/event.html',
>   {
>   'eventform':event_form,
>   'categoryform':categoryform,
>   },
>   context_instance=RequestContext(request)
>   )
> 
> I am trying to add a ManyToMany Field and gets this traceback :-
>
> Exception Type: TypeError at /event/createevent/
> Exception Value: 'event_public' is an invalid keyword argument for this 
> function
>
> Can anybody

Ajax images upload in django admin

2012-06-30 Thread Maksim Schepelin
Hi.
I need to do drag and drop images uploader for django admin.
I think take 
this(https://github.com/blueimp/jQuery-File-Upload)
 
as a basis. But don't understand how it use in django admin.
Perhabs, exists complete solutions for this task?
Will be glad for any help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/4HPIYdi1-O8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Use regular expression to retrieve all image tags from a given content

2012-06-30 Thread Sunny Nanda
You can try the following two suggestions:

1. Try removing the "^" from the pattern and match only r"
> Hello, 
>
> am really a noob with regular expressions, I tried to do this on my own 
> but I couldn't understand from the manuals how to approach it. Am trying to 
> find all img tags of a given content, I wrote the below but its returning 
> None
>
>  content = i.content[0].value
>
> prog = re.compile(r'^
> result = prog.match(content)
>
> print result
>
>
>  any suggestions?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/URj9ESCdOaYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Where I am wrong in loading static files ?

2012-06-30 Thread surya


On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
>
> On 22-6-2012 15:53, surya wrote: 
> > This is my project folder hierarchy: 
> > 
> > project \ 
> >project \ 
> >   __init__.py 
> >   settings.py 
> >   urls.py 
> >   views.py 
> >   ... etc 
> >templates \ 
> >css \ 
> > index_css.css 
> > 
> >media \ 
> >  logo.png 
> > 
> >templates \ 
> >  home.html 
> >manage.py 
> > 
> > 
> > So, these are the settings I made in "settings.py" 
> > 
> > currDir = os.path.dirname(__file__) 
> > templateDir_media = 
> > os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), 
> "media") 
> > templateDir_css = 
> > os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css") 
> > 
> > STATICFILES_DIRS = ( 
> > templateDir_media, 
> > templateDir_css, 
> > "d:/code/projects-dev/readdme/" 
> > ) 
> > ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT 
> > 
> > The HTML source file contains: 
> > 
> > Image URL:  src="../media/logo.png" 
> > CSS URL : href="../css/twoColFixLtHdr.css" 
>
> You're not using staticfiles, because they will always result in 
> absolute path references. Try starting with the documentation and let us 
> know what you don't understand about it: 
> https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/ 
>
> -- 
> Melvyn Sopacua 
>
>
>
Thanks Melvyn.. 

I could display photos on the template. But there is a problem.. 

when I am using *collectstatic* command, it is collecting all files and 
storing in project folder.

I mean, 

/

   (static files)

   manage.py

   /


Is there any way to avoid it??

*Another thing is, the files are not working with I am switching off debug 
mode (DEBUG = False). I searched on it and found that I need to use my own 
webserver for that. So, I'd like to use Apache Http but don't know how to 
configure it!! *
*
*
*Can you help me on it?*

 

On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
>
> On 22-6-2012 15:53, surya wrote: 
> > This is my project folder hierarchy: 
> > 
> > project \ 
> >project \ 
> >   __init__.py 
> >   settings.py 
> >   urls.py 
> >   views.py 
> >   ... etc 
> >templates \ 
> >css \ 
> > index_css.css 
> > 
> >media \ 
> >  logo.png 
> > 
> >templates \ 
> >  home.html 
> >manage.py 
> > 
> > 
> > So, these are the settings I made in "settings.py" 
> > 
> > currDir = os.path.dirname(__file__) 
> > templateDir_media = 
> > os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), 
> "media") 
> > templateDir_css = 
> > os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "css") 
> > 
> > STATICFILES_DIRS = ( 
> > templateDir_media, 
> > templateDir_css, 
> > "d:/code/projects-dev/readdme/" 
> > ) 
> > ## I JUST ADDED THOSE /MEDIA AND /CSS DIR IN IT 
> > 
> > The HTML source file contains: 
> > 
> > Image URL:  src="../media/logo.png" 
> > CSS URL : href="../css/twoColFixLtHdr.css" 
>
> You're not using staticfiles, because they will always result in 
> absolute path references. Try starting with the documentation and let us 
> know what you don't understand about it: 
> https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/ 
>
> -- 
> Melvyn Sopacua 
>
>
>
On Friday, June 22, 2012 9:44:59 PM UTC+5:30, Melvyn Sopacua wrote:
>
> On 22-6-2012 15:53, surya wrote: 
> > This is my project folder hierarchy: 
> > 
> > project \ 
> >project \ 
> >   __init__.py 
> >   settings.py 
> >   urls.py 
> >   views.py 
> >   ... etc 
> >templates \ 
> >css \ 
> > index_css.css 
> > 
> >media \ 
> >  logo.png 
> > 
> >templates \ 
> >  home.html 
> >manage.py 
> > 
> > 
> > So, these are the settings I made in "settings.py" 
> > 
> > currDir = os.path.dirname(__file__) 
> > templateDir_media = 
> > os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), 
> "media") 
> > templateDir_css = 
> > os.path.join(os.path.join(os.path.split(currDir)[0],"Templates"), "c

Re: Testing with LiveServerTestCase and Selenium

2012-06-30 Thread Rafael Durán Castañeda

El 28/06/12 15:45, Paul Childs escribió:

Hello,
I'm using Django 1.4 and was really excited to learn about the new 
testing features. I am totally new to this.
I seem to have hit a bump in the road. If I overcome this I'm hopeful 
it will be smooth sailing and I will experience some great testing 
goodness.
I've been mucking around with this all morning and I can't seem to get 
the selenium Firefox webdriver to navigate to the given URL.


I have read the docs:
https://docs.djangoproject.com/en/1.4/topics/testing/#django.test.LiveServerTestCase 


and read this tutorial
http://www.tdd-django-tutorial.com/tutorial/1/
and tried to run the test code that they suggest.

When I run the very simple test:

from django.test import LiveServerTestCase
from selenium import webdriver

class MySeleniumTests(LiveServerTestCase):
fixtures = ['lookups_security.json']

def setUp(self):
self.browser = webdriver.Firefox()

def tearDown(self):
self.browser.quit()

def test_login(self):
# Gertrude opens her web browser, and goes to the admin page
self.browser.get(self.live_server_url + '/admin/login/')

# She sees the familiar 'Django administration' heading
body = self.browser.find_element_by_tag_name('body')
self.assertIn('CISSIMP Admin', body.text)

A blank Firefox browser pops up, sits there and then closes.

The test output is:

(sitar_env2) C:\virtual_env\sitar_env2\cissimp>python manage.py test 
--liveserver=localhost:8082 sitar

Creating test database for alias 'default'...
E
==
ERROR: test_login (sitar.tests.MySeleniumTests)
--
Traceback (most recent call last):
  File "C:\virtual_env\sitar_env2\cissimp\sitar\tests.py", line 54, in 
test_login

self.assertIn('CISSIMP Admin', body.text)
AttributeError: 'NoneType' object has no attribute 'text'

--
Ran 1 test in 22.546s

FAILED (errors=1)
Destroying test database for alias 'default'...

It seems obvious that the browser is not navigating to the URL I want 
so the code is trying to get a reference to an non-existent body tag.


Can anyone see what I am doing wrong?

Thanks
/Paulr
--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/jh47T9WA7QkJ.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


The error is quite obvious, body is None and thus it doesn't have 'text' 
attribute, why body is None is not so obvious since I think selenium 
should raise NoSuchElementExceptionif it can't find the body tag, no 
tjust returning None. When you manually browse the url, what do you get? 
is the body tag there or are your getting a blank page?


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