Re: get_absolute_url returning empty string

2012-07-25 Thread Victor Rocha
Your get_absolute_url method is in the wrong format:::

it should be:
   @models.permalink
def get_absolute_url(self):
 return ("view_name", #view name
) 

On Tuesday, July 24, 2012 1:58:26 PM UTC-4, Jeff Green wrote:
>
> I am stuck in trying to figure out why the get_absolute_url call in my 
> template is giving me empty string.
>  
> Here is my models.py
>  
> class Category(models.Model):
> name = models.CharField(max_length=50)
> description = models.TextField()
> slug = models.SlugField(max_length=50, unique=True,
> help_text='Unique value for product page URL, created from name')
> description = models.TextField()
> is_active = models.BooleanField(default=True)
> meta_keywords = models.CharField("Meta keywords", max_length=255,
> help_text='Comma-delimited set of SEO keywords for meta tag')
> meta_description = models.CharField("Meta description", max_length=255,
> help_text='Content for meta description tag')
> created_at = models.DateTimeField(auto_now_add=True)
> updated_at = models.DateTimeField(auto_now=True)
> class Meta:
> db_table = 'categories'
> ordering = ['name']
> verbose_name_plural = 'Categories'
> def __unicode__(self):
> return self.name
> @models.permalink
> def get_absolute_url(self):
>  return (show_category', [self.slug])
> 
> My urls.py
>  
> urlpatterns = patterns('catalog.views',
> url(r'^$', 'index', { 'template_name': 'catalog/index.html'}, 
> 'catalog_home'),
> url(r'^category/(?P[-\w+])/$', 'show_category'),
> url(r'^product/(?P[-\w+])/$',
> 'show_product',
> { 'template_name': 'catalog/product.html'}, 'catalog_product'),
> )
>  
> My views.py
>  
> def show_category(request, category_slug, 
> template_name='catalog/category.html'):
> c = get_object_or_404(Category, slug=category_slug)
> products = c.product_set.all()
> page_title = c.name
> meta_keywords = c.meta_keywords
> meta_description = c.meta_description
> return render_to_response(template_name, locals(),
> context_instance=RequestContext(request))
>  
> My template
>  
> Categories
> {% for c in active_categories %}
> {{ c.name }}
> {% endfor %}
>  
> Any help would be greatly appreciated. Thanks.
>  
> 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/-/QapYPqc7mFIJ.
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: get_absolute_url returning empty string

2012-07-25 Thread Victor Rocha
your get absolute url method is in the wrong format::
if should be.

@models.permalink
def get_absolute_url(self):
  return ("view_name", #view name,
(), #tuble of positional args
   {}, #dict of name kwargs
)

In your case, this is what the method should look like:

@models.permalink
def get_absolute_url(self):
  return ("show_category", #view name,
(), #tuble of positional args
   {"category_slug":self.slug}, #dict of name kwargs
)

On Tuesday, July 24, 2012 1:58:26 PM UTC-4, Jeff Green wrote:
>
> I am stuck in trying to figure out why the get_absolute_url call in my 
> template is giving me empty string.
>  
> Here is my models.py
>  
> class Category(models.Model):
> name = models.CharField(max_length=50)
> description = models.TextField()
> slug = models.SlugField(max_length=50, unique=True,
> help_text='Unique value for product page URL, created from name')
> description = models.TextField()
> is_active = models.BooleanField(default=True)
> meta_keywords = models.CharField("Meta keywords", max_length=255,
> help_text='Comma-delimited set of SEO keywords for meta tag')
> meta_description = models.CharField("Meta description", max_length=255,
> help_text='Content for meta description tag')
> created_at = models.DateTimeField(auto_now_add=True)
> updated_at = models.DateTimeField(auto_now=True)
> class Meta:
> db_table = 'categories'
> ordering = ['name']
> verbose_name_plural = 'Categories'
> def __unicode__(self):
> return self.name
> @models.permalink
> def get_absolute_url(self):
>  return (show_category', [self.slug])
> 
> My urls.py
>  
> urlpatterns = patterns('catalog.views',
> url(r'^$', 'index', { 'template_name': 'catalog/index.html'}, 
> 'catalog_home'),
> url(r'^category/(?P[-\w+])/$', 'show_category'),
> url(r'^product/(?P[-\w+])/$',
> 'show_product',
> { 'template_name': 'catalog/product.html'}, 'catalog_product'),
> )
>  
> My views.py
>  
> def show_category(request, category_slug, 
> template_name='catalog/category.html'):
> c = get_object_or_404(Category, slug=category_slug)
> products = c.product_set.all()
> page_title = c.name
> meta_keywords = c.meta_keywords
> meta_description = c.meta_description
> return render_to_response(template_name, locals(),
> context_instance=RequestContext(request))
>  
> My template
>  
> Categories
> {% for c in active_categories %}
> {{ c.name }}
> {% endfor %}
>  
> Any help would be greatly appreciated. Thanks.
>  
> 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/-/nlKbk7rrrPgJ.
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: Automated updating of data across staging and production environments?

2012-07-26 Thread Victor Rocha
I partly agree with the above question. It's a solution, but you usually 
never want to use your production database on a development server. 

As for his problem, I would look into fabric. You can easily write a 
function that dumps data from one database and into another.


On Thursday, July 26, 2012 6:10:33 AM UTC-4, Lloyd Dube wrote:
>
> Hi all,
>
> We have an Ubuntu Linux server which is running virtual environments (one 
> for staging, one for prod.). Our clients test their sites on the staging 
> environment and then proceed to capture the same data on the live sites. 
> They want to be able to, at the click of a button, migrate only the latest 
> data to the live sites. If users have submitted new data (e.g. contact 
> requests) on the prod. server, this data must not be affected.
>
> Is it possible to achieve this, and if so, are there any tools oout there 
> to consider? Any feedback would be appreciated.
>
> Thanks.
>
> -- 
> Regards,
> Sithembewena Lloyd Dube
>

-- 
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/-/aA6OI_LFyk4J.
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: Returning data belonging to a model (FK)

2012-07-27 Thread Victor Rocha
David,

Django already comes with a built-in contenttypes application which does 
exactly what you trying to accomplish, i think.

You should read the documentation:
https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/



On Friday, July 27, 2012 8:47:37 AM UTC-4, David wrote:
>
> Hi
>
> I am trying to abstract one of my applications.
>
> for f in self._meta.fields:
> print f
> if f.get_internal_type() == "ForeignKey":
> for o in f.related.parent_model.objects.all():
>
> I am using the above code to isolate any fields in self._meta.fields that 
> are foreign keys. I need to get data from these foreignkey relations to 
> other models.
>
> Is this possible please?
>
> Thank you
>

-- 
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/-/3LeoMbfXKkMJ.
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: form.errors is not a dictionary?

2012-08-01 Thread Victor Rocha
Read the above reply.

When you print form.error --> prints out a custom __unicode__ for you to 
use in your templates.
However, you can iterate over form.errors and it will act as a normal dict.



On Wednesday, August 1, 2012 1:56:28 AM UTC-4, vivek soundrapandi wrote:
>
> I too have the same problem. How did you fix it?
>
> On Wednesday, April 6, 2011 2:13:48 AM UTC+5:30, Roy Smith wrote:
>>
>> I'm using django-1.3 .  I have a view with the following code: 
>>
>> def item_create(request): 
>> if request.method == 'POST': 
>> form = ItemForm(request.POST) 
>> if form.is_valid(): 
>> url = form.cleaned_data['url'] 
>> item.save() 
>> return HttpResponseRedirect('/') 
>> else: 
>> print form.errors 
>>
>> when I submit the form, I expected that form.errors would print out as 
>> a dict, as documented in 
>> http://docs.djangoproject.com/en/1.3/ref/forms/api/#using-forms-to-validate-data.
>>  
>>
>> Instead, I'm getting a hunk of HTML: 
>>
>>
>> Django version 1.3, using settings 'soco-site.settings' 
>> Development server is running at http://0.0.0.0:7626/ 
>> Quit the server with CONTROL-C. 
>> date_addedThis 
>> field is required.user_id> class="errorlist">This field is required. 
>> [05/Apr/2011 16:36:32] "POST /item/create/ HTTP/1.1" 200 718 
>>
>> Is my understanding wrong, or is this a bug? 
>>
>

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



Re: How to override an attribute?

2012-08-05 Thread Victor Rocha
What about you do what the error is telling you to do?
All you need to do its to add a related name to your field definitions and 
that will fix it.

If you need me to fix it for you, post some real code.
  

On Saturday, August 4, 2012 10:55:13 AM UTC-4, . wrote:
>
> Hello, 
>
> I'm trying to do the same [1]. 
> I've already tried all solutions from stackoverflow but none of them 
> worked. 
>
> [1] 
> http://stackoverflow.com/questions/2344751/in-django-model-inheritance-does-it-allow-you-to-override-a-parent-models-a
>  
>

-- 
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/-/5pOWCEA7Sw0J.
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 user should not login on multiple machine with same username and passowrd when user already login on one machine

2012-08-10 Thread Victor Rocha
That would imply that the user needs to log out of the other machine before 
login into this one. For that reason you would also need to include another 
view to log an authenticated user out of any other machines. I said an 
authenticated user because you need to make sure that the user trying to 
log out of other machines is who he says he is.

The other way is to make the user manually log out of his machine before 
log in to another, however, that seems like a hassle for the user. Security 
seems much more improved this way though.



On Friday, August 10, 2012 10:15:01 AM UTC-4, Mengu wrote:
>
> there are two simple ways.
>
> have your own login view first. in your own login logic:
>
> 1) assuming you have a UserProfile model, add a field called is_online. in 
> your login view after logging the user successfully, set the is_online 
> field for this user to True.
> 2) if you are using redis or memcached instead of hitting the db, you can 
> have a simple key like ("user_%s_is_online" % username)  and expire it 
> until your session expires. 
>
> depending on the way you choose, before logging the user in, you simply 
> check if that user is online or not. if the user is online you can show an 
> error message like "you are already logged in somewhere else."
>
> On Friday, August 10, 2012 4:12:51 PM UTC+3, NIL ZONE wrote:
>>
>> user login on one machine, should not login on another machine with same 
>> username and password in django
>>
>

-- 
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/-/--Ki25552rwJ.
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 Admin asks password every operation

2012-10-06 Thread Victor Rocha
Depending on what exactly you want to accomplish to match the root to a 
url, I do as follow:
url(r'^$', 'earth.views.Home'),

However, it is sometimes good to have a default page if a request didnt 
match the url requested (I would use this as the very last rule, otherwise 
it will catch every request):
url(r'^', 'earth.views.Home'),

As for your origina question, are you sure you have your session middleware 
activated?

On Saturday, October 6, 2012 9:53:36 AM UTC-4, Stefano T wrote:
>
> What i want is to match the root of my website with a url.
>
> On Saturday, October 6, 2012 12:53:08 AM UTC+2, ke1g wrote:
>>
>> All urls match this.  The regular expression says "any URL that starts 
>> from the beginning, no matter what follows.  I suspect that you want 
>> 'r^$' 
>>
>> Bill 
>>
>> On Fri, Oct 5, 2012 at 2:15 PM, Stefano T 
>>  wrote: 
>> > wait i may have spotted out the problem: 
>> > if i've an app, is this the correct url pattern for the homepage? 
>> > 
>> > url(r'^', 'earth.views.Home'), 
>> > 
>> > or does it take ll the urls? 
>> > 
>> > 
>> > On Friday, October 5, 2012 8:10:09 PM UTC+2, Stefano T wrote: 
>> >> 
>> >> i didn't est SESSION_COOKIE_AGE anywhere, so i suppose it's set to its 
>> >> default value. 
>> >> Cookies are enabled. 
>> >> i'm facing the problem in chrome (i deleted all the browser data, 
>> nothing 
>> >> changed) 
>> >> with FF it works. 
>> >> Before it was working with chrome, suddently it stopped. 
>> >> 
>> >> On Friday, October 5, 2012 7:32:16 PM UTC+2, Larry@gmail.comwrote: 
>> >>> 
>> >>> On Fri, Oct 5, 2012 at 10:57 AM, Stefano T 
>> >>>  wrote: 
>> >>> > Hi all. 
>> >>> > i'm new to django and i'm facing a problem i can't solve so far. 
>> >>> > Basically, when i log in in the admin part, every operation i do it 
>> >>> > ask me for the login. doesn't matter which browser i user, it's 
>> always 
>> >>> > the same. 
>> >>> > at the beginning it was acting normally: once logged in i stay 
>> logged 
>> >>> > in until the logout. 
>> >>> > idea? 
>> >>> 
>> >>> What is SESSION_COOKIE_AGE set to in your settings file? Or are 
>> >>> cookies disabled for your browser? 
>> > 
>> > -- 
>> > 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/-/jJ7LrE2_TC0J. 
>> > 
>> > 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/-/870HncbaK18J.
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: Date widget not HTML5

2012-10-25 Thread Victor Rocha
You need to roll out your own widget.

I assume django will have html5 support in the near future.


On Wednesday, October 24, 2012 1:04:07 PM UTC-4, Juan Pablo Tamayo wrote:
>
>
>
> Is there any reason not to have the date widget input tag have the 
> attribute type="date" instead of just type="text"?
>
> I mean, most browser do not treat it differently, but it tells them that 
> they should; besides it would mean that Django tries to support the full 
> range of HTML5.
>
>
> Is there a way to change this particular behavior?
>
> Thanks in advance fellow Django-mates!!!
>

-- 
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/-/sCLLhz7VluIJ.
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: Using Emails to authenticate

2012-11-04 Thread Victor Rocha
I haven't heard of a package that does what you need. I will try to help 
you as much as possible.

I use django-registration to handle user registration. It provides a form 
named RegistrationFormUniqueEmail, this form, as its name suggests, will 
ensure that the email used is unique.

For login: implement an authentication backend that makes sure that the 
password and email match. It should look something like this:
# Overwrite the default backend to check for e-mail address 

class EmailBackend(ModelBackend):

def authenticate(self, username=None, password=None):
#If username is an email address, then try to pull it up
try:
user = User.objects.get(email__iexact=username)
except User.DoesNotExist:
return None

if user.check_password(password):
return user

Let me know if you have any questions.


On Sunday, November 4, 2012 2:09:36 AM UTC-5, Frankline wrote:
>
> Hi all,
>
> I guess this question has been asked here a couple of times but I'm going 
> to ask it anyway.
>
> I'm developing a Django application/website and I have a need to use the 
> email for authentication instead of username. I'm more keen to find out how 
> you handle the following:
>
> - The default length of the email field
> - Ensuring that the email field remain unique
> - Making/Synchronizing the changes with the database
>
> I'm more biased towards handling this myself rather than using the 
> available packages out there.
>
> Does any one have a pointer to a link on how this is handled?
>
> Thanks.
>
> Regards,
> F. O. O.
>

-- 
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/-/cUq4lreToHgJ.
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: TypeError:

2012-11-16 Thread Victor Rocha
Take a look at this thread. 
https://groups.google.com/forum/?fromgroups=#!topic/django-users/Z_AXgg2GCqs

It seems that your custom field is outdated. Field objects in django 1.4 
now take two new named arguments: "connection" and "prepared". Update your 
field to be in compliance with new django 1.4 specifications and you should 
be fine.

Thank you,
Victor Rocha
RochApps.com


On Thursday, November 15, 2012 3:05:02 PM UTC-5, Satinder Goraya wrote:
>
> I am using a custom field "SeparatedValuesField" for saving array 
> values in my models. When i tried to save the values in it, in the 
> python shell, it gives the following error: 
>  TypeError: get_db_prep_value() got an unexpected keyword argument 
> 'connection' 
> Is anybody know, what error is this, and how will save the array 
> values to my models. 
> -- 
> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/5FIrn7R-NCkJ.
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: What used @models.permalink and get_absolute_url? Please an example to better understand this. An example of the documentation is not clear to me

2012-11-17 Thread Victor Rocha
In order to use get_absolute_url, first of all you need to have named urls. 
Lets imagine we have the following named url.

  url(r'^accounts/(P?d+)/$',
DetailView.as_view(
  template_name='accounts/details.html',
), name='account_details')

In order to referece this url in a template you have to alternatives, 
actually 3:
  1) You can hardcode the url, eg. /accounts/1
  2) Do a reverse url lookup, eg. {% url account_details pk=1%}
  3) Use the get_absolute_url method on your instance, eg. 
account.get_absolute_url

As you can see, using the get_absolute_url makes for a less hardcoded url; 
changin parameters in your view wouldn't mean having to go back in your 
templates and updating each one of the references to the url.

In order to define a get_absolute_url in your model you need to use the 
@permalink decorator.

@models.permalink
def get_absolute_url(self):
  return ('account_details', #name of the view you are reversing
  (), # a tuple of all the positional parameter your view takes
  {'pk':self.id}, # a dict of all the named arguments your view takes
)



On Friday, November 16, 2012 10:03:08 AM UTC-5, enemytet wrote:
>
> How (and why) to use @models.permalink and get_absolute_url? 
>
> Please an example to better understand this. An example of the 
> documentation is not clear to me
>

-- 
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/-/vxjgwK838d4J.
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: Editing model instance

2012-11-23 Thread Victor Rocha
For starters, I see more than one thing wrong with your code. I hope thats 
not the one your actually using and it was just a typo when you asked the 
question.
+ jform = editJobForm(request.POST, instance=job) # job has not 
being defined.
Also when you instantiate your form, you want to use and instance of the 
class your want to use, for instance.
clientjob = ClientEditJob.objects.get(job_id =query) 
job = EditJob.objects.get(job_id=query)

Right now you using this: clientjob = ClientJob.objects.get(job_id = 
query). ClientJob is not a model for any of the two forms you are using.

Let me know if I was of any help,
Victor Rocha
RochApps <http://www.rochapps.com>


On Thursday, November 22, 2012 5:59:11 AM UTC-5, sandy wrote:
>
> I edit value of a table using model instance, however after editing I 
> want the values to be saved in some other table with same structure. 
> For this to happen I have used following code in views.py : 
>
> def editjob(request): 
> clientjob = ClientJob.objects.get(job_id = query) 
> if request.method == "POST": 
> jform = editJobForm(request.POST, instance=job) 
> sform = editClientJobForm(request.POST, 
> instance=clientjob) 
> if jform.is_valid() and sform.is_valid(): 
> jform.save() 
> sform.save() 
> return 
> render_to_response('tcc/succes.html',context_instance=RequestContext(request))
>  
>
> else: 
> jform = editJobForm(instance=job) 
> sform = editClientJobForm(instance=clientjob) 
> return render_to_response('tcc/edit_job.html', {'jform': 
> jform,'sform':sform},context_instance=RequestContext(request)) 
>
> where : 
> class editJobForm(forms.ModelForm): 
> class Meta : 
> model = EditJob 
> exclude= ['client','job_no','id'] 
>
> class editClientJobForm(forms.ModelForm): 
>
> class Meta : 
> model = ClientEditJob 
> exclude= ['job'] 
>
> However this code saves the value in same instance itself. What I want 
> is to get old values from table: Job and ClientJob and then after 
> editing get saved in tables: EditJob and ClentEditJob. 
> Is this possible? Your help will be appreciated. 
> Thank you. 
>
> -- 
> Sandeep Kaur 
> E-Mail: mkaur...@gmail.com  
> Blog: sandymadaan.wordpress.com 
>

-- 
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/-/H6ly_fe2CXEJ.
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: Editing model instance

2012-11-23 Thread Victor Rocha
This would be the code I would like you to try:

def editjob(request): 
clientjob = ClientEditJob.objects.get(job_id =query) 
#adjust query as needed
job = EditJob.objects.get(job_id=query)#adjust query as 
needed
if request.method == "POST": 
jform = editJobForm(request.POST, instance=job) 
sform = editClientJobForm(request.POST, 
instance=clientjob) 
if jform.is_valid() and sform.is_valid(): 
jform.save() 
sform.save() 
return 
render_to_response('tcc/succes.html',context_instance=RequestContext(request)) 
else: 
jform = editJobForm(instance=job) 
sform = editClientJobForm(instance=clientjob) 
return render_to_response('tcc/edit_job.html', {'jform': 
jform,'sform':sform},context_instance=RequestContext(request)) 

Thank you,
Victor Rocha
RochApps <http://RochApps.com>

On Friday, November 23, 2012 8:55:06 AM UTC-5, Victor Rocha wrote:
>
> For starters, I see more than one thing wrong with your code. I hope thats 
> not the one your actually using and it was just a typo when you asked the 
> question.
> + jform = editJobForm(request.POST, instance=job) # job has not 
> being defined.
> Also when you instantiate your form, you want to use and instance of the 
> class your want to use, for instance.
> clientjob = ClientEditJob.objects.get(job_id =query) 
> job = EditJob.objects.get(job_id=query)
>
> Right now you using this: clientjob = ClientJob.objects.get(job_id = 
> query). ClientJob is not a model for any of the two forms you are using.
>
> Let me know if I was of any help,
> Victor Rocha
> RochApps <http://www.rochapps.com>
>
>
> On Thursday, November 22, 2012 5:59:11 AM UTC-5, sandy wrote:
>>
>> I edit value of a table using model instance, however after editing I 
>> want the values to be saved in some other table with same structure. 
>> For this to happen I have used following code in views.py : 
>>
>> def editjob(request): 
>> clientjob = ClientJob.objects.get(job_id = query) 
>> if request.method == "POST": 
>> jform = editJobForm(request.POST, instance=job) 
>> sform = editClientJobForm(request.POST, 
>> instance=clientjob) 
>> if jform.is_valid() and sform.is_valid(): 
>> jform.save() 
>> sform.save() 
>> return 
>> render_to_response('tcc/succes.html',context_instance=RequestContext(request))
>>  
>>
>> else: 
>> jform = editJobForm(instance=job) 
>> sform = editClientJobForm(instance=clientjob) 
>> return render_to_response('tcc/edit_job.html', {'jform': 
>> jform,'sform':sform},context_instance=RequestContext(request)) 
>>
>> where : 
>> class editJobForm(forms.ModelForm): 
>> class Meta : 
>> model = EditJob 
>> exclude= ['client','job_no','id'] 
>>
>> class editClientJobForm(forms.ModelForm): 
>>
>> class Meta : 
>> model = ClientEditJob 
>> exclude= ['job'] 
>>
>> However this code saves the value in same instance itself. What I want 
>> is to get old values from table: Job and ClientJob and then after 
>> editing get saved in tables: EditJob and ClentEditJob. 
>> Is this possible? Your help will be appreciated. 
>> Thank you. 
>>
>> -- 
>> Sandeep Kaur 
>> E-Mail: mkaur...@gmail.com 
>> Blog: sandymadaan.wordpress.com 
>>
>

-- 
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/-/VqO7RYOxjf4J.
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 1.4 manage.py cannot find settings

2012-12-25 Thread Victor Rocha
Hi,

I would like to ask you to post a snapshot of your dir structure. In the 
mean time, I am going to give you some pointers that you could consider. Is 
the an app you converted to django 1.4 or did you created your app from 
scratch(using 1.4 from the beginning)?

If you converted you app your Error("Could not import settings 
'test.test.settings' (Is it on sys.path?): ") indicates that you set your 
"DJANGO_SETTINGS_MODULE" is set incorrectly. Open your manage.py file and 
set it the django environmental variable to "test.settings".

If you created your app using django 1.4 from the beginning, I don't see 
how this error could happen! Django lays out your project for you and sets 
everything correctly. 

Thank you,
Victor Rocha
RochApps <http://www.rochapps.com>


On Tuesday, December 25, 2012 8:22:10 AM UTC-5, huw_at1 wrote:
>
> Hi,
>
> This has probably been asked a million times before so apologies. I'm new 
> to 1.4 so the standard project layout is a little unfamiliar. I'm trying to 
> perform a simple import from within my shell:
>
> from django.contrib.sites.models import Site
>
> However I am constantly getting the problem that my settings are not being 
> found:
>
> raise ImportError("Could not import settings '%s' (Is it on 
> sys.path?): %s" % (self.SETTINGS_MODULE, e))
> ImportError: Could not import settings 'test.test.settings' (Is it on 
> sys.path?): No module named test.settings
>
> In the past I would have thought that this was an issue as the project and 
> the "app" had the same name although in the case of 1.4 the settings are 
> placed in a directory with the same name as the project. I'm not sure what 
> I should change to get this to work.
>
> Has this been seen before or any ideas?
>
> Many thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BjA9V-YqpBgJ.
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 1.4 manage.py cannot find settings

2012-12-25 Thread Victor Rocha
I don't have much experience using PyCharm, however from I can understand,
your issues may be alleviated by adding a ___init__.py file at the same
level as your manage.py file. Can you set which dir is the project's root
dir? can you show me the content of your manage.py file?

I am still concern about this 'test.test.settings'  it should only be
'test.settings'

Thank you,
Victor Rocha
RochApps <http://www.rochapps.com/>


On Tue, Dec 25, 2012 at 10:22 AM, huw_at1  wrote:

> Thank you,
> Victor Rocha
> RochApps <http://www.rochapps.com>
>

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



Re: Django 1.4 manage.py cannot find settings

2012-12-25 Thread Victor Rocha
I don't think I can be of more help. Hopefully someone with experience with
PyCharm can chime in.
This is probably not what you want to hear but ditch windows, ditch pycharm
use windows and vim or at least gedit.

One last comment, in your manage.py file i can see this 'pkadata.settings';
i didnt see that directory when you showed me your file structure.



On Tue, Dec 25, 2012 at 12:01 PM, huw_at1  wrote:

> pkadata.settings

-- 
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: Django 1.4 manage.py cannot find settings

2012-12-25 Thread Victor Rocha
Your welcome! Merry Christmas



On Tue, Dec 25, 2012 at 12:25 PM, huw_at1  wrote:

> Hiya - sorry yeah I pasted the wrong manage.py file initially. It should
> have been the test.settings manage.py.
>
> I figured it out partially anyway - I needed to change the project
> directory setting in the IDE as you said.
>
> Thanks for the help.
>
>
> On Tuesday, December 25, 2012 5:14:03 PM UTC, Victor Rocha wrote:
>
>> I don't think I can be of more help. Hopefully someone with experience
>> with PyCharm can chime in.
>> This is probably not what you want to hear but ditch windows, ditch
>> pycharm use windows and vim or at least gedit.
>>
>> One last comment, in your manage.py file i can see this 'pkadata.settings';
>> i didnt see that directory when you showed me your file structure.
>>
>>
>>
>> On Tue, Dec 25, 2012 at 12:01 PM, huw_at1  wrote:
>>
>>> pkadata.settings
>>
>>
>>  --
> 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/-/xbeOEaE7Ah4J.
>
> 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: Django 1.4 manage.py cannot find settings

2012-12-25 Thread Victor Rocha
Would you please describe all you have to do to resolve it, in case someone
else stumbles upon the same issue?

Thank you,
Victor Rocha
RochApps 

On Tue, Dec 25, 2012 at 5:51 PM, huw_at1  wrote:

> [RESOLVED]
>
>
> On Tuesday, 25 December 2012 17:28:15 UTC, Victor Rocha wrote:
>
>> Your welcome! Merry Christmas
>>
>>
>>
>> On Tue, Dec 25, 2012 at 12:25 PM, huw_at1  wrote:
>>
>>> Hiya - sorry yeah I pasted the wrong manage.py file initially. It should
>>> have been the test.settings manage.py.
>>>
>>> I figured it out partially anyway - I needed to change the project
>>> directory setting in the IDE as you said.
>>>
>>> Thanks for the help.
>>>
>>>
>>> On Tuesday, December 25, 2012 5:14:03 PM UTC, Victor Rocha wrote:
>>>
>>>> I don't think I can be of more help. Hopefully someone with experience
>>>> with PyCharm can chime in.
>>>> This is probably not what you want to hear but ditch windows, ditch
>>>> pycharm use windows and vim or at least gedit.
>>>>
>>>> One last comment, in your manage.py file i can see this 'pkadata.settings';
>>>> i didnt see that directory when you showed me your file structure.
>>>>
>>>>
>>>>
>>>> On Tue, Dec 25, 2012 at 12:01 PM, huw_at1  wrote:
>>>>
>>>>> pkadata.settings
>>>>
>>>>
>>>>  --
>>> 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/-/**xbeOEaE7Ah4J<https://groups.google.com/d/msg/django-users/-/xbeOEaE7Ah4J>
>>> .
>>>
>>> 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<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/-/QDMIerGSTp8J.
>
> 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: Get objects sorted by time of last comment

2013-01-05 Thread Victor Rocha
Hi Vibhu,

You have more than one option, I think:
1)Modify model's Meta class and add an order_by = 
('-comment__creation_date',)
2)Make a view that does just that last_threads_commented = 
Thread.comments.order_by('-comment__creation_date')
3)Make a custom template tag that does all of the heavy lifting behind the 
scenes.

disclaimer: I am not really sure if you can employed any of the methods 
listed here on a Generic Model tho, use at your own risk...

thank you,
Victor Rocha
RochApps <http://www.rochapps.com>

On Wednesday, January 2, 2013 1:50:17 AM UTC-5, Vibhu Rishi wrote:
>
> Hi All, 
>
> A very happy new year to you all !
>
> I am working on a website I am making as my hobby project. It is to do 
> with motorcycle touring. 
>
> I have done some initial work on it, and incrementally making changes as 
> and when I can. 
>
> I am trying to figure out the following issue : 
> 1. I have a forum object where people can start threads. 
> 2. the forum object uses the django comments module along with mptt. So 
> far so good. 
> 3. Now, I want to show the "latest commented on" posts. But I am not able 
> to figure it out. 
>
> For reference : http://bikenomads.herokuapp.com/
>
> On the box on the right, I want to show the posts based on the last 
> comment time. However, all I can do right now is show the last post based 
> on creation time (this is a field for the post object). I am not able to 
> figure out how to sort based on comment time. 
>
> Solutions :
> 1. Ideally there should be a way to sort object by comment time using the 
> inbuilt comments module in django. Is this possible ? 
> 2. Alternatively, I will need to update the post model to have another 
> field for 'last_comment_time' and when someone posts a comment, I will need 
> to update this field. I would rather not do this as I will need to make 
> sure all the objects using comments will need to have this exact field. 
>
> What would you suggest ? 
>
> Vibhu
>
> -- 
> Simplicity is the ultimate sophistication. - Leonardo da Vinci
> Life is really simple, but we insist on making it complicated. - Confucius 
>

-- 
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/-/t_Drdvmj9AEJ.
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 FilteredSelectMultiple widget

2013-01-31 Thread Victor Rocha
Can you post up your code?


On Thursday, January 31, 2013 6:29:08 AM UTC-5, KVR wrote:
>
> Hi,
> I am trying to reuse FilteredSelectMultiple widget from django admin 
> widgets.
>
> I've defined my form and media classes, and included form and media 
> contexts in my template also.
>
> But when I load the page, it's just showing multiselect box and below line:
>
> 
>
> What may be the problem and how to get the entire widget.
>
> Regards,
> kvr
>
>

-- 
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: Problem with FilteredSelectMultiple widget

2013-02-01 Thread Victor Rocha
I remember running into this problem quite sometime ago. What happens is
that in order to access the file jsi18n you need to be logged in. What you
need to do it's save a copy of the file and point to the file instead.

thank you,
Victor rocha
rochapps.com

On Fri, Feb 1, 2013 at 11:52 PM, KVR  wrote:

> forms.py
> class SampleWidget(forms.Form):
> date=forms.CharField(widget=AdminDateWidget,max_length=100)
> users =
> forms.ModelMultipleChoiceField(queryset=User.objects.all(),widget=FilteredSelectMultiple(("Users"),
> False))
>
>
> mytemple.html
>
> {% block content %}
> 
>  />
> 
>
> window.__admin_media_prefix__ =
> "/static/admin/";
>
>
> 
> 
>  src="/static/admin/js/admin/RelatedObjectLookups.js">
> 
>  src="/static/admin/js/jquery.init.js">
> 
>  src="/static/admin/js/SelectBox.js">
>  src="/static/admin/js/SelectFilter2.js">
> 
>  src="/static/admin/js/admin/DateTimeShortcuts.js">
>
> 
> {{ form.as_p }}
> {{ form.media }}
> {% csrf_token %}
> 
> 
>
>
> This working fine if I log in with admin credentials , how to use this
> with normal user.
>
> Please help me.
>
> Regards,
> kvr
>
> On Thursday, January 31, 2013 9:44:11 PM UTC+5:30, Victor Rocha wrote:
>>
>> Can you post up your code?
>>
>>
>> On Thursday, January 31, 2013 6:29:08 AM UTC-5, KVR wrote:
>>>
>>> Hi,
>>> I am trying to reuse FilteredSelectMultiple widget from django admin
>>> widgets.
>>>
>>> I've defined my form and media classes, and included form and media
>>> contexts in my template also.
>>>
>>> But when I load the page, it's just showing multiselect box and below
>>> line:
>>>
>>> 
>>>
>>> What may be the problem and how to get the entire widget.
>>>
>>> Regards,
>>> kvr
>>>
>>>  --
> 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: Problem with FilteredSelectMultiple widget

2013-02-01 Thread Victor Rocha
One way around this is to call the view on a different path one thats not
password protected such as the admin urls.
In order to do that, you simply add this to your urls: (r'^my_url/jsi18n',
'django.views.i18n.javascript_catalog') and when your loading the
javascript files on your templated you do this 

Thank you,
Victor Rocha
rochapps.com

On Sat, Feb 2, 2013 at 12:15 AM, KVR  wrote:

> Yeah, it's throwing js error. Could you please tell me how to point that,
> I am just newbie to Django.
> I've tried adding the following to urls.py
>
> (r'^jsi18n/(?P\S+?)/$', 'django.views.i18n.javascript_catalog'),
>
> I did not understand what to replace with 
>
>
> On Saturday, February 2, 2013 10:38:29 AM UTC+5:30, Victor Rocha wrote:
>
>> I remember running into this problem quite sometime ago. What happens is
>> that in order to access the file jsi18n you need to be logged in. What
>> you need to do it's save a copy of the file and point to the file instead.
>>
>> thank you,
>> Victor rocha
>> rochapps.com
>>
>> On Fri, Feb 1, 2013 at 11:52 PM, KVR  wrote:
>>
>>> forms.py
>>> class SampleWidget(forms.Form):
>>> date=forms.CharField(widget=**AdminDateWidget,max_length=**100)
>>>  users = forms.**ModelMultipleChoiceField(**queryset=User.objects.all(),
>>> **widget=FilteredSelectMultiple(**("Users"), False))
>>>
>>>
>>> mytemple.html
>>>
>>> {% block content %}
>>> >> />
>>> >> />
>>> 
>>>
>>> window.**__admin_media_prefix__ =
>>> "/static/admin/";
>>>
>>>
>>> 
>>> >> >
>>> </**script>
>>> <script type="text/javascript" src="/static/admin/js/jquery.**
>>> js">
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 

Re: Problem with FilteredSelectMultiple widget

2013-02-01 Thread Victor Rocha
You are very welcome!

On Sat, Feb 2, 2013 at 1:14 AM, KVR  wrote:

> Thank you very much Victor Rocha !!
> That resolved my issue.
>
> Regards,
> kvr
>
>
> On Saturday, February 2, 2013 11:06:29 AM UTC+5:30, Victor Rocha wrote:
>
>> One way around this is to call the view on a different path one thats not
>> password protected such as the admin urls.
>> In order to do that, you simply add this to your urls:
>> (r'^my_url/jsi18n', 'django.views.i18n.javascript_**catalog') and when
>> your loading the javascript files on your templated you do this > src="/my_url/jsi18n/" type="text/javascript"></**script>
>>
>> Thank you,
>> Victor Rocha
>> rochapps.com
>>
>> On Sat, Feb 2, 2013 at 12:15 AM, KVR <kvr...@gmail.com> wrote:
>>
>>> Yeah, it's throwing js error. Could you please tell me how to point
>>> that, I am just newbie to Django.
>>> I've tried adding the following to urls.py
>>>
>>> (r'^jsi18n/(?P<packages>\S+?)/**$', 'django.views.i18n.javascript_**
>>> catalog'),
>>>
>>> I did not understand what to replace with <package>
>>>
>>>
>>> On Saturday, February 2, 2013 10:38:29 AM UTC+5:30, Victor Rocha wrote:
>>>
>>>> I remember running into this problem quite sometime ago. What happens
>>>> is that in order to access the file jsi18n you need to be logged in.
>>>> What you need to do it's save a copy of the file and point to the file
>>>> instead.
>>>>
>>>> thank you,
>>>> Victor rocha
>>>> rochapps.com
>>>>
>>>> On Fri, Feb 1, 2013 at 11:52 PM, KVR <kvr...@gmail.com> wrote:
>>>>
>>>>> forms.py
>>>>> class SampleWidget(forms.Form):
>>>>> date=forms.CharField(widget=**Ad**minDateWidget,max_length=**100)
>>>>>  users = forms.**ModelMultipleChoiceField**(**
>>>>> queryset=User.objects.all(),**w**idget=FilteredSelectMultiple(**(**"Users"),
>>>>> False))
>>>>>
>>>>>
>>>>> mytemple.html
>>>>>
>>>>> {% block content %}
>>>>> <link rel="stylesheet" type="text/css" href="/static/admin/css/base.**
>>>>> c**ss" />
>>>>> <link rel="stylesheet" type="text/css" href="/static/admin/css/forms.*
>>>>> ***css" />
>>>>> <!--[if lte IE 7]><link rel="stylesheet" type="text/css"
>>>>> href="/static/admin/css/ie.**css**" /><![endif]-->
>>>>>
>>>>> <script type="text/javascript">window.__admin_media_prefix__ =
>>>>> "/static/admin/";
>>>>>
>>>>>
>>>>> 
>>>>> >>>> >
>>>>> </**scrip**t>
>>>>> <script type="text/javascript" src="/static/admin/js/jquery.**j**
>>>>> s">
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 

Re: App-structure: how to have a bunch of data in all the pages.

2013-02-05 Thread Victor Rocha
I think template tags would be a good solution.

Thank you,
victor rocha
www.rochapps.com

On Tuesday, February 5, 2013 5:06:28 AM UTC-5, Stefano Tranquillini wrote:
>
> Hi all.
> i've a conceptual problem that i would like to solve. 
> Let's take as example a blog.
> In all the pages of the blog i would like to have a colum containing the 
> list of tags and the list of the top-10 posts.
>
> Now, i can create a base.html template where i render the data. but, how 
> should i do the population of these lists?
> Should i create a middleware that for each request populates the lists?
> or what?
>
> ciao
>

-- 
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: admin - see detail inline

2013-02-06 Thread Victor Rocha
I see more than one problem with your code. StackedInline is only used for 
models that have a one to many relationship and not the otherway around, in 
other words, you can have Docs stacked in line on the Client page but not 
the other way around, because only ONE client owns the document. You will 
see who owns it unless you have editable=False in your foreignkey.  The 
code should look like this:

#Model
class Client(models.Model):
name= models.CharField(max_length=25)
...

class Docs(models.Model):
name= models.CharField(max_length=25)
...
client  = models.ForeignKey(Client)

#Admin
class Detail_Doc(admin.StackedInline):
model = Docs

class DocAdmin(admin.ModelAdmin):
pass

class ClientAdmin(admin.ModelAdmin):
inlines = [Detail_Doc,]

admin.site.register(Doc, DocAdmin)
admin.site.register(Client, ClientAdmin)


Thank you,
Victor Rocha
www.rochapps.com

On Wednesday, February 6, 2013 8:02:53 AM UTC-5, grat wrote:
>
> Hi,
>
> i have this code:
>
> #Model
> class Client(models.Model):
> name= models.CharField(max_length=25)
> ...
>
> class Docs(models.Model):
> name= models.CharField(max_length=25)
> ...
> client  = models.ForeignKey(Client)
>
> #Admin
> class Detail_Doc(admin.StackedInline):
> model = Docs
>
> class Detail_Client(admin.StackedInline):
> model = Client
>
> class DocAdmin(admin.ModelAdmin):
> inlines = [Detail_Client,]
>
> class ClientAdmin(admin.ModelAdmin):
> inlines = [Detail_Docs,]
>
> admin.site.register(Doc,DocAdmin)
> admin.site.register(Client,ClientAdmin)
>
> what i want:
> a) in pages where is DOC i need see owner this Doc
> b) in pages in client i want to see DOC owned 
>
> Sorry for simple QA, but i only starting learn Django
>
> Milan
>

-- 
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: p.choice_set.all() error

2013-03-08 Thread Victor Rocha
The only thing I can think of it is that your database is not up-to-date 
with your models. You could drop the database and do a syncdb, otherwise 
using south to migrate your database schema could be an option.

Good luck,
Victor Rocha
RochApps <http://www.rochapps.com>

On Thursday, March 7, 2013 10:39:42 PM UTC-5, Hugo Guzman wrote:
>
> Hey there. I'm working through Part I of the "Writing your first Django 
> app" tutorial and everything was going smoothly until I tried executing the 
> following command:
>
> >>> p.choice_set.all()
>
> When I try running it I get the proceeding errors (below). I've attached 
> my models.py file for context. Any help or guidance would be much 
> appreciated.
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 72, in __repr__
> data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 87, in __len__
> self._result_cache.extend(self._iter)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 291, in iterator
> for row in compiler.results_iter():
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
>  
> line 763, in results_iter
> for rows in self.execute_sql(MULTI):
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
>  
> line 818, in execute_sql
> cursor.execute(sql, params)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/util.py", 
> line 40, in execute
> return self.cursor.execute(sql, params)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  
> line 114, in execute
> return self.cursor.execute(query, args)
>   File "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/cursors.py", 
> line 201, in execute
> self.errorhandler(self, exc, value)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/connections.py", 
> line 36, in defaulterrorhandler
> raise errorclass, errorvalue
> DatabaseError: (1054, "Unknown column 'polls_choice.choice_text' in 'field 
> list'")
>
>
>

-- 
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: 'SimpleLazyObject'

2013-07-13 Thread Victor Rocha
This is a wild guess but I do not see the login_required decorator on your 
view. I think you are getting this error because you are trying to save an 
Bookmark object passing an anonymous user as one of your arguments. An 
anonymous user is a SimpleLazyObject; it is a user but there is no 
reference to it on your databases. The Bookmark foreign key expects to 
point to user instance on the users table.

Thank you,
Victor Rocha
www.RochApps.com
 

On Friday, July 12, 2013 2:45:00 PM UTC-4, Kakar wrote:
>
> I've got a TypeError:
>
> int() argument must be a string or a number, not 'SimpleLazyObject'
>
>
> Here's my view:
>
> def bookmark_save_page(request):
> if request.method == 'POST':
> form = BookmarkSaveForm(request.POST)
> if form.is_valid():
> # Create or get link.
> link, dummy = Link.objects.get_or_create(
> url=form.cleaned_data['url']
> )
> # Create or get bookmarks.
> bookmark, created = Bookmark.objects.get_or_create(
> user = request.user,
> link = link
> )
> # Update bookmark title.
> bookmark.title = form.cleaned_data['title']
> # If the bookmark is being updated, clear old tag list.
> if not created:
> bookmark.tag_set.clear()
> # Create new tag list.
> tag_names = form.cleaned_data['tags'].split()
> for tag_name in tag_names:
> tag, dummy = Tag.objects.get_or_create(name=tag_name)
> bookmark.tag_set.add(tag)
> # Save bookmark to database.
> bookmark.save()
> return HttpResponseRedirect(
> '/user/%s/' %request.user.username
> )
> else:
> form = BookmarkSaveForm()
>
> variables = RequestContext(request, {'form': form})
> return render_to_response('bookmark_save.html',variables)
>
> I really don't know what's going on here. Please guide me.
>  

-- 
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: html to pdf

2013-07-28 Thread Victor Rocha
Shameless plug but you could use this: 
https://github.com/rochapps/django-pdf

-victor

On Sunday, July 28, 2013 3:50:41 AM UTC-4, Harjot Mann wrote:
>
> Hello Everyone 
>
> I am using Reportlaba nd pisa to convert the html template to pdf and 
> it is working but my question is that I want to convert the html 
> template directly to pdf. Right now it is retrieving data from 
> database but I dont want this thing. Cant we create it directly form 
> the templates byt only giving the url or template?? 
> How can we create different and multiple templates to 1 pdf file which 
> are having different url paths?? 
> Please reply asap.. 
> Thanks in advance 
>
>
> -- 
> Harjot Kaur Mann 
> Blog: http://harjotmann.wordpress.com/ 
>

-- 
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: html to pdf

2013-07-28 Thread Victor Rocha
Can you post the traceback?

On Sunday, July 28, 2013 3:50:41 AM UTC-4, Harjot Mann wrote:
>
> Hello Everyone 
>
> I am using Reportlaba nd pisa to convert the html template to pdf and 
> it is working but my question is that I want to convert the html 
> template directly to pdf. Right now it is retrieving data from 
> database but I dont want this thing. Cant we create it directly form 
> the templates byt only giving the url or template?? 
> How can we create different and multiple templates to 1 pdf file which 
> are having different url paths?? 
> Please reply asap.. 
> Thanks in advance 
>
>
> -- 
> Harjot Kaur Mann 
> Blog: http://harjotmann.wordpress.com/ 
>

-- 
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: django1.5 pour rapidsms

2013-07-31 Thread Victor Rocha
can you post the traceback you are getting?

On Wednesday, July 31, 2013 7:49:10 AM UTC-4, mimi89 wrote:
>
> depuis que j'ai rajouté l'application rapidsms-xforms à rapidsms, celui-ci 
> ne marche plus car la version de ce dernier est Django1.5 et que pour 
> rapidsms c'est un ancienne version!
> Les tags donnent un messages d'erreurs!
> Si quelqu'un peut m'aider!!!
>
>

-- 
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: Passing an image to the other url?

2015-06-23 Thread victor rocha
Jeremy, 

Extending a template do not magically gives you access to the context 
variables the other template has.
The context is set in the view, what's the view for the homepage? You 
didn't include it in your post.
Is the variable images set in there? I recommend using django debug toolbar 
to help debugging issues
like this. 

Anyway, make sure to set a context variable `images` in your homepage view 
and you will be all set.


On Monday, June 22, 2015 at 7:15:15 AM UTC-4, Jeremi Podlasek wrote:
>
> Please beware that I'm just few weeks into django and really do not feel 
> confortable at it
>
> In my first django project I've created an app which is uploading images 
> to the site, the images are stored at the same link the uploading takes 
> place
>
> What I'm trying to accomplish is to upload the images at the /list.html 
> and to display the images on the homepage.
> I've tried to inherit template from list.html so the homepage would have 
> the variable images so I could iterate over it but to no avail.
> I'm stuck and really a django framework beginner.
>
> All the homepage says is "No images."
>
>
>
> models.py 
> from django.db import models
> from PIL import Image
>
> class Image(models.Model):
> imgfile = models.ImageField(upload_to='images/%Y/%m/%d')
> 
>
>
> forms.py
> from django import forms
>
> class ImageForm(forms.Form):
> imgfile = forms.ImageField(
> label='Select a file',
> )
>
>
> views.py
> from django.shortcuts import render_to_response
> from django.template import RequestContext
> from django.http import HttpResponseRedirect
> from django.core.urlresolvers import reverse
>
> from .models import Image
> from .forms import ImageForm
>
> def list(request):
> # handling the file upload process
> if request.method == 'POST':
> form = ImageForm(request.POST, request.FILES)
> if form.is_valid():
> newimg = Image(imgfile = request.FILES['imgfile'])
> newimg.save()
>
> # point to the list of images
> return HttpResponseRedirect(reverse('img.views.list'))
> else:
> form = ImageForm() # show nothing
>
> #load images on the list page
> images = Image.objects.all()
>
> # render list page with the images & the browse form
> return render_to_response(
> 
> 'img/list.html',
> {'images': images, 'form':form},
> context_instance=RequestContext(request)
> )
>
>
> and templates: 
>
> list.html
> {% extends "site_base.html" %}
>
> {% load i18n %}
>
> {% block head_title %}site for specific people{% endblock %}
>
> {% block body_class %}list{% endblock %}
>
> {% block body_base %}
> 
> 
> {% include "_messages.html" %}
> {% blocktrans %}Add an image!{% endblocktrans %}
> 
>  
>   
>   {% if images %}
> 
> {% for image in images %}
> {{ image.imgfile.title }}
>  style="padding=20px; margin=20px" >
>
> {% endfor %}
> 
> {% else %}
> No images.
> {% endif %}
>
> 
> 
>
> 
>   
> 
> 
>  enctype="multipart/form-data">
> {% csrf_token %}
> {{ form.non_field_errors }}
> {{ form.imgfile.label_tag }} {{ form.image.help_text }}
> 
> {{ form.imgfile.errors }}
> {{ form.imgfile }}  
>
> 
> 
>  
> 
> 
> 
> {% endblock %}
>
> homepage.html
> {% extends "img/list.html" %}
>
> {% load i18n %}
>
> {% block head_title %}site for specific people{% endblock %}
>
> {% block body_class %}home{% endblock %}
>
> {% block body_base %}
> 
> 
> {% include "_messages.html" %}
>
>   
> {% if not user.is_authenticated %}
> {% url "account_login" as login_url %}
> {% url "account_signup" as signup_url %}
> {% blocktrans %}Feel free to  href="{{ login_url }}" class="btn btn-default">Log In or Sign Up and post an image!{% 
> endblocktrans %}
> {% endif %}
> 
> 
> {% if images %}
> 
> {% for image in images %}
> {{ image.imgfile.title }}
>  style="padding=20px; margin=20px" >
>
> {% endfor %}
> 
> {% else %}
> No images.
> {% endif %}
> 
> 
> 
> 
> 
> 
> 
> 
>   
> 
> 
> 
> {% endblock %}
>
>
>
>

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