Re: Speficy a Database for Testing

2012-02-08 Thread Mark Furbee
Denis Darii already answered this on February 1st:

"You can redefine your database connection by adding somewhere at the end
of your settings.py something like:

import sys

if 'test' in sys.argv:

DATABASES = ...

hope this helps."


Did you try this?

On Wed, Feb 8, 2012 at 7:19 AM, xina towner  wrote:

> Can I create a Database manually and then specify to the testing unit to
> use that?
>
> --
> Gràcies,
>
> Rubén
>
>  --
> 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: Speficy a Database for Testing

2012-02-08 Thread Mark Furbee
I'm not sure that you can specify a different existing database. I think
(not certain) that Django's testing is built to have no effect on real
data, hence creating a blank test database. You can, however, use fixtures
to create data in the test database after it is created and before the unit
tests are performed. I assume the reason you want to use a previously,
externally created DB is that you want to test based on the data in that
DB. If this is the case, it is perfect to use a fixture of that DB's data.

Mark

On Wed, Feb 8, 2012 at 7:42 AM, xina towner  wrote:

> Yes, but django makes a new testDatabase and that's my problem, I want
> django to use a database I've previously done.
>
>
> On 8 February 2012 16:34, Mark Furbee  wrote:
>
>> Denis Darii already answered this on February 1st:
>>
>> "You can redefine your database connection by adding somewhere at the
>> end of your settings.py something like:
>>
>> import sys
>>
>> if 'test' in sys.argv:
>>
>> DATABASES = ...
>>
>> hope this helps."
>>
>>
>> Did you try this?
>>
>> On Wed, Feb 8, 2012 at 7:19 AM, xina towner  wrote:
>>
>>> Can I create a Database manually and then specify to the testing unit to
>>> use that?
>>>
>>> --
>>> Gràcies,
>>>
>>> Rubén
>>>
>>>  --
>>> 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.
>>
>
>
>
> --
> Gràcies,
>
> Rubén
>
>  --
> 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: Set of choices of which several can be chosen without using a ManyToManyField

2011-11-02 Thread Mark Furbee
As alluded to previously, the most "straightforward way to use a set of
choices of which several can be chosen" IS to use a ManyToManyField. The
syntax is slightly different, but ManyToManyFields are really easy to use
with Django. Do not reinvent the wheel in this case.

Thanks,

Mark Furbee


On Tue, Nov 1, 2011 at 7:49 AM, J. Cliff Dyer  wrote:

> On 11/01/2011 09:05 AM, Jaroslav Dobrek wrote:
>
>> You are confusing model fields with form fields. MultipleChoiceField
>>> is a form field, not a model field.
>>>
>> I wasn't aware of the existence of MultipleChoiceFields. The idea of
>> the above code was to express that I wanted to use this code
>>
>> class Candidate(models.Model):
>>
>> programming_languages = models.CharField(max_length=**50, choices=(
>>
>> (u'Python)', u'Python'),
>> (u'C++', u'C++'),
>> (u'Java', u'Java'),
>> # ...
>> ), blank=True)
>>
>> with the only exception that, in the admin interface, several choices
>> are possible when one creates a new candidate object. I.e. I want
>> admins to be able to create a candidate that knows, say Python *and* C+
>> + by choosing both of these languages during the creation of the
>> object. I used the string "MultipleChoiceField" as a dummy for
>> whatever should be used instead.
>>
>> Jaroslav
>>
>>
>>
>>
>>
>>
>>  If you want a field that will be represented by a MultipleChoiceField
>>> in model, you simply need to define 'choices' on a field class.
>>>
>>> https://docs.djangoproject.**com/en/1.3/ref/models/fields/#**choices<https://docs.djangoproject.com/en/1.3/ref/models/fields/#choices>
>>>
>>> Cheers
>>>
>>> Tom
>>>
>> Still, you want to control the input at the form level, not the model
> level.  Create a ModelForm for your Candidate, but override the language
> field to take a MultipleChoiceField, and then override the __init__() and
> save() methods to handle them properly.  "Properly," of course, is
> determined by your application, and how you want to store the information
> in the database.  You could choose to store it in a CharField as a comma
> separated list of language names, or in an IntegerField as a bit field (0x1
> = 'Python', 0x2 = 'Perl', 0x4 = PHP, so 0x5 means the user knows Python and
> PHP, but not Perl).  The latter is a more efficient way to store the data,
> but the former is arguably more human-friendly.
>
> Ultimately, though, it seems that you are adding complexity rather than
> removing it.  This is exactly what many to many relationships are designed
> to handle.  If you want to use another method, you have to figure out the
> details for yourself.
>
> Cheers,
> Cliff
>
>
> --
> 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<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: Relation not found error while dealing with foreign keys and forms

2011-11-04 Thread Mark Furbee
Good Morning Tabitha.

Actually, do you have a model for StaffForm? That is the object being
instantiated and then causing the error. If there is no nics group
reference field in the StaffForm object, it may raise this error. Also, do
you have this running in a view/template? Do you have a real page that
you've tried this on, or have you just tried it in the shell?

Thanks,

Furbee

On Fri, Nov 4, 2011 at 7:02 AM, Tabitha Samuel wrote:

> Here is staff/models.py
>
> from django.db import models
>
> class NICSGroupType(models.Model):
>n_group_number = models.IntegerField(primary_key = True)
>n_group_name = models.CharField(max_length = 512)
> def __str__(self):
>return self.n_group_name
> class Meta:
>db_table = "n_nics_groups"
>
> class StaffpageAdmin(models.Model):
>n_id= models.IntegerField(primary_key =
> True)
>n_username  = models.CharField(max_length = 50)
>class Meta:
>db_table = 'n_staffpage_admin'
>
> class Staff(models.Model):
>username= models.CharField(primary_key = True,
> max_length = 50)
>home_phone  = models.CharField(max_length = 12,
> null=True)
>cell_phone  = models.CharField(max_length = 12,
> null = True)
>home_address= models.CharField(max_length = 1024,
> null = True)
>home_city   = models.CharField(max_length = 64,
> null = True)
>home_state  = models.CharField(max_length = 32,
> null = True)
>home_zip= models.CharField(max_length = 10,
> null = True)
>emergency_name  = models.CharField(max_length =64,
> null = True)
>emergency_phone = models.CharField(max_length = 12,
> null = True)
>nics_group  = models.ForeignKey(NICSGroupType,
> to_field="n_group_number",db_column="nics_group",
> null=True,blank=True)
>room_number = models.CharField(max_length = 32,
> null = True)
>title   = models.CharField(max_length = 64)
>supervisor  = models.CharField(max_length = 25,
> null = True, blank = True)
>url = models.CharField(max_length =
> 256,null = True, blank = True)
>im  = models.CharField(max_length = 32,
> null = True, blank=True)
>last_modification_time  = models.IntegerField()
>start_date  = models.IntegerField()
>creation_time   = models.IntegerField()
>termination_date= models.IntegerField(null = True,
> blank = True)
>bio = models.TextField()
>photopath   = models.CharField(max_length = 5048)
>office_phone= models.CharField(max_length=12)
>email   = models.CharField(max_length = 256)
>preferred_name  = models.CharField(max_length = 50,
> null = True, blank = True)
>deleted = models.BooleanField(default = False)
>viewable= models.BooleanField(default = True)
>
>class Meta:
>db_table = "n_test_staff"
>
> class TG_Staff(models.Model):
>g_name  = models.CharField(primary_key = True,
> max_length = 1024)
>g_modification_time = models.IntegerField()
>g_active= models.CharField(max_length = 5)
>g_common_name   = models.CharField(max_length = 1024)
>g_phone_number  = models.CharField(max_length = 1024)
>g_default_project   = models.CharField(max_length = 1024)
>g_office_address= models.CharField(max_length = 1024)
>g_bz_phone  = models.CharField(max_length = 1024)
>g_bz_phone_ext  = models.CharField(max_length = 1024)
>g_citizenship   = models.CharField(max_length = 1024)
>g_street_address= models.CharField(max_length = 1024)
>g_street_address2   = models.CharField(max_length = 1024)
>g_city  = models.CharField(max_length = 1024)
>g_state = models.CharField(max_length = 1024)
>g_zip   = models.CharField(max_length = 1024)
>g_country   = models.CharField(max_length = 1024)
>g_dept  = models.CharField(max_length = 1024)
>g_tg_person_id  = models.CharField(max_length = 1024)
>g_org   = models.CharField(max_length = 1024)
>g_position  = models.CharField(max_length = 1024)
>g_home_phone= models.CharField(max_length = 1024)
>g_fax   = models.CharField(max_length = 1024)
>g_ldap_id   = models.IntegerField()
>g_email_address = models.CharField(max_length = 1024)
>
>class Meta:
>db_table = "g_user"
>
> Is this what

Re: Having Headache With LoginForm

2012-01-17 Thread Mark Furbee
It means, don't use the "decorator" @login_required above your login view.
Your login view cannot require a login, because you'd never get to log in.
Chicken and egg.

On Tue, Jan 17, 2012 at 2:34 PM, coded kid  wrote:

>
>
> Thorsten Sanders wrote:
> > With using
> >
> > @login_required decorator the user needs to be logged in to allow
> execution, don't makes much sense for a login :P
> >
> >
> >
> > Am 17.01.2012 22:23, schrieb coded kid:
> > > Hi guys, I�m having problem with my login form. The login form will
> > > redirect me to the next page even if I didn�t input anything in the
> > > username and password field. Also it can�t get the username of the
> > > registered users to verify if the user data is wrong or right. How can
> > > I get rid of this problem?
> > > Below are my code:
> > > In views.py
> > > from django.db import models
> > > from mymeek.meekme.models import RegisterForm
> > > from django.shortcuts import render_to_response
> > > from django.http import HttpResponse
> > > from django.template import RequestContext
> > > from django.http import HttpResponseRedirect
> > > from django.contrib.auth import authenticate, login
> > > from django.contrib.auth.decorators import login_required
> > >
> > > @login_required
> > > def mylogin(request):
> > >  if request.method=='POST':
> > >  username= request.POST['username']
> > >  password= request.POST['password']
> > >  user=authenticate (username=username, password=password)
> > >  if user is not None:
> > >  if user.is_active:
> > >  login(request, user)
> > >  return HttpResponseRedirect('/logpage/')
> > >  else:
> > >  return direct_to_template(request,'q_error.html')
> > >  else:
> > >  return render_to_response('mainpage.html')
> > > In my template:
> > > 
> > > 
> > > 
> > > 
> > >{{form.username.label_tag}}
> > >{{form.username}}
> > > 
> > > 
> > >{{form.password.label_tag}}
> > >{{form.password}}
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Please help me out! 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.



Re: Having Headache With LoginForm

2012-01-18 Thread Mark Furbee
Is that template mainpage.html?

I'm not sure exactly what you mean is happening. When you open the login
page it takes you back to the home page? Also, I would add in the my_login
view that if they are already logged in to redirect them to another page
besides the login page. As your view is now, when they go to the login
page, while they are already logged in, it will allow them to log in again
as a different user. Perhaps that is intended, I just thought I'd point it
out.

Mark

On Tue, Jan 17, 2012 at 10:57 PM, coded kid  wrote:

> Yeah, I've done that, but its not working! Any help?
>
> On Jan 17, 10:37 pm, Mark Furbee  wrote:
> > It means, don't use the "decorator" @login_required above your login
> view.
> > Your login view cannot require a login, because you'd never get to log
> in.
> > Chicken and egg.
> >
> >
> >
> > On Tue, Jan 17, 2012 at 2:34 PM, coded kid 
> wrote:
> >
> > > Thorsten Sanders wrote:
> > > > With using
> >
> > > > @login_required decorator the user needs to be logged in to allow
> > > execution, don't makes much sense for a login :P
> >
> > > > Am 17.01.2012 22:23, schrieb coded kid:
> > > > > Hi guys, I�m having problem with my login form. The login form
> will
> > > > > redirect me to the next page even if I didn�t input anything in
> the
> > > > > username and password field. Also it can�t get the username of
> the
> > > > > registered users to verify if the user data is wrong or right. How
> can
> > > > > I get rid of this problem?
> > > > > Below are my code:
> > > > > In views.py
> > > > > from django.db import models
> > > > > from mymeek.meekme.models import RegisterForm
> > > > > from django.shortcuts import render_to_response
> > > > > from django.http import HttpResponse
> > > > > from django.template import RequestContext
> > > > > from django.http import HttpResponseRedirect
> > > > > from django.contrib.auth import authenticate, login
> > > > > from django.contrib.auth.decorators import login_required
> >
> > > > > @login_required
> > > > > def mylogin(request):
> > > > >  if request.method=='POST':
> > > > >  username= request.POST['username']
> > > > >  password= request.POST['password']
> > > > >  user=authenticate (username=username, password=password)
> > > > >  if user is not None:
> > > > >  if user.is_active:
> > > > >  login(request, user)
> > > > >  return HttpResponseRedirect('/logpage/')
> > > > >  else:
> > > > >  return direct_to_template(request,'q_error.html')
> > > > >  else:
> > > > >  return render_to_response('mainpage.html')
> > > > > In my template:
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > >{{form.username.label_tag}}
> > > > >{{form.username}}
> > > > > 
> > > > > 
> > > > >{{form.password.label_tag}}
> > > > >{{form.password}}
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > Please help me out! 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.
>
>

-- 
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: Having Headache With LoginForm

2012-01-18 Thread Mark Furbee
This is my login process.

urls.py:
url(r'^login$', 'views.Login'),
url(r'^logout$', 'views.Logout'),


views.py:
def Login(request, next=None):
"""
Used to log into the application.
"""

#  If the user is authenticated pass them through to the homepage.
if request.user.is_authenticated():
return HttpResponseRedirect('/')

# If the user is not authenticated, but the method is POST, they have
posted their username and password.
if request.method == "POST":

# Get Username and Password.
username = request.POST['username']
password = request.POST['password']

# Authenticate.
user = authenticate(username=username, password=password)

# If the User is not None, they have a valid account and password.
if user is not None:

# If the user isactive, we can log them in.
if user.is_active:
# Log them in, and redirect to the homepage.
login(request, user)
return HttpResponseRedirect('/')

# If the user is not active, pass them back to the login page,
with a message that the account is inactive.
else:
return render_to_response('login.htm', {'error': 'Account
Disabled - contact I.T. for assistance'},
context_instance=RequestContext(request))

# The user with those credentials did not exist, pass them back to
the login page, with a message that the account was invalid.
else:
return render_to_response('login.htm', {'error': 'Invalid
Username/Password - contact I.T. for assistance'},
context_instance=RequestContext(request))

# They have not yet attempted a login, pass them to the login page,
without any error messages..
else:

return render_to_response('login.htm', {'NoSessionTimeout': 'True',
'next': next}, context_instance=RequestContext(request))


def Logout(request):
logout(request)

# Render the logout.htm page, which will display they are logging out
and redirect them to the login page.
return render_to_response('login.htm', {'notice': 'You have been logged
out successfully.'}, context_instance=RequestContext(request))



template login.htm:

.
.
.

 {% csrf_token %}
 
 
 Login
 

 
{% if error %}
 

 {% FatalImage %}
{{ error }}

 

 {% endif %}
{% if warning %}

 
{% WarnImage %}
 {{ warning }}


 
{% endif %}
 {% if notice %}


 {% NoticeImage %}
{{ notice }}

 

 {% endif %}

Email address:    
 

 


 Password:    

 
 

 
 
 

 

 


 




On Wed, Jan 18, 2012 at 8:09 AM, Mark Furbee  wrote:

> Is that template mainpage.html?
>
> I'm not sure exactly what you mean is happening. When you open the login
> page it takes you back to the home page? Also, I would add in the my_login
> view that if they are already logged in to redirect them to another page
> besides the login page. As your view is now, when they go to the login
> page, while they are already logged in, it will allow them to log in again
> as a different user. Perhaps that is intended, I just thought I'd point it
> out.
>
> Mark
>
> On Tue, Jan 17, 2012 at 10:57 PM, coded kid wrote:
>
>> Yeah, I've done that, but its not working! Any help?
>>
>> On Jan 17, 10:37 pm, Mark Furbee  wrote:
>> > It means, don't use the "decorator" @login_required above your login
>> view.
>> > Your login view cannot require a login, because you'd never get to log
>> in.
>> > Chicken and egg.
>> >
>> >
>> >
>> > On Tue, Jan 17, 2012 at 2:34 PM, coded kid 
>> wrote:
>> >
>> > > Thorsten Sanders wrote:
>> > > > With using
>> >
>> > > > @login_required decorator the user needs to be logged in to allow
>> > > execution, don't makes much sense for a login :P
>> >
>> > > > Am 17.01.2012 22:23, schrieb coded kid:
>> > > > > Hi guys, I�m having problem with my login form. The login form
>> will
>> > > > > redirect me to the next page even if I didn�t input anything in
>> the
>> > > > > username and password field. Also it can�t get the username of
>> the
>> > > > > registered users to verify if the user data is wrong or right.
>> How can
>> > > > > I get rid of this problem?
>> > > > > Below are my code:
>> > > > > In views.py
>> > > > > from django.db import models
>> > > > > from mymeek.meek

Re: Having Headache With LoginForm

2012-01-19 Thread Mark Furbee
No problem. You will likely use the form objects in your template, I just
chose to create my own form in HTML.

Since the 'views.Login' is a string, you don't need to import it. It just
tells Django which view to pass the request to when that url pattern is
found. The ^ means the beginning of the url after the slash
(www.mysite.com/). The $ means the string ends. I found this useful, because without
it, multiple urls will match. For example: with `url(r'^login',
'views.Login')`, the following will all match and go to views.Login: 1)
www.mysite.com/login, 2) www.mysite.com/login_page, 3)
www.mysite.com/login?no_login=1. So I specify the $ to make it more exact,
more out of habit than requirement. If you add the slash to the end like
`url(r'^login/$', 'views.Login')`, it will require the slash, so
www.mysite.com/login will not match. If you want to have both urls work, I
think this will work (although untested): `url(r'^login/?$',
'views.Login')`, where the /? means that there could be no / or one slash.
With this, the following would not match: www,mysite.com/login///. If you
wanted to allow multiple slashes, change the ? with *, like
`url(r'^login/*', 'views.Login')`. Again, that's not tested, but it should
work, I think.

Happy Coding!

Mark

On Wed, Jan 18, 2012 at 6:09 PM, coded kid  wrote:

> Thanks bro. Don't you think I should import Login in urls.py? What
> about / in before the $ in urls.py? Or I should just place it like
> that?
>
> Mark Furbee wrote:
> > This is my login process.
> >
> > urls.py:
> > url(r'^login$', 'views.Login'),
> > url(r'^logout$', 'views.Logout'),
> >
> >
> > views.py:
> > def Login(request, next=None):
> > """
> > Used to log into the application.
> > """
> >
> > #  If the user is authenticated pass them through to the homepage.
> > if request.user.is_authenticated():
> > return HttpResponseRedirect('/')
> >
> > # If the user is not authenticated, but the method is POST, they have
> > posted their username and password.
> > if request.method == "POST":
> >
> > # Get Username and Password.
> > username = request.POST['username']
> > password = request.POST['password']
> >
> > # Authenticate.
> > user = authenticate(username=username, password=password)
> >
> > # If the User is not None, they have a valid account and
> password.
> > if user is not None:
> >
> > # If the user isactive, we can log them in.
> > if user.is_active:
> > # Log them in, and redirect to the homepage.
> > login(request, user)
> > return HttpResponseRedirect('/')
> >
> > # If the user is not active, pass them back to the login
> page,
> > with a message that the account is inactive.
> > else:
> > return render_to_response('login.htm', {'error': 'Account
> > Disabled - contact I.T. for assistance'},
> > context_instance=RequestContext(request))
> >
> > # The user with those credentials did not exist, pass them back
> to
> > the login page, with a message that the account was invalid.
> > else:
> > return render_to_response('login.htm', {'error': 'Invalid
> > Username/Password - contact I.T. for assistance'},
> > context_instance=RequestContext(request))
> >
> > # They have not yet attempted a login, pass them to the login page,
> > without any error messages..
> > else:
> >
> > return render_to_response('login.htm', {'NoSessionTimeout':
> 'True',
> > 'next': next}, context_instance=RequestContext(request))
> >
> >
> > def Logout(request):
> > logout(request)
> >
> > # Render the logout.htm page, which will display they are logging out
> > and redirect them to the login page.
> > return render_to_response('login.htm', {'notice': 'You have been
> logged
> > out successfully.'}, context_instance=RequestContext(request))
> >
> >
> >
> > template login.htm:
> >
> > .
> > .
> > .
> >  > method="post" name="login">
> >  {% csrf_token %}
> >  
> >  
> >  Login
> >  
> &g

Re: can someone rewrite this line please

2013-02-20 Thread Mark Furbee
Not sure if you need the json.large to be compiled or if that should be
part of the string. The biggest issue was you had a single-quote before
onmouseover. After that, you have to escape the single-quote before \',LEFT, true, OFFSETY, -250, OFFSETX, 0, WIDTH,
800)\" target=\"_blank\">';

FYI: if you use an IDE like Eclipse, it will show you what is and isn't
escaped to some degree, using colored text to denote quoted strings versus
compiled commands.

Cheers,

Mark

On Wed, Feb 20, 2013 at 6:25 AM, MikeKJ  wrote:

> large = ' src='+json.large+'/>',LEFT, true, OFFSETY, -250, OFFSETX, 0, WIDTH, 800)\"
> target=\"_blank\">';
>
> so that is comes out of the jquery call as proper html, it needs more
> escaping somewhere but damned if I can see it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: can someone rewrite this line please

2013-02-21 Thread Mark Furbee
No worries, Mike. Any time!


On Thu, Feb 21, 2013 at 3:17 AM, MikeKJ  wrote:

> Thank you Mark spot on!
>
> Really appreciate it
>
>
>
>
>
> On Wednesday, February 20, 2013 3:58:28 PM UTC, Mark wrote:
>
>> Not sure if you need the json.large to be compiled or if that should be
>> part of the string. The biggest issue was you had a single-quote before
>> onmouseover. After that, you have to escape the single-quote before > src and either escape the + json.large + or leave it so that Type will
>> compile it. Give this a try, I think it is what you want:
>>
>> large = '> src="'+json.large+'"/>\',LEFT, true, OFFSETY, -250, OFFSETX, 0, WIDTH,
>> 800)\" target=\"_blank\">';
>>
>> FYI: if you use an IDE like Eclipse, it will show you what is and isn't
>> escaped to some degree, using colored text to denote quoted strings versus
>> compiled commands.
>>
>> Cheers,
>>
>> Mark
>>
>> On Wed, Feb 20, 2013 at 6:25 AM, MikeKJ  wrote:
>>
>>> large = '>> src='+json.large+'/>',LEFT, true, OFFSETY, -250, OFFSETX, 0, WIDTH, 800)\"
>>> target=\"_blank\">';
>>>
>>> so that is comes out of the jquery call as proper html, it needs more
>>> escaping somewhere but damned if I can see it.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Saving browser output as pdf

2013-02-24 Thread Mark Furbee
Mike DeWitt's answer is most appropriate. In you view define an argument
'pdf=False' and when returning the response from uou view, if pdf is False,
return regular HttpResponse. If pdf is True, follw @Mike's reply to set
response Content type to PDF. It is really easy to return what would be an
html response as a pdf download. You could even show report as html, with
link to download as PDF. The PDF link would go to the same view method with
'pdf=True'.
On Feb 24, 2013 6:30 AM, "Nick Apostolakis"  wrote:

> On 24/02/2013 03:15 μμ, Satinderpal Singh wrote:
>
>> Thanks a lot to all. I noted your suggestions, and will try to
>> implement one which would be best suit to my requirement.
>>
>> By the way, i am trying to take pdf output from the models and for
>> that i required these libraries. Currently, i am using pisa for saving
>> the output of the report as pdf file.
>>
>> Basically i need both outputs, html and pdf, for my clients. I need to
>>   produce more than 40 different reports as html and pdf so that my
>> client can take whatever he needed. And if i tried to produce both
>> html and pdf from views, then it requires functions double to the
>> reports, two for each html and pdf. So, i need solution which can
>> convert my html output to the pdf from browser.
>>
>>
>>
>>
> Hi there, I use the report lab library in my application to produce pdf
> reports.
>
> The user sees the report in html of course and has an option to download
> it as csv or as pdf.
> The pdf part is accomplished with reportlab library.
>
> Cheers
>
> --
>  --**--**--
>Nick Apostolakis
>   e-mail: nicka...@oncrete.gr
>  Web Site: http://nick.oncrete.gr
>  --**--**--
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> django-users+unsubscribe@**googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users?hl=en
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

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




Re: Saving browser output as pdf

2013-02-24 Thread Mark Furbee
Django docs (pretty turse):
https://docs.djangoproject.com/en/dev/howto/outputting-pdf/

>From ReportLab site:
http://www.reportlab.com/software/documentation/

Here's a decent quick tutorial:
http://www.blog.pythonlibrary.org/2010/03/08/a-simple-step-by-step-reportlab-tutorial/

Note that what you are proposing is to create an HTML version of the report
and a separate PDF version using ReportLab. Otherwise, if you want to make
what would be an HTML report download as a PDF document, use @Mike's
solution.

Good Luck,

Mark


On Sun, Feb 24, 2013 at 8:04 AM, Satinderpal Singh <
satinder.goray...@gmail.com> wrote:

> On Sun, Feb 24, 2013 at 8:00 PM, Nick Apostolakis 
> wrote:
> > On 24/02/2013 03:15 μμ, Satinderpal Singh wrote:
> >>
> >> Thanks a lot to all. I noted your suggestions, and will try to
> >> implement one which would be best suit to my requirement.
> >>
> >> By the way, i am trying to take pdf output from the models and for
> >> that i required these libraries. Currently, i am using pisa for saving
> >> the output of the report as pdf file.
> >>
> >> Basically i need both outputs, html and pdf, for my clients. I need to
> >>   produce more than 40 different reports as html and pdf so that my
> >> client can take whatever he needed. And if i tried to produce both
> >> html and pdf from views, then it requires functions double to the
> >> reports, two for each html and pdf. So, i need solution which can
> >> convert my html output to the pdf from browser.
> >>
> >>
> >>
> >
> > Hi there, I use the report lab library in my application to produce pdf
> > reports.
> >
> > The user sees the report in html of course and has an option to download
> it
> > as csv or as pdf.
> > The pdf part is accomplished with reportlab library.
> >
> That exactly i want, please tell me how will i do this.
>
>
> > Cheers
> >
> > --
> >  --
> >Nick Apostolakis
> >   e-mail: nicka...@oncrete.gr
> >  Web Site: http://nick.oncrete.gr
> >  --
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
>
> --
> Satinderpal Singh
> http://satindergoraya.blogspot.in/
> http://satindergoraya91.blogspot.in/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: ANNOUNCE: Django 1.5 released

2013-02-26 Thread Mark Furbee
Woo-hoo! Awesome news. We really appreciate all the hard work you guys have
been doing getting this version out.

Thanks a million!

Mark


On Tue, Feb 26, 2013 at 11:44 AM, James Bennett wrote:

> Yup, it's finally here!
>
> * Announcement blog post here:
> https://www.djangoproject.com/weblog/2013/feb/26/15/
> * Release notes here: https://docs.djangoproject.com/en/1.5/releases/1.5/
> * Download it here: https://www.djangoproject.com/download/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Mark Furbee
It would appear to me that your missing the path to django in your
environment. When you upgraded did you also upgrade to another version of
Python, perhaps? Is the dist-packages/site-packages django folder in the
same place it was?


On Thu, Apr 4, 2013 at 3:58 PM, Bastian  wrote:

> I have tried with runserver and debug = True and it gives me the error but
> when I turn off debug then the site loads fine.
> Then I installed gunicorn and with debug = true and the error appears but
> with debug = False the site loads fine but without the static content.
> I don't know if this is a clue about something wrong in the static
> settings or if it's just a setting in gunicorn.
>
> Any idea?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Mark Furbee
Can you run manage.py shell and connect to 'views?'


On Thu, Apr 4, 2013 at 4:13 PM, Mark Furbee  wrote:

> It would appear to me that your missing the path to django in your
> environment. When you upgraded did you also upgrade to another version of
> Python, perhaps? Is the dist-packages/site-packages django folder in the
> same place it was?
>
>
> On Thu, Apr 4, 2013 at 3:58 PM, Bastian wrote:
>
>> I have tried with runserver and debug = True and it gives me the error
>> but when I turn off debug then the site loads fine.
>> Then I installed gunicorn and with debug = true and the error appears but
>> with debug = False the site loads fine but without the static content.
>> I don't know if this is a clue about something wrong in the static
>> settings or if it's just a setting in gunicorn.
>>
>> Any idea?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

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




Re: I really about to give up Django

2013-08-22 Thread Mark Furbee
Try dropping the .value from referencia. Like {{
form.instance.idproduto.idmercadoria.referencia }}. Does this work?


On Thu, Aug 22, 2013 at 9:35 AM, Fellipe Henrique wrote:

> I tried again.. and work if I have just 1 FK, if I have more then one,
> doesn't work, like this:
>
> I have this models:
> Itens -> produto -> mercadoria
>
> itens:
>   idproduto = FK (produto)
> produto:
>   idmercadoria = FK(mercadoria)
> mercadoria:
>   referencia = Char
>
> I try to get "referencia" field, as you told:
>
> {{ form.instance.idproduto.idmercadoria.referencia.value }}
>
> doesn't work.. what I miss?
>
> Here is my complete models, forms and view: http://pastebin.com/w2TmyLzt
>
> Cheers,
>
>
> Em quinta-feira, 22 de agosto de 2013 13h24min31s UTC-3, Fellipe Henrique
> escreveu:
>
>> Ok, I read that, but the problem persist.. I try to use as you told, but
>> nothing show... and no errors appears..
>>
>> Sorry about my first line.. I just stop here, simple problem, in more
>> then 1 day, and I don't find any solution, anything on internet to...
>>
>> Cheers
>> Fellipe
>>
>>
>>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I really about to give up Django

2013-08-22 Thread Mark Furbee
Are your "nome" and "idade" fields displaying? If so, {{
form.instance.brinq.descricao }} should display the descricao field of the
brinq object associated with that Filhos instance bound to the form in the
formset.


On Thu, Aug 22, 2013 at 9:24 AM, Fellipe Henrique wrote:

> Ok, I read that, but the problem persist.. I try to use as you told, but
> nothing show... and no errors appears..
>
> Sorry about my first line.. I just stop here, simple problem, in more then
> 1 day, and I don't find any solution, anything on internet to...
>
> Cheers
> Fellipe
>
> Em quinta-feira, 22 de agosto de 2013 12h19min31s UTC-3, Tom Evans
> escreveu:
>
>> On Thu, Aug 22, 2013 at 3:28 PM, Fellipe Henrique 
>> wrote:
>> > Hi guys,
>> >
>> > I really about to give up from Django,
>>
>> So should I bother giving you the advice you asked for, since you are
>> just going to give up on Django?
>>
>> > because? I try to do something simple
>> > and I looking, looking around the internet and don't find anything
>> about
>> > this... try this simple example: http://pastebin.com/epazpBcZ
>> >
>> > I just want to get "descricao" field, from "Brinq" model, using a
>> > inlineformSet.
>> >
>> > I can't do this.. I try:  {{ form.brinq__descricao }} , {{
>> > form.brinq_id__descricao }}, {{ form.brinq.descricao }} and {{
>> > form.brinq_id__descricao }}
>> >
>> > I think it`s simple thing to do.. but I don't found anything to do this
>> in
>> > internet..
>> >
>> > Can any one help me in this simple question?
>> >
>> > Thanks.
>> >
>>
>> First of all, a model form that is bound to an instance of a model has
>> an attribute called 'instance' that represents the instance it is
>> bound to. This is mentioned all over the ModelForms documentation, eg
>> here:
>>
>> https://docs.djangoproject.**com/en/1.5/topics/forms/**
>> modelforms/#overriding-the-**clean-method
>>
>> and here:
>>
>> https://docs.djangoproject.**com/en/1.5/topics/forms/**
>> modelforms/#the-save-method
>>
>> Therefore, if you want to output things related to that instance, you
>> can use it in your template:
>>
>> {{ form.instance.brinq.descricao }}
>>
>>
>> Cheers
>>
>> Tom
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I really about to give up Django

2013-08-23 Thread Mark Furbee
Are you sure the idmercadoria is not None on that idproduto record?

{{ form.instance.idproduto.**idmercadoria }} Does this display anything?
How about {{ form.instance.idproduto }}?

If these don't display, verify the records in your database. In Django
templates, if something is None or does not exist, it will not raise an
exception, it just ignores it and remains blank. Also verify the referencia
field is not empty. If the field is 'NOT NULL' then it will be an empty
string if it is blank.



On Thu, Aug 22, 2013 at 12:58 PM, Fellipe Henrique wrote:

> No, nothing displayed..
>
> Em quinta-feira, 22 de agosto de 2013 13h38min04s UTC-3, Mark escreveu:
>>
>> Try dropping the .value from referencia. Like {{ form.instance.idproduto.
>> **idmercadoria.referencia }}. Does this work?
>>
>>
>> On Thu, Aug 22, 2013 at 9:35 AM, Fellipe Henrique wrote:
>>
>>> I tried again.. and work if I have just 1 FK, if I have more then one,
>>> doesn't work, like this:
>>>
>>> I have this models:
>>> Itens -> produto -> mercadoria
>>>
>>> itens:
>>>   idproduto = FK (produto)
>>> produto:
>>>   idmercadoria = FK(mercadoria)
>>> mercadoria:
>>>   referencia = Char
>>>
>>> I try to get "referencia" field, as you told:
>>>
>>> {{ form.instance.idproduto.**idmercadoria.referencia.value }}
>>>
>>> doesn't work.. what I miss?
>>>
>>> Here is my complete models, forms and view: http://pastebin.com/**
>>> w2TmyLzt 
>>>
>>>  Cheers,
>>>
>>>
>>> Em quinta-feira, 22 de agosto de 2013 13h24min31s UTC-3, Fellipe
>>> Henrique escreveu:
>>>
 Ok, I read that, but the problem persist.. I try to use as you told,
 but nothing show... and no errors appears..

 Sorry about my first line.. I just stop here, simple problem, in more
 then 1 day, and I don't find any solution, anything on internet to...

 Cheers
 Fellipe


>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I really about to give up Django

2013-08-23 Thread Mark Furbee
I see. I don't understand how this works: {{
itens.instance.idproduto.codigobarra
}} when this doesn't: {{ itens.instance.idproduto.idmercadoria.referencia }}

Can you post your template code?




On Fri, Aug 23, 2013 at 10:13 AM, Fellipe Henrique wrote:

> form.instance is "Pedido"  model, not "ItensPedido".
>
> My "ItensPedido" has "idproduto" not my "Pedido". and all idproduto has
> idmercadoria, it a required field, never, never go null`s this field.
>
> Cheers,
>
> Em sexta-feira, 23 de agosto de 2013 12h15min15s UTC-3, Mark escreveu:
>>
>> Are you sure the idmercadoria is not None on that idproduto record?
>>
>> {{ form.instance.idproduto.**idmerc**adoria }} Does this display
>> anything?
>> How about {{ form.instance.idproduto }}?
>>
>> If these don't display, verify the records in your database. In Django
>> templates, if something is None or does not exist, it will not raise an
>> exception, it just ignores it and remains blank. Also verify the referencia
>> field is not empty. If the field is 'NOT NULL' then it will be an empty
>> string if it is blank.
>>
>>
>>
>> On Thu, Aug 22, 2013 at 12:58 PM, Fellipe Henrique wrote:
>>
>>> No, nothing displayed..
>>>
>>> Em quinta-feira, 22 de agosto de 2013 13h38min04s UTC-3, Mark escreveu:

 Try dropping the .value from referencia. Like {{
 form.instance.idproduto.**idmerc**adoria.referencia }}. Does this work?


 On Thu, Aug 22, 2013 at 9:35 AM, Fellipe Henrique wrote:

> I tried again.. and work if I have just 1 FK, if I have more then one,
> doesn't work, like this:
>
> I have this models:
> Itens -> produto -> mercadoria
>
> itens:
>   idproduto = FK (produto)
> produto:
>   idmercadoria = FK(mercadoria)
> mercadoria:
>   referencia = Char
>
> I try to get "referencia" field, as you told:
>
> {{ form.instance.idproduto.**idmerc**adoria.referencia.value }}
>
> doesn't work.. what I miss?
>
> Here is my complete models, forms and view: http://pastebin.com/**w2Tm
> **yLzt 
>
>  Cheers,
>
>
> Em quinta-feira, 22 de agosto de 2013 13h24min31s UTC-3, Fellipe
> Henrique escreveu:
>
>> Ok, I read that, but the problem persist.. I try to use as you told,
>> but nothing show... and no errors appears..
>>
>> Sorry about my first line.. I just stop here, simple problem, in more
>> then 1 day, and I don't find any solution, anything on internet to...
>>
>> Cheers
>> Fellipe
>>
>>
>>>  --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@**googlegroups.**com.
> To post to this group, send email to django...@googlegroups.com.
>
> Visit this group at 
> http://groups.google.com/**group**/django-users
> .
> For more options, visit 
> https://groups.google.com/**grou**ps/opt_out
> .
>

  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to check if user is already in user database?

2015-01-16 Thread Mark Furbee
Yes, that link will cover the basics...

Here's a couple ways to find out if a query returns any records:

User.objects.filter(username=username).exists()  # .exists() returns
boolean if records are found.
User.objects.filter(username=username).count() != 0  # .count() returns
number of records in query.
User.objects.filter(username=username).first() is not None # .first()
returns the first record if there are matches, and None if there aren't


On Fri, Jan 16, 2015 at 9:11 AM, James Bennett 
wrote:

> This may be a good time to review Django's documentation on how to perform
> database queries:
>
>
> https://docs.djangoproject.com/en/1.7/topics/db/queries/#retrieving-a-single-object-with-get
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAL13Cg8MaAhTh%2B%3DoGTJ75jeZVY8-gt_hMkUTjZxyLxFkQ%2Bx36Q%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to check if user is already in user database?

2015-01-16 Thread Mark Furbee
Also, you can do a try/catch, but I don't really like this method,
personally:

try:
User.objects.get(username=username)
except User.DoesNotExist:
# user didn't exist in database.

On Fri, Jan 16, 2015 at 9:16 AM, Mark Furbee  wrote:

> Yes, that link will cover the basics...
>
> Here's a couple ways to find out if a query returns any records:
>
> User.objects.filter(username=username).exists()  # .exists() returns
> boolean if records are found.
> User.objects.filter(username=username).count() != 0  # .count()
> returns number of records in query.
> User.objects.filter(username=username).first() is not None # .first()
> returns the first record if there are matches, and None if there aren't
>
>
> On Fri, Jan 16, 2015 at 9:11 AM, James Bennett 
> wrote:
>
>> This may be a good time to review Django's documentation on how to
>> perform database queries:
>>
>>
>> https://docs.djangoproject.com/en/1.7/topics/db/queries/#retrieving-a-single-object-with-get
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAL13Cg8MaAhTh%2B%3DoGTJ75jeZVY8-gt_hMkUTjZxyLxFkQ%2Bx36Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAL13Cg8MaAhTh%2B%3DoGTJ75jeZVY8-gt_hMkUTjZxyLxFkQ%2Bx36Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: ANN: Django website redesign launched

2014-12-16 Thread Mark Furbee
Looks slick to me! Clearly with mobile and responsive design in mind, but
that's what we have to keep in mind these days.

Great job to all contributors involved in this redesign!

On Tue, Dec 16, 2014 at 4:01 PM, Cal Leeming  wrote:
>
> Personally I really like it.
>
> The footer menu contrast is a little bright with the white/light green,
> however it's worth noting that the color/contrast experience will vary
> depending on what equipment your using. Typically if a site has been
> designed on an Apple Thunderbolt/MBP Retina display, then it will look a
> bit crappy on many PC monitors (even the higher quality ones). I used to
> complain about site designs all the time when I was on a PC, since
> switching to an MBP most of these problems disappeared. The same goes for
> font weight, and indeed font rendering, typically OS X renders fonts much
> cleaner than Windows. (This is on the assumption that you are using a PC).
>
> Three spots (the design agency) look like they are using Macs in their
> office according to their office photos, so this might help explain why.
>
> However there are a few bugs;
>
> * code.djangoproject has some indenting issues on header tags (e.g.
> getting involved), and the shaded underline is weird, you can see this
> white background box around it then some grey fading... very strange.
> http://i.imgur.com/q2ejjq0.png
>
> * code.djangoproject ticket list table is "bleeding" over the right hand
> edge
> http://i.imgur.com/ALm4eX0.png
>
> * code.djangoproject query form is not properly designed, small font with
> oddly placed form elements and incorrect use of spacing;
> http://i.imgur.com/t2POMDL.png
>
> Gotta head to bed so I'll cut this short, hope this helps though.
>
> Cal
>
>
> On Tue, Dec 16, 2014 at 11:22 PM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>>
>>
>> On Wed, Dec 17, 2014 at 6:55 AM, Schmitt, Christian <
>> c.schm...@briefdomain.de> wrote:
>>
>>> Somehow I hate it. The website is the worst website I've seen since a
>>> long time.
>>> The contrast is really aweful.
>>> The issue Tracker got unusable due to the colors that aren't focused on
>>> readability.
>>>
>>> Overall it looks like a mess, just to have a new design.
>>>
>>> Doesn't look like a designer or a graphic guy had his hands on that.
>>> I can't realized why some should replace a good and usable design which
>>> had some practical usage and also a good readability with the "thing" we
>>> have now.
>>>
>>> Sorry but I will stick to the old docs as for now or use the PDF ones
>>> with my custom style (since your colors are aweful, too).
>>>
>>> Django should focus on a clear design which is helpful for readability
>>> and not this stupid mess.
>>>
>>
>> Thanks for the feedback. Sorry you don't like what we've rolled out.
>>
>> I can assure you that we *did* engage a "designer or graphic guy" in this
>> process - several in fact - and they all have significant experience in
>> designing "usable designs" with "practical usage". The blog post announcing
>> the launch has the details.
>>
>> The old design was a classic, but you can't say it didn't have problems -
>> from a technical perspective, it was almost unusable on mobile devices;
>> from a functional perspective, it didn't provide a way for us as a project
>> to highlight community efforts, or draw attention to the DSF or provide
>> calls to action for people who aren't discovering Django for the first time.
>>
>> If you've got specific feedback - something we can actually fix or
>> address, not "I don't like it" - please open a ticket. We've already had
>> some comments raised about contrast, which the team is looking into. If
>> there's something else we should know about, let us know and we can address
>> it.
>>
>> Yours,
>> Russ Magee %-)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAJxq848JSv9gw4C-RpPDuVJi994%2B%2BFOctqp8LYp%2BhqBVE%3DjSgw%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://gr

Re: (1364, "Field 'id' doesn't have a default value") - mysql issue?

2014-04-09 Thread Mark Furbee
You say you imported the database. Did you use syncdb to set up the tables?
It sounds like your comment_id field in MySQL is not set as an
auto-incrementing primary key field. Do you have access to that MySQL
database to check, and or update that field definition?


On Wed, Apr 9, 2014 at 2:42 PM, Adam Teale  wrote:

> Hi Guys
>
> I have been working on a django app that was going well using an sqlite db.
> I've moved it over to mysql and imported the database
>
> Everything looks good
>
> But when I try to use the django comment system that was working well on
> the sqlite db before I get:
>
> OperationalError at /comments/post/
> (1364, "Field 'id' doesn't have a default value")
> Request Method: POST
> Request URL: http://192.168.1.143/comments/post/
> Django Version: 1.6.2
> Exception Type: OperationalError
> Exception Value:
> (1364, "Field 'id' doesn't have a default value")
> Exception Location: 
> /Users/admin/Dropbox/mstudio/code/mBrain/mbrain/venv/lib/python2.7/site-packages/MySQLdb/connections.py
> in defaulterrorhandler, line 36
> Python Executable:
>
>
> I'm a little lost - do i need to set a default value for
> the django.contrib.comments model?
> And how would i do that if I needed to - this has an Object ID field - i
> don't know how I'd set that up
>
>
> Any ideas? What am i missing?
>
> Many thanks!
>
> Adam
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/18894c72-24c9-41cd-85a1-4dc09072dfb8%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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