Sunday, December 30, 2012

Re: Star Rating System In Django

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 <duffle...@gmail.com> 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+unsubscribe@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

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+unsubscribe@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'")

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.


Cheers,
Ryan

On 29/12/2012, at 7:27 AM, Jeff <je...@ccmail.co> 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+unsubscribe@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

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 <donarb@nwlink.com> 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+unsubscribe@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+unsubscribe@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



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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Actions after logout

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 <4thegdlife@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
> <4thegdlife@googlemail.com <http://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
>> <mailto:django-users@googlegroups.com>.
>> To unsubscribe from this group, send email to
>> django-users+unsubscribe@googlegroups.com
>> <mailto:django-users+unsubscribe@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+unsubscribe@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+unsubscribe@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+unsubscribe@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

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 <donarb@nwlink.com> 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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.