Re: admin panel adding left-right panel

2012-07-02 Thread Sunny Nanda
You can specify a 'filter-horizontal' tuple in the admin model declaration: 
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_horizontal
 

-Sandeep

On Monday, July 2, 2012 6:56:07 PM UTC+5:30, ledzgio wrote:
>
> In default admin panel, under group permissions, I saw a double panels 
> where I can add an element from the left list panel to the right one 
> instead of selecting multiple elements by holding CTRL. I would like to 
> have this panel implementation in my admin with my models, how can I do 
> that?
>
> thanks
>

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



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 <varma.nikhi...@gmail.com>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

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_d

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 

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: how to manage range of hours in models and forms in django1.4

2012-06-29 Thread Sunny Nanda
One way to store such information can be like this:
Create a model "Day". This will hold entries for each day i.e. from Monday 
till Sunday
In the UserProfile model, create a ManyToMany relation to the above defined 
Day model through an intermediate table (say WorkingHours) which can hold 
the "from" and "to" time.

Partial example below:

class UserProfile(models.Model):
> working_hours = models.ManyToManyField("Day", through="WorkingHours")
>
> class WorkingHours(models.Model)
> profile = models.ForeignKey("UserProfile")
> day = models.ForeignKey("Day")
> from_time = models.**TimeField()
> to_time = models.**TimeField()
>

While creating the forms, take input from the user for the WorkingHours 
model. This way, the days of work will not be hardcoded, and user can 
select mutiple choices.

Regards,
Sandeep


On Friday, June 29, 2012 10:16:47 AM UTC+5:30, Nikhil Verma wrote:
>
>
> Hi
>
> I am developing an event app which has users who publish events , other 
> users also.
> Now users have their profile info for which i have made a very common 
> UserProfile Model with all the necessary details in it.
>
> I have a requirement where in UserProfile model i need to display a field 
> institue_hours_of_operation( no. of hours that an institute works)
>
>
> class UserProfile(models.Model):
> user = models.ForeignKey(User, blank=True, null=True, unique=True)
> first_name = models.CharField(max_length=30, blank=True)
> last_name = models.CharField(max_length=30, blank=True)
> gender = models.CharField(max_length=1, choices=GENDER_CHOICES, 
> blank=True)
> birth_date = models.DateField(auto_now_add=True)
> street_address = models.CharField(max_length=75, blank=True)
> city = models.CharField(max_length=30, blank=True)
> zip_code = models.IntegerField(max_length=7, blank=True, null=True)
> country = models.CharField(max_length=30, blank=True)
> mobile = models.CharField(max_length=15, blank=True)
> home_phone = models.CharField(max_length=15, blank=True)
> primary_email = models.EmailField(max_length=60, blank=True)
> secondary_email = models.EmailField(max_length=60, blank=True)
> institution_name = 
> models.CharField(max_length=100,blank=True,null=True)
> institution_website = 
> models.CharField(max_length=100,blank=True,null=True)
>
>
> # Field to be added
>
> It will be displayed in html like this
>
> Insitutue hour of operation :   Monday  9.00 - 17.00 (Monday will be 
> hardcoded,Time will be filled by user)
>   Tuesday 9.00 - 17.00 
> (Monday will be hardcoded,Time will be filled by user)
>
>and so on
>
> # Note the weekdays like monday,  tuesday they are all hardcoded as 
> requirement but i don't want that to be hardcoded. 
> Also i am using a django forms  to display this.
>
>
> How can i design this form field as well in models or What should be the 
> type of this field both in models and forms such that weekdays remain 
> dynamic(i can simply generate them from loop) and the user can fill the 
> time  and when he hits submit it will get saved.
>
>
> Thanks 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/N2ArPbWtQmYJ.
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.