Re: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread donarb
At this point, I would just skip trying to load the data through Django and 
write a quick Python script to load the data using INSERT statements or create 
a bulk data file to load it directly into MySQL. I'm not as familiar with MySQL 
as I am with Postgres, but Postgres can swallow a whole data file and rollback 
the transaction should it find invalid data in a row. I'm guessing MySQL can do 
something similar.

-- 
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/-/B4RwpUtco8wJ.
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: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread Sam Raker
I've also tried changing the charset and collation options in my MySQL 
tables. Still no good. I'm so stumped. Can anyone help me, please?

On Sunday, December 30, 2012 8:54:44 PM UTC-5, Sam Raker wrote:
>
> I tried changing my backend to django-mysql-pymysql (
> http://pypi.python.org/pypi/django-mysql-pymysql/0.1), and that didn't 
> work either. I'm really at my wits' end. Can anyone help?
>
> On Sunday, December 30, 2012 4:21:57 PM UTC-5, Sam Raker wrote:
>>
>> I just tried both of those things, and the YAML data loaded fine, and 
>> validate said I had 0 errors.
>>
>> Any other suggestions? I'm really stumped here.
>>
>> On Sun, Dec 30, 2012 at 3:35 PM, donarb  wrote:
>>
>>>
>>>
>>> On Sunday, December 30, 2012 11:58:46 AM UTC-8, Sam Raker wrote:

 So I upped the verbosity like you said, and basically all it got me was 
 a bunch of text telling me all the places Django didn't find my fixture 
 before it finally did, and then the same error. Here's the full text of 
 the 
 error:

 Traceback (most recent call last):
   File "/home/menusadmin/.pythonbrew/**pythons/Python-2.7.3/lib/**
 python2.7/site-packages/**django/core/management/**commands/loaddata.py", 
 line 190, in handle
 for obj in objects:
   File "/home/menusadmin/.pythonbrew/**pythons/Python-2.7.3/lib/**
 python2.7/site-packages/**django/core/serializers/**pyyaml.py", line 
 62, in Deserializer
 raise DeserializationError(e)
 DeserializationError: maximum recursion depth exceeded while calling a 
 Python object

 I tried changing commit to False in loaddata.py, I tried adding a 
 manager class to the one model I have that another model refers to with a 
 natural key (e.g., 'name,' a CharField, as opposed to the primary key). I 
 read something about loaddata having some unicode-related problems, so I 
 added custom Manager classes for all my models that coerce appropriate 
 fields to strings, e.g.:

 class MenuManager(models.Manager):
 def create_Menu(self,restaurant,**year,location,status,pk,**
 period,language):
 menu = self.create(restaurant=str(**restaurant),year=int(year),**
 location=str(location),status=**str(status),pk=int(pk),period=**
 str(period),language=str(**language))
  return menu

 I'm still getting the exact same error. Help?

>>>  
>>> Then the next thing I'd do is to test the yml data itself, separate from 
>>> Django to make sure that the data is not corrupted in any way. Run a script 
>>> like this, if it passes, then you probably have some sort of error in your 
>>> models that is recursive.
>>>
>>> *#!/usr/bin/env python*
>>> *
>>> *
>>> *import yaml*
>>> *
>>> *
>>> *stream = open("test.yml", "r")*
>>> *print yaml.load(stream)*
>>>
>>>
>>> Finally, I'd run
>>>
>>> *./manage.py validate*
>>>
>>>
>>> to make sure that all of your models are valid.
>>>
>>>  
>>>
>>> -- 
>>> 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/-/WoMoRX8i3DsJ.
>>>
>>> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hTw0AXF02WEJ.
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 method all() in overrided models.Manager doesn't works as expected

2012-12-30 Thread Shuge Lee


I'm writing a simple CMS, it stores page file data on local file system 
instead of SQL server.

I do overrides the model Page's Manager, but it not works as expected, 
problems

   - PageManager.all(it calls PageQuerySet?) doesn't works
   - I can create Page object in Admin, but can't view it or delete it

Source code is here 
https://github.com/shuge/mcms/blob/master/pages/models.py

I have read Django Manager 
docs a 
couple of times, but it doesn't help.

Thanks for reply.

-- 
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/-/Rm6OnBOI22cJ.
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: Unable to get an object value using get method in Django

2012-12-30 Thread coded kid
Yeah, its a name of a field in my form.  I want to the value
automatically since I don't know the name of the place the user will
choose. I tried adding your correction but i'm getting error.

On Dec 31, 2:33 am, Bill Freeman  wrote:
> On Sun, Dec 30, 2012 at 7:11 PM, coded kid  wrote:
> > I want to get an object value from a model. After trying the get()
> > method, I've been unable to make it work.And I'm getting the below
> > error. I have a page that display the name of a place to users, so if
> > a user see a place he likes, he will go ahead and fill the form.And in
> > the form, I want to get the name of the place automatically from
> > another model, I don't want users to fill the name of the place. Below
> > are my codes
>
> > NameError at /welcome/
>
> >        global name 'name' is not defined
>
> > Models
>
> >  class Fin(models.Model):
> >       user=models.ForeignKey(User)
> >       name=models.CharField(max_length=100)
>
> >       def __unicode__(self):
> >           return self.user
>
> >  class Place(models.Model):
> >       user=models.ForeignKey(User)
> >       mall=models.ForeignKey(Fin)
> >       full_name=models.CharField(max_length=100)
> >       e_mail=models.EmailField(max_length=100)
> >       phone_no=models.CharField(max_length=100)
> >       pub_date=models.DateTimeField()
>
> >       def __unicode__(self):
> >           return self.full_name
> >       class Meta:
> >          ordering=['-pub_date']
>
> >   class PlaceForm(ModelForm):
> >        class Meta:
> >          model=Place
> >          fields=('full_name','e_mail','phone_no')
> >          exclude=('user','pub_date','mall')
>
> > Views:
>
> >    def place_me(request):
> >        if request.method=="POST":
> >           form=PlaceForm(request.POST)
> >           if form.is_valid():
> >              data=form.cleaned_data
> >              newbooks=Place(
> >                  user=request.user,
> >                  pub_date=datetime.datetime.now(),
> >                  mall=Fin.objects.get(name),
> >                  full_name=data['full_name'],
> >                  e_mail=data['e_mail'],
> >                  phone_no=data['phone_no'])
> >              newbooks.save()
> >              return HttpResponse('Thanks for choosing themall, we will
> > contact you as soon as possible.')
> >          else:
> >             return HttpResponse('Some fields are not filled
> > correctly')
> >      else:
> >         return render_to_response('buuk.html',
> > {'PlaceForm':PlaceForm},context_instance=RequestContext(request))
>
> > Perhaps you want:
>
>    mail=Fin.objects.get(name="something")
>
> Where I'm not sure what "something" is.  A field from your form, perhaps?
>
> Bill

-- 
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: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread Sam Raker
I tried changing my backend to django-mysql-pymysql 
(http://pypi.python.org/pypi/django-mysql-pymysql/0.1), and that didn't 
work either. I'm really at my wits' end. Can anyone help?

On Sunday, December 30, 2012 4:21:57 PM UTC-5, Sam Raker wrote:
>
> I just tried both of those things, and the YAML data loaded fine, and 
> validate said I had 0 errors.
>
> Any other suggestions? I'm really stumped here.
>
> On Sun, Dec 30, 2012 at 3:35 PM, donarb  wrote:
>
>>
>>
>> On Sunday, December 30, 2012 11:58:46 AM UTC-8, Sam Raker wrote:
>>>
>>> So I upped the verbosity like you said, and basically all it got me was 
>>> a bunch of text telling me all the places Django didn't find my fixture 
>>> before it finally did, and then the same error. Here's the full text of the 
>>> error:
>>>
>>> Traceback (most recent call last):
>>>   File "/home/menusadmin/.pythonbrew/**pythons/Python-2.7.3/lib/**
>>> python2.7/site-packages/**django/core/management/**commands/loaddata.py", 
>>> line 190, in handle
>>> for obj in objects:
>>>   File "/home/menusadmin/.pythonbrew/**pythons/Python-2.7.3/lib/**
>>> python2.7/site-packages/**django/core/serializers/**pyyaml.py", line 
>>> 62, in Deserializer
>>> raise DeserializationError(e)
>>> DeserializationError: maximum recursion depth exceeded while calling a 
>>> Python object
>>>
>>> I tried changing commit to False in loaddata.py, I tried adding a 
>>> manager class to the one model I have that another model refers to with a 
>>> natural key (e.g., 'name,' a CharField, as opposed to the primary key). I 
>>> read something about loaddata having some unicode-related problems, so I 
>>> added custom Manager classes for all my models that coerce appropriate 
>>> fields to strings, e.g.:
>>>
>>> class MenuManager(models.Manager):
>>> def create_Menu(self,restaurant,**year,location,status,pk,**
>>> period,language):
>>> menu = self.create(restaurant=str(**restaurant),year=int(year),**
>>> location=str(location),status=**str(status),pk=int(pk),period=**
>>> str(period),language=str(**language))
>>>  return menu
>>>
>>> I'm still getting the exact same error. Help?
>>>
>>  
>> Then the next thing I'd do is to test the yml data itself, separate from 
>> Django to make sure that the data is not corrupted in any way. Run a script 
>> like this, if it passes, then you probably have some sort of error in your 
>> models that is recursive.
>>
>> *#!/usr/bin/env python*
>> *
>> *
>> *import yaml*
>> *
>> *
>> *stream = open("test.yml", "r")*
>> *print yaml.load(stream)*
>>
>>
>> Finally, I'd run
>>
>> *./manage.py validate*
>>
>>
>> to make sure that all of your models are valid.
>>
>>  
>>
>> -- 
>> 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/-/WoMoRX8i3DsJ.
>>
>> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/f9YJ8yh-F0IJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django jQuery AJAX Self Replacing Script

2012-12-30 Thread That guy
EDITs made to orginal but same issue.

On Sunday, December 30, 2012 5:16:17 PM UTC-8, That guy wrote:
>
>Hello,
>
>
> I've been having trouble implementing a self-replacing script. I admit 
> that I am terribly confused.
>
> I am trying to implement two buttons such that if you click on one, a POST 
> request is sent to the server; the server validates that you indeed went to 
> this webpage and sends back a HttpResponseRedirect to a page containing an 
> incomplete web-page/a page that has only the portions I want updated after 
> the button is clicked. Once my orginal jQuery request receives that new 
> page, it will replace the elements on current the page with the new one it 
> just received. 
>
> My jQuery looks like:
>
> 
> $(document).ready(function() {  
>   $('#button1').click(function(){
> $.post("/", { 
>   unique_id : "{{ unique_id }}",
>   csrfmiddlewaretoken: '{{ csrf_token }}'
> },
> function(data){
>var js_portion = $('
').html(data).find('self_replacing') >var html_portion = $('
').html(data).find('pic_content') >$('#pic_content').replaceWith(html_portion) >$('#self_replacing').replaceWith(js_portion) > }); > });}); > > Incomplete Page: > > > $(document).ready(function() { > $('#button1').click(function(){ > $.post("/", { > unique_id : "{{ unique_id }}", > csrfmiddlewaretoken: '{{ csrf_token }}' > }, > function(data){ >var js_portion = $('
').html(data).find('self_replacing') >var html_portion = $('
').html(data).find('pic_content') >$('#pic_content').replaceWith(html_portion) >$('#self_replacing').replaceWith(js_portion) > }); > });}); > . > . > > > Do I have the right idea? When I watch my requests through the FireBug > console, the traffic begins scaling upward everytime the button is clicked. > > For instance at the start, it beings with 1 click = 1 POST then 1 click = > 2POST, and then 1 click = 3 POST. I'm not too sure why this is happening. > Is there something wrong with my jQuery script? > > Note: The jQuery script needs to be updated after each POST too. > > > Thank You for any help you can provide :) > -- 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/-/wVV36UrowMIJ. 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: Unable to get an object value using get method in Django

2012-12-30 Thread Bill Freeman
On Sun, Dec 30, 2012 at 7:11 PM, coded kid  wrote:

> I want to get an object value from a model. After trying the get()
> method, I've been unable to make it work.And I'm getting the below
> error. I have a page that display the name of a place to users, so if
> a user see a place he likes, he will go ahead and fill the form.And in
> the form, I want to get the name of the place automatically from
> another model, I don't want users to fill the name of the place. Below
> are my codes
>
> NameError at /welcome/
>
>global name 'name' is not defined
>
> Models
>
>  class Fin(models.Model):
>   user=models.ForeignKey(User)
>   name=models.CharField(max_length=100)
>
>   def __unicode__(self):
>   return self.user
>
>
>  class Place(models.Model):
>   user=models.ForeignKey(User)
>   mall=models.ForeignKey(Fin)
>   full_name=models.CharField(max_length=100)
>   e_mail=models.EmailField(max_length=100)
>   phone_no=models.CharField(max_length=100)
>   pub_date=models.DateTimeField()
>
>   def __unicode__(self):
>   return self.full_name
>   class Meta:
>  ordering=['-pub_date']
>
>   class PlaceForm(ModelForm):
>class Meta:
>  model=Place
>  fields=('full_name','e_mail','phone_no')
>  exclude=('user','pub_date','mall')
>
> Views:
>
>def place_me(request):
>if request.method=="POST":
>   form=PlaceForm(request.POST)
>   if form.is_valid():
>  data=form.cleaned_data
>  newbooks=Place(
>  user=request.user,
>  pub_date=datetime.datetime.now(),
>  mall=Fin.objects.get(name),
>  full_name=data['full_name'],
>  e_mail=data['e_mail'],
>  phone_no=data['phone_no'])
>  newbooks.save()
>  return HttpResponse('Thanks for choosing themall, we will
> contact you as soon as possible.')
>  else:
> return HttpResponse('Some fields are not filled
> correctly')
>  else:
> return render_to_response('buuk.html',
> {'PlaceForm':PlaceForm},context_instance=RequestContext(request))
>
>
>
> Perhaps you want:

   mail=Fin.objects.get(name="something")

Where I'm not sure what "something" is.  A field from your form, perhaps?

Bill

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



Django jQuery AJAX Self Replacing Script

2012-12-30 Thread That guy
Hello,
   

I've been having trouble implementing a self-replacing script. I admit that 
I am terribly confused.

I am trying to implement two buttons such that if you click on one, a POST 
request is sent to the server; the server validates that you indeed went to 
this webpage and sends back a HttpResponseRedirect to a page containing an 
incomplete web-page/a page that has only the portions I want updated after 
the button is clicked. Once my orginal jQuery request receives that new 
page, it will replace the elements on current the page with the new one it 
just received. 

My jQuery looks like:


$(document).ready(function() {  
  $('#button1').click(function(){
$.post("/", { 
  unique_id : "{{ unique_id }}",
  csrfmiddlewaretoken: '{{ csrf_token }}'
},
function(data){
   var js_portion = $('
').html(data).find('self_replacing') var html_portion = $('
').html(data).find('pic_content') $('pic_content').replaceWith(html_portion) $('self_replacing').replaceWith(js_portion) }); });}); Incomplete Page: $(document).ready(function() { $('#button1').click(function(){ $.post("/", { unique_id : "{{ unique_id }}", csrfmiddlewaretoken: '{{ csrf_token }}' }, function(data){ var js_portion = $('
').html(data).find('self_replacing') var html_portion = $('
').html(data).find('pic_content') $('pic_content').replaceWith(html_portion) $('self_replacing').replaceWith(js_portion) }); });}); . . Do I have the right idea? When I watch my requests through the FireBug console, the traffic begins scaling upward everytime the button is clicked. For instance at the start, it beings with 1 click = 1 POST then 1 click = 2POST, and then 1 click = 3 POST. I'm not too sure why this is happening. Is there something wrong with my jQuery script? Note: The jQuery script needs to be updated after each POST too. Thank You for any help you can provide :) -- 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/-/CtKkoK1_vtAJ. 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: Star Rating System In Django

2012-12-30 Thread coded kid
Thanks! Agon works perfectly!

On Sunday, 30 December 2012 14:46:24 UTC+1, coded kid wrote:
>
> The developer for agon rating is no more working on it and I guess it 
> won't work nice .
>
> Simple ratings is not working out for me. Don't know if there's a 
> JavaScript plugin for rating?
>
> On Sunday, 30 December 2012 14:08:10 UTC+1, Alec Taylor wrote:
>>
>> Agon (probably easiest): 
>> http://agon-ratings.readthedocs.org/en/latest/usage.html 
>>
>> -or- 
>>
>> https://github.com/dcramer/django-ratings 
>>
>> -or- 
>>
>> https://github.com/coleifer/django-simple-ratings 
>>
>> On Mon, Dec 31, 2012 at 12:03 AM, coded kid  wrote: 
>> > Anyone know about any good package or tutorial or plugin for building 
>> > a star rating system in django? I tried using dcramer/django rating 
>> > but It's not working perfectly. 
>> > 
>> > If you know of any plugin, package on how to build a star rating 
>> > system, kindly post it below. 
>> > 
>> > Thanks! 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups "Django users" group. 
>> > To post to this group, send email to django...@googlegroups.com. 
>> > To unsubscribe from this group, send email to 
>> django-users...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fTgXj2iqSf0J.
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.



Unable to get an object value using get method in Django

2012-12-30 Thread coded kid
I want to get an object value from a model. After trying the get()
method, I've been unable to make it work.And I'm getting the below
error. I have a page that display the name of a place to users, so if
a user see a place he likes, he will go ahead and fill the form.And in
the form, I want to get the name of the place automatically from
another model, I don't want users to fill the name of the place. Below
are my codes

NameError at /welcome/

   global name 'name' is not defined

Models

 class Fin(models.Model):
  user=models.ForeignKey(User)
  name=models.CharField(max_length=100)

  def __unicode__(self):
  return self.user


 class Place(models.Model):
  user=models.ForeignKey(User)
  mall=models.ForeignKey(Fin)
  full_name=models.CharField(max_length=100)
  e_mail=models.EmailField(max_length=100)
  phone_no=models.CharField(max_length=100)
  pub_date=models.DateTimeField()

  def __unicode__(self):
  return self.full_name
  class Meta:
 ordering=['-pub_date']

  class PlaceForm(ModelForm):
   class Meta:
 model=Place
 fields=('full_name','e_mail','phone_no')
 exclude=('user','pub_date','mall')

Views:

   def place_me(request):
   if request.method=="POST":
  form=PlaceForm(request.POST)
  if form.is_valid():
 data=form.cleaned_data
 newbooks=Place(
 user=request.user,
 pub_date=datetime.datetime.now(),
 mall=Fin.objects.get(name),
 full_name=data['full_name'],
 e_mail=data['e_mail'],
 phone_no=data['phone_no'])
 newbooks.save()
 return HttpResponse('Thanks for choosing themall, we will
contact you as soon as possible.')
 else:
return HttpResponse('Some fields are not filled
correctly')
 else:
return render_to_response('buuk.html',
{'PlaceForm':PlaceForm},context_instance=RequestContext(request))

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



Re: Problem with auto tests Get an error creating the test database: (1044, "Access denied for user 'viewbank_django'@'localhost' to database 'test_viewbank_django'")

2012-12-30 Thread Jeff
Thanks Ryan,

That almost worked. The first run of the test script failed with the same 
error, but if I create the database from the mysql client in the server 
control panel, the script then asks if you want to delete the database and 
then continues and runs the tests.

Also the test database is not destroyed by the script when it finishes 
running.

So while not perfect it does seem to work ok.

Again thanks
Jeff

On Sunday, December 30, 2012 3:02:25 AM UTC+8, Ryan Blunden wrote:
>
> Hey Jeff,
>
> There sure is. Just specify a "TEST_NAME" key in the database 
> configuration dictionary and you're good to go.
>
>
> https://docs.djangoproject.com/en/dev/topics/testing/overview/#the-test-database
>
> Cheers,
> Ryan
>
> On 29/12/2012, at 7:27 AM, Jeff > wrote:
>
> When I run the command - "python manage.py test polls" I get the following 
> error - error creating the test database: (1044, "Access denied for user 
> 'viewbank_django'@'localhost' to database 'test_viewbank_django'")
>
> I am using a shared server that will only allow me to create a database 
> prefixed with viewbank_.
>
> Using the MYSQL client I can create viewbank_django_test or any variation 
> I like as long as it starts with viewbank_.
>
> Is there a way to change the way django names the test database?
>
> Thanks in advance
> Jeff
>
> -- 
> 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/-/oxBvQnPWaJgJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sV0vQOFbcacJ.
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: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread Sam Raker
I just tried both of those things, and the YAML data loaded fine, and
validate said I had 0 errors.

Any other suggestions? I'm really stumped here.

On Sun, Dec 30, 2012 at 3:35 PM, donarb  wrote:

>
>
> On Sunday, December 30, 2012 11:58:46 AM UTC-8, Sam Raker wrote:
>>
>> So I upped the verbosity like you said, and basically all it got me was a
>> bunch of text telling me all the places Django didn't find my fixture
>> before it finally did, and then the same error. Here's the full text of the
>> error:
>>
>> Traceback (most recent call last):
>>   File "/home/menusadmin/.pythonbrew/**pythons/Python-2.7.3/lib/**
>> python2.7/site-packages/**django/core/management/**commands/loaddata.py",
>> line 190, in handle
>> for obj in objects:
>>   File "/home/menusadmin/.pythonbrew/**pythons/Python-2.7.3/lib/**
>> python2.7/site-packages/**django/core/serializers/**pyyaml.py", line 62,
>> in Deserializer
>> raise DeserializationError(e)
>> DeserializationError: maximum recursion depth exceeded while calling a
>> Python object
>>
>> I tried changing commit to False in loaddata.py, I tried adding a manager
>> class to the one model I have that another model refers to with a natural
>> key (e.g., 'name,' a CharField, as opposed to the primary key). I read
>> something about loaddata having some unicode-related problems, so I added
>> custom Manager classes for all my models that coerce appropriate fields to
>> strings, e.g.:
>>
>> class MenuManager(models.Manager):
>> def create_Menu(self,restaurant,**year,location,status,pk,**
>> period,language):
>> menu = self.create(restaurant=str(**restaurant),year=int(year),**
>> location=str(location),status=**str(status),pk=int(pk),period=**
>> str(period),language=str(**language))
>>  return menu
>>
>> I'm still getting the exact same error. Help?
>>
>
> Then the next thing I'd do is to test the yml data itself, separate from
> Django to make sure that the data is not corrupted in any way. Run a script
> like this, if it passes, then you probably have some sort of error in your
> models that is recursive.
>
> *#!/usr/bin/env python*
> *
> *
> *import yaml*
> *
> *
> *stream = open("test.yml", "r")*
> *print yaml.load(stream)*
>
>
> Finally, I'd run
>
> *./manage.py validate*
>
>
> to make sure that all of your models are valid.
>
>
>
> --
> 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/-/WoMoRX8i3DsJ.
>
> 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: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread donarb


On Sunday, December 30, 2012 11:58:46 AM UTC-8, Sam Raker wrote:
>
> So I upped the verbosity like you said, and basically all it got me was a 
> bunch of text telling me all the places Django didn't find my fixture 
> before it finally did, and then the same error. Here's the full text of the 
> error:
>
> Traceback (most recent call last):
>   File 
> "/home/menusadmin/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/django/core/management/commands/loaddata.py",
>  
> line 190, in handle
> for obj in objects:
>   File 
> "/home/menusadmin/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/django/core/serializers/pyyaml.py",
>  
> line 62, in Deserializer
> raise DeserializationError(e)
> DeserializationError: maximum recursion depth exceeded while calling a 
> Python object
>
> I tried changing commit to False in loaddata.py, I tried adding a manager 
> class to the one model I have that another model refers to with a natural 
> key (e.g., 'name,' a CharField, as opposed to the primary key). I read 
> something about loaddata having some unicode-related problems, so I added 
> custom Manager classes for all my models that coerce appropriate fields to 
> strings, e.g.:
>
> class MenuManager(models.Manager):
> def create_Menu(self,restaurant,year,location,status,pk,period,language):
> menu = 
> self.create(restaurant=str(restaurant),year=int(year),location=str(location),status=str(status),pk=int(pk),period=str(period),language=str(language))
>  return menu
>
> I'm still getting the exact same error. Help?
>
 
Then the next thing I'd do is to test the yml data itself, separate from 
Django to make sure that the data is not corrupted in any way. Run a script 
like this, if it passes, then you probably have some sort of error in your 
models that is recursive.

*#!/usr/bin/env python*
*
*
*import yaml*
*
*
*stream = open("test.yml", "r")*
*print yaml.load(stream)*


Finally, I'd run

*./manage.py validate*


to make sure that all of your models are valid.

 

-- 
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/-/WoMoRX8i3DsJ.
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: Actions after logout

2012-12-30 Thread Bill Freeman
Michael,

How will the server know that they user has logged out?  If by clicking a
logout link or button, fine, you can capture that and delete the data.

But it sounds like you also want to do this when the user "leaves the
page".  That is much harder.  The user's browser does not tell the server
when the user leaves the page.  So the server normally doesn't know that
the user has left the page (or closed his browser, or shut down his
computer).

It is possible to have JavaScript, which runs on the browser, send a
"heartbeat" AJAX request to the server at regular intervals, so the server
could assume that the user has "left the page" if after some amount of
time, longer than the specified interval, it has not received such a
request.  This is pretty messy, and won't work if JavaScript is not
available in the user's browser.  It requires a process, one that is
independent of Django receiving a request, to look at all such partial data
sets, find the time that the JavaScript last contacted the server, and
delete the data if it was too long ago.  You must have the timestamp of the
AJAX access stored somewhere that persists between requests, either in the
database with the data, or on the session (which can still wind up in the
database).  So for each AJAX "ping" you have not only a request/response
pair on the network, but a database access.  Also, your choice of interval
must take into account that the user may have a very slow link, and that
the network may be temporarily overloaded.

A more common way to expire partially completed form sequence data is to
store a timestamp with the model collecting the data at each request that
changes it (form submission).  Then limit the time allowed between steps,
again using a background process that runs periodically to see if there are
incomplete data sets whose last change time is longer ago than you allow
per step, and if so, delete them.  Note that the time for a deletion to
happen can be up to the sum of the allowed time and the period between
runnings of the background task.  I have implemented this technique with
rather long timeouts, running the background task once per day, but you can
run it more often, at the expense of additional database traffic and server
load.  Consider that your user may be called away to answer a phone call or
some other urgency, and provide a reasonably long timeout.

A final approach is to not store any data, but return it to the browser in
hidden fields of the next from.  This is fine if you are simply breaking
things into steps for the purposes of presenting the user with an interface
organized as bite sized pieces, but if you need to reserve something in an
earlier step, e.g.; a user name during a sign up sequence, then you must
make the reservation in the database.

Bill

On Sun, Dec 30, 2012 at 1:35 PM, r4m <4thegdl...@googlemail.com> wrote:

> Hallo Ryan,
>
> thank you for your advice.
> What I meant by process is that I've developed a APP user can insert
> data on 4 forms. If they do not complete them on the fourth form, I
> want to delete the data after logout our leaving the page.
>
> Greetings,
> Michael
>
> On Sat 29 Dec 2012 08:25:26 PM CET, Ryan Blunden wrote:
> > When you say you haver a "process in place", do you mean code sitting
> > in a file?
> >
> > If you haven't already, create a logout url and hook it up to your
> > code to delete the log out data. Then just call
> > *django.contrib.auth.logout() *somewhere in your logout view.
> >
> > Cheers,
> > Ryan
> >
> > On 27/12/2012, at 6:50 AM, 4 The good Life we work
> > <4thegdl...@googlemail.com > wrote:
> >
> >> Hallo,
> >>
> >> I would like to delete certain data + login data after logout.
> >>
> >> I have a process in place and would like to delete the
> >> data inserted if the process is not followed to the last step.
> >>
> >> Thanks for your support,
> >> Michael
> >>
> >> --
> >> 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 e

Re: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread Sam Raker
So I upped the verbosity like you said, and basically all it got me was a
bunch of text telling me all the places Django didn't find my fixture
before it finally did, and then the same error. Here's the full text of the
error:

Traceback (most recent call last):
  File
"/home/menusadmin/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/django/core/management/commands/loaddata.py",
line 190, in handle
for obj in objects:
  File
"/home/menusadmin/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/django/core/serializers/pyyaml.py",
line 62, in Deserializer
raise DeserializationError(e)
DeserializationError: maximum recursion depth exceeded while calling a
Python object

I tried changing commit to False in loaddata.py, I tried adding a manager
class to the one model I have that another model refers to with a natural
key (e.g., 'name,' a CharField, as opposed to the primary key). I read
something about loaddata having some unicode-related problems, so I added
custom Manager classes for all my models that coerce appropriate fields to
strings, e.g.:

class MenuManager(models.Manager):
def create_Menu(self,restaurant,year,location,status,pk,period,language):
menu =
self.create(restaurant=str(restaurant),year=int(year),location=str(location),status=str(status),pk=int(pk),period=str(period),language=str(language))
return menu

I'm still getting the exact same error. Help?
On Sun, Dec 30, 2012 at 1:28 PM, donarb  wrote:

> On Sunday, December 30, 2012 9:54:45 AM UTC-8, Sam Raker wrote:
>>
>> Thanks for your suggestions.
>>
>> I eliminated the underscores and got rid of the __unicode__ methods
>> entirely, cleaned up my except statement, and changed the order of stuff
>> such that all of each model's fields are defined before any methods. (As
>> for the pk field: The csvs I'm using are actually dumps from another
>> database, so everything has its own primary key already, and I realized
>> it's way easier to just leave them alone rather than waste the processing
>> time and memory reconnecting everything via Python.)
>>
>> I'm still having the same problem. I don't think it's related to the
>> length of the files or something in simplejson, as even a dozen-line yaml
>> file gives me the same exception when I try to load it with loaddata.
>>
>> Any more ideas?
>>
>
>
> Next, I would post the stack trace, there's probably something in there
> that points to the problem, if the yaml parser thinks there is recursion in
> the data. And up the verbosity when running the loaddata command:
>
> --verbosity 3
>
>  --
> 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/-/pq_mI5E031EJ.
>
> 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: Replicating same model for different deployed application.

2012-12-30 Thread Subodh Nijsure
Exactly I was missing the django/web app terminology of multi-tenant app.

I tried using https://github.com/phugoid/django-simple-multitenant and it
seems to have issues. I will see if I can fix them with my limited
knowledge of django.

Are there any good multi-tenants frameworks for django out there, any
recommendations?

Regards,
-Subodh

On Sun, Dec 30, 2012 at 8:57 AM, Amirouche wrote:

> Héllo Subodh
>
>
> On Sunday, December 30, 2012 3:57:36 AM UTC+1, Subodh Nijsure wrote:
>>
>> Hi,
>>
>> I have following situation where. My model consist of say table1, table2,
>> table3.
>>
>> I am going to "host" similar data and associated web interface for
>> multiple customers -( customer1, customer2, customer3.) they would access
>> these application as http://hostname/customer1 http://hostname/customer2etc.
>>
>> When customer1 application is deployed I want tables customer1_table1,
>> customer1_table2, customer1_table3 to be created. Same for customer2, 3 etc.
>>
>> Right now I am thinking of having one "template" directory where all
>> database names are referred to as replaceme_table1, replaceme_table2 etc.
>>
>> When I actually deploy application for real customer say customer1 I am
>> copying this template to directory customer1 and running sed to  change
>> 'replaceme' with 'customer1'
>>
>> Is there a better, elegant way to do this in django where you have same
>>  model that needs to be deployed as multiple django applications?
>>
>
> If I understand this is a multitenant application or multitenancy for
> short, one django instance for several customer. They are several
> application that are labeled like that, I can't recommend any in particular
> since I don't use it them.
>
> Regards,
>
> Amirouche
>
> --
> 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/-/_np6wETOfSwJ.
>
> 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: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread donarb
On Sunday, December 30, 2012 9:54:45 AM UTC-8, Sam Raker wrote:
>
> Thanks for your suggestions.
>
> I eliminated the underscores and got rid of the __unicode__ methods 
> entirely, cleaned up my except statement, and changed the order of stuff 
> such that all of each model's fields are defined before any methods. (As 
> for the pk field: The csvs I'm using are actually dumps from another 
> database, so everything has its own primary key already, and I realized 
> it's way easier to just leave them alone rather than waste the processing 
> time and memory reconnecting everything via Python.) 
>
> I'm still having the same problem. I don't think it's related to the 
> length of the files or something in simplejson, as even a dozen-line yaml 
> file gives me the same exception when I try to load it with loaddata. 
>
> Any more ideas?
>

 
Next, I would post the stack trace, there's probably something in there 
that points to the problem, if the yaml parser thinks there is recursion in 
the data. And up the verbosity when running the loaddata command:

--verbosity 3

-- 
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/-/pq_mI5E031EJ.
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: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread Sam Raker
Thanks for your suggestions.

I eliminated the underscores and got rid of the __unicode__ methods
entirely, cleaned up my except statement, and changed the order of stuff
such that all of each model's fields are defined before any methods. (As
for the pk field: The csvs I'm using are actually dumps from another
database, so everything has its own primary key already, and I realized
it's way easier to just leave them alone rather than waste the processing
time and memory reconnecting everything via Python.)

I'm still having the same problem. I don't think it's related to the length
of the files or something in simplejson, as even a dozen-line yaml file
gives me the same exception when I try to load it with loaddata.

Any more ideas?

On Sun, Dec 30, 2012 at 12:18 PM, Amirouche wrote:

>
>
> On Saturday, December 29, 2012 9:42:50 PM UTC+1, Sam Raker wrote:
>>
>> Here's the truncated version I tried to load in case the problem was the
>> length of the file:
>> - fields: {location: ST. DENNIS HOTEL, restaurant: Veterans American
>> Guard, status: complete,
>> year: 1900}
>>   model: dishes.menu
>>   pk: 12495
>> - fields: {location: BOSTON, restaurant: New England Shorthand Reporter's
>> Association,
>> status: complete, year: 1900}
>>   model: dishes.menu
>>   pk: 12563
>> - fields: {location: RMS LUCANIA, restaurant: Cunard Line, status: under
>> review, year: 1900}
>>   model: dishes.menu
>>   pk: 12749
>> - fields: {location: IROQUOIS, restaurant: Alumni Association
>> University Of Buffalo,
>> status: complete, year: 1900}
>>   model: dishes.menu
>>   pk: 12826
>> - fields: {location: '[CHICAGO', restaurant: Chicago Bar Association,
>> status: complete,
>> year: 1900}
>>   model: dishes.menu
>>   pk: 12836
>> - fields: {location: NEW YORK, restaurant: Hotel Marlborough, status:
>> under review,
>> year: 1900}
>>   model: dishes.menu
>>   pk: 12841
>> - fields: {location: NEW YORK, restaurant: Hotel Marlborough, status:
>> complete, year: 1900}
>>   model: dishes.menu
>>   pk: 12960
>> - fields: {location: HOTEL MARLBOROUGH, restaurant: District No.3
>> Catholic Benevolent
>>   Legion, status: under review, year: 1900}
>>   model: dishes.menu
>>   pk: 13076
>> - fields: {location: 9 & 10 BATTERY PL. NY, restaurant: Castle Garden
>> Hotel, status: complete,
>> year: 1900}
>>   model: dishes.menu
>>   pk: 13117
>>
>> Here's the model:
>> class Menu(models.Model):
>> restaurant=models.TextField(**unique=False)
>> year=models.IntegerField(**unique=False,null=True)
>> location=models.TextField(**unique=False)
>> status=models.CharField(**unique=False,max_length=20)
>> pk=models.IntegerField(**primary_key=True)
>> def __unicode__(self):
>> return restaurant
>> def __period__(self):#adapted from http://stackoverflow.com/**
>> questions/2272149/round-to-**5or-other-number-in-python
>> try:
>> p=int(10*round(float(self.**year)/10))
>> if p < self.year:
>> return "%s-%s"%(p,p+5)
>> else:
>> return "%s-%s"%(p-5,p)
>> except:
>> return ""
>> period=property(__period__)
>> language = models.CharField(unique=False,**max_length=30)
>>
>>
> Some recommandations:
>
> - I never defined __XYZ__ except to look elite ;)
> - how «return restaurant» in __unicode__ can possibly work ?
> - unique default value = False, no need to repeat it if is not something
> else
> - according to Django codings standards you should not inter-mix model
> fields with plain properties or methods
> - pk=models.IntegerField(**primary_key=True) What is it useful for ?
> - according to pep8 «except:» should never be used instead use the «except
> MyException» or «except MyException, e» this prevents bugs [2]
>
>> I've got a very tight deadline, and I'm encountering a very frustrating
>>> problem. Every time I try to use loaddata to load my data into my database,
>>> I get the loaddata error in the subject. I've tried YAML, I've tried JSON,
>>> I've tried excerpting only a few lines of each, all to no avail. I'm really
>>> at my rope's end. I don't think my models are flawed in any significant
>>> way--each refers to only one field in one other model (the primary key in
>>> four out of five of them).
>>>
>>> How big is the json file ? Which library do you use ? If you use
> simplejson it's probably that see:
> https://github.com/simplejson/simplejson/issues/28 This relates to a
> hierarchical data structure where your datastructure at least the one you
> pasted is not, I already had troubles with big JSON files and simplejson, I
> have no metrics sorry.
>
> Can you use SQL ? Maybe you will need to consider spliting the json file
> into several file.
>
> Regards,
>
> Amirouche
>
> [1]
> https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style
> [2] http://peps.io/8/#programming-recommendations
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To 

Re: Actions after logout

2012-12-30 Thread r4m
Hallo Ryan,

thank you for your advice.
What I meant by process is that I've developed a APP user can insert 
data on 4 forms. If they do not complete them on the fourth form, I 
want to delete the data after logout our leaving the page.

Greetings,
Michael

On Sat 29 Dec 2012 08:25:26 PM CET, Ryan Blunden wrote:
> When you say you haver a "process in place", do you mean code sitting
> in a file?
>
> If you haven't already, create a logout url and hook it up to your
> code to delete the log out data. Then just call
> *django.contrib.auth.logout() *somewhere in your logout view.
>
> Cheers,
> Ryan
>
> On 27/12/2012, at 6:50 AM, 4 The good Life we work
> <4thegdl...@googlemail.com > wrote:
>
>> Hallo,
>>
>> I would like to delete certain data + login data after logout.
>>
>> I have a process in place and would like to delete the
>> data inserted if the process is not followed to the last step.
>>
>> Thanks for your support,
>> Michael
>>
>> --
>> 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: loaddata deserializationerror: maximum recursion depth exceeded while calling a Python object

2012-12-30 Thread Amirouche


On Saturday, December 29, 2012 9:42:50 PM UTC+1, Sam Raker wrote:
>
> Here's the truncated version I tried to load in case the problem was the 
> length of the file:
> - fields: {location: ST. DENNIS HOTEL, restaurant: Veterans American 
> Guard, status: complete,
> year: 1900}
>   model: dishes.menu
>   pk: 12495
> - fields: {location: BOSTON, restaurant: New England Shorthand Reporter's 
> Association,
> status: complete, year: 1900}
>   model: dishes.menu
>   pk: 12563
> - fields: {location: RMS LUCANIA, restaurant: Cunard Line, status: under 
> review, year: 1900}
>   model: dishes.menu
>   pk: 12749
> - fields: {location: IROQUOIS, restaurant: Alumni Association   University 
> Of Buffalo,
> status: complete, year: 1900}
>   model: dishes.menu
>   pk: 12826
> - fields: {location: '[CHICAGO', restaurant: Chicago Bar Association, 
> status: complete,
> year: 1900}
>   model: dishes.menu
>   pk: 12836
> - fields: {location: NEW YORK, restaurant: Hotel Marlborough, status: 
> under review,
> year: 1900}
>   model: dishes.menu
>   pk: 12841
> - fields: {location: NEW YORK, restaurant: Hotel Marlborough, status: 
> complete, year: 1900}
>   model: dishes.menu
>   pk: 12960
> - fields: {location: HOTEL MARLBOROUGH, restaurant: District No.3 Catholic 
> Benevolent
>   Legion, status: under review, year: 1900}
>   model: dishes.menu
>   pk: 13076
> - fields: {location: 9 & 10 BATTERY PL. NY, restaurant: Castle Garden 
> Hotel, status: complete,
> year: 1900}
>   model: dishes.menu
>   pk: 13117
>
> Here's the model:
> class Menu(models.Model):
> restaurant=models.TextField(unique=False)
> year=models.IntegerField(unique=False,null=True)
> location=models.TextField(unique=False)
> status=models.CharField(unique=False,max_length=20)
> pk=models.IntegerField(primary_key=True)
> def __unicode__(self):
> return restaurant
> def __period__(self):#adapted from 
> http://stackoverflow.com/questions/2272149/round-to-5or-other-number-in-python
> try:
> p=int(10*round(float(self.year)/10))
> if p < self.year:
> return "%s-%s"%(p,p+5)
> else:
> return "%s-%s"%(p-5,p)
> except:
> return ""
> period=property(__period__) 
> language = models.CharField(unique=False,max_length=30)
>
>
Some recommandations:

- I never defined __XYZ__ except to look elite ;)
- how «return restaurant» in __unicode__ can possibly work ?
- unique default value = False, no need to repeat it if is not something 
else
- according to Django codings standards you should not inter-mix model 
fields with plain properties or methods
- pk=models.IntegerField(primary_key=True) What is it useful for ?
- according to pep8 «except:» should never be used instead use the «except 
MyException» or «except MyException, e» this prevents bugs [2]

> I've got a very tight deadline, and I'm encountering a very frustrating 
>> problem. Every time I try to use loaddata to load my data into my database, 
>> I get the loaddata error in the subject. I've tried YAML, I've tried JSON, 
>> I've tried excerpting only a few lines of each, all to no avail. I'm really 
>> at my rope's end. I don't think my models are flawed in any significant 
>> way--each refers to only one field in one other model (the primary key in 
>> four out of five of them).
>>
>> How big is the json file ? Which library do you use ? If you use 
simplejson it's probably that see: 
https://github.com/simplejson/simplejson/issues/28 This relates to a 
hierarchical data structure where your datastructure at least the one you 
pasted is not, I already had troubles with big JSON files and simplejson, I 
have no metrics sorry.

Can you use SQL ? Maybe you will need to consider spliting the json file 
into several file.

Regards,

Amirouche

[1] 
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style
[2] http://peps.io/8/#programming-recommendations

-- 
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/-/FCFXKNxtvAIJ.
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: Getting Access to Object in Admin Panel

2012-12-30 Thread Amirouche


On Sunday, December 30, 2012 8:47:05 AM UTC+1, donarb wrote:
>
> You can code a string that references the __unicode__ method:
>
>   list_display = ('__unicode__', ...
>
ref: 
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display
 

-- 
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/-/iJWxqtXmcS0J.
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: Serve static files in production server

2012-12-30 Thread Amirouche
Héllo Stefano,

On Sunday, December 30, 2012 1:27:12 PM UTC+1, Stefano Tranquillini wrote:
>
> Hi all.
> in the appfog ML we were fighting again the possibility to serve static 
> file in django without using an external server.
> So far AF does not provide a setup of the server to split the server in 
> static and dynamic (django) folders.
> so, one of the solution is to use this
>
> # urls.py 
> urlpatterns += patterns('', 
> url(r'^static/(?P.*)$', 'django.views.static.serve', { 
> 'document_root': settings.STATIC_ROOT}) 
> )
>
> but, is it ok to use this trick in django or will it lead to problems (aka 
> memory problems and stuff like that)?
>

The documentation state «Again, this view is *not* hardened for production 
use» [1]

What is the particular issue your are facing ? Maybe tproxy [2] can help.

Regards,

Amirouche

[1] 
https://docs.djangoproject.com/en/dev/howto/static-files/#django.views.static.serve
[2] https://github.com/benoitc/tproxy

>

-- 
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/-/WjCrTrhhcyEJ.
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: Replicating same model for different deployed application.

2012-12-30 Thread Amirouche
Héllo Subodh

On Sunday, December 30, 2012 3:57:36 AM UTC+1, Subodh Nijsure wrote:
>
> Hi,
>
> I have following situation where. My model consist of say table1, table2, 
> table3. 
>
> I am going to "host" similar data and associated web interface for 
> multiple customers -( customer1, customer2, customer3.) they would access 
> these application as http://hostname/customer1 http://hostname/customer2etc.
>
> When customer1 application is deployed I want tables customer1_table1, 
> customer1_table2, customer1_table3 to be created. Same for customer2, 3 etc.
>
> Right now I am thinking of having one "template" directory where all 
> database names are referred to as replaceme_table1, replaceme_table2 etc.
>
> When I actually deploy application for real customer say customer1 I am 
> copying this template to directory customer1 and running sed to  change 
> 'replaceme' with 'customer1' 
>
> Is there a better, elegant way to do this in django where you have same 
>  model that needs to be deployed as multiple django applications?
>

If I understand this is a multitenant application or multitenancy for 
short, one django instance for several customer. They are several 
application that are labeled like that, I can't recommend any in particular 
since I don't use it them.

Regards,

Amirouche

-- 
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/-/_np6wETOfSwJ.
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: Replicating same model for different deployed application.

2012-12-30 Thread Thiago Luiz Silva
Hello,

I guess that the most elegant way is to create a "detachable" app in one
principal project and then you install it on the projects that will use
that. After the installation you may run the migrations for each project so
you don´t have to change files and keep track of changes.

We are developing a application with a scenario that may be similar:
http://hostname1 and http://hostname2 runs the same app, but with different
databases and using South to generate the migrations.

If you wanna use the same database and the same app on the same domain, you
should use the same table for all data and use the customer as a filter.
Your database may become a bit confusing after 5 clients with 3 or 4 tables
each one.


[]´s
ThLuiz






On Sun, Dec 30, 2012 at 12:57 AM, Subodh Nijsure
wrote:

> Hi,
>
> I have following situation where. My model consist of say table1, table2,
> table3.
>
> I am going to "host" similar data and associated web interface for
> multiple customers -( customer1, customer2, customer3.) they would access
> these application as http://hostname/customer1 http://hostname/customer2etc.
>
> When customer1 application is deployed I want tables customer1_table1,
> customer1_table2, customer1_table3 to be created. Same for customer2, 3 etc.
>
> Right now I am thinking of having one "template" directory where all
> database names are referred to as replaceme_table1, replaceme_table2 etc.
>
> When I actually deploy application for real customer say customer1 I am
> copying this template to directory customer1 and running sed to  change
> 'replaceme' with 'customer1'
>
> Is there a better, elegant way to do this in django where you have same
>  model that needs to be deployed as multiple django applications?
>
> -Subodh
>
> --
> 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: Star Rating System In Django

2012-12-30 Thread coded kid
The developer for agon rating is no more working on it and I guess it won't 
work nice .

Simple ratings is not working out for me. Don't know if there's a 
JavaScript plugin for rating?

On Sunday, 30 December 2012 14:08:10 UTC+1, Alec Taylor wrote:
>
> Agon (probably easiest): 
> http://agon-ratings.readthedocs.org/en/latest/usage.html 
>
> -or- 
>
> https://github.com/dcramer/django-ratings 
>
> -or- 
>
> https://github.com/coleifer/django-simple-ratings 
>
> On Mon, Dec 31, 2012 at 12:03 AM, coded kid 
> > 
> wrote: 
> > Anyone know about any good package or tutorial or plugin for building 
> > a star rating system in django? I tried using dcramer/django rating 
> > but It's not working perfectly. 
> > 
> > If you know of any plugin, package on how to build a star rating 
> > system, kindly post it below. 
> > 
> > Thanks! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Django users" group. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> django-users...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/T60zmdo25g8J.
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: Star Rating System In Django

2012-12-30 Thread Alec Taylor
Agon (probably easiest):
http://agon-ratings.readthedocs.org/en/latest/usage.html

-or-

https://github.com/dcramer/django-ratings

-or-

https://github.com/coleifer/django-simple-ratings

On Mon, Dec 31, 2012 at 12:03 AM, coded kid  wrote:
> Anyone know about any good package or tutorial or plugin for building
> a star rating system in django? I tried using dcramer/django rating
> but It's not working perfectly.
>
> If you know of any plugin, package on how to build a star rating
> system, kindly post it below.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Star Rating System In Django

2012-12-30 Thread coded kid
Anyone know about any good package or tutorial or plugin for building
a star rating system in django? I tried using dcramer/django rating
but It's not working perfectly.

If you know of any plugin, package on how to build a star rating
system, kindly post it below.

Thanks!

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