I nedd help - first Django app, part 2 - Admin - Adding related objects

2014-01-27 Thread Rafał Szymański
Hello everybody.
I'm Rafał. I just started learnig and I'd like to ask You for little help.
I'm in the part 2 of tutorial - admin, Adding related objects.
I have no three slots for related Choices.
Here is my code.
Thanks in advance for any help.

from django.contrib import admin
from polls.models import Choice, Poll

class ChoiceInline(admin.StackedInline):
model = Choice
extra = 3

class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question']}),
('Date information', {'fields': ['pub_date'], 'classes': 
['collapse']}),
]
inline = [ChoiceInline]
list_display = ('question', 'pub_date', 'was_published_recently')

admin.site.register(Poll, PollAdmin)

-- 
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/ebe4c00a-8e9d-4337-8d6d-0f51861f78b2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I nedd help - first Django app, part 2 - Admin - Adding related objects

2014-01-27 Thread Rafał Szymański
as usual...

Thank you Ramiro for your effort

W dniu poniedziałek, 27 stycznia 2014 14:14:14 UTC+1 użytkownik Ramiro 
Morales napisał:
>
> On Mon, Jan 27, 2014 at 7:54 AM, Rafał Szymański 
> <r.szy...@gmail.com> 
> wrote: 
> > Hello everybody. 
> > I'm Rafał. I just started learnig and I'd like to ask You for little 
> help. 
> > I'm in the part 2 of tutorial - admin, Adding related objects. 
> > I have no three slots for related Choices. 
> > Here is my code. 
> > [snip] 
> > class PollAdmin(admin.ModelAdmin): 
> > ... 
> > inline = [ChoiceInline] 
>
> The correct option name here is 'inlines': 
>
>  inlines = [ChoiceInline] 
>
> -- 
> Ramiro Morales 
> @ramiromorales 
>

-- 
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/30d66915-407d-4d9d-9768-abefda839c0c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


can't compare datetime.datetime to datetime.date

2014-01-27 Thread Rafał Szymański
Hi again

I wolud like ask another question.
If someone would be so kind and help that will be great.
I'm in the begining of django tutorial.

I use python3.3 and django1.6

I get error:
can't compare datetime.datetime to datetime.date

Here is my code:

import datetime
from django.utils import timezone
from django.db import models

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateField('date published')
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
def __str__(self):
return self.question

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text

Thanks in advance
Rafał

-- 
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/0a985ef1-4b69-44d3-9523-c3e1ab23c8e0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: can't compare datetime.datetime to datetime.date

2014-01-28 Thread Rafał Szymański
Thank You so much.
Best wishes
Rafal

W dniu poniedziałek, 27 stycznia 2014 15:43:59 UTC+1 użytkownik 
i...@simpler.co napisał:
>
> You're comparing pub_date, which is a datetime.date, to timezone.now(), 
> which is a datetime.datetime. Check the docs at 
> http://docs.python.org/2/library/datetime.html for more.
>
> In order to convert timezone.now() to a date, just call 
> timezone.now().date(), like:
>
> In [1]: from django.utils import timezone
>
> In [3]: timezone.now()
>
> Out[3]: datetime.datetime(2014, 1, 27, 14, 42, 29, 408491, tzinfo=)
>
> In [4]: timezone.now().date()
>
> Out[4]: datetime.date(2014, 1, 27)
>
> On Monday, January 27, 2014 5:38:20 AM UTC-8, Rafał Szymański wrote:
>>
>> Hi again
>>
>> I wolud like ask another question.
>> If someone would be so kind and help that will be great.
>> I'm in the begining of django tutorial.
>>
>> I use python3.3 and django1.6
>>
>> I get error:
>> can't compare datetime.datetime to datetime.date
>>
>> Here is my code:
>>
>> import datetime
>> from django.utils import timezone
>> from django.db import models
>>
>> class Poll(models.Model):
>> question = models.CharField(max_length=200)
>> pub_date = models.DateField('date published')
>> def was_published_recently(self):
>> return self.pub_date >= timezone.now() - 
>> datetime.timedelta(days=1)
>> def __str__(self):
>> return self.question
>>
>> class Choice(models.Model):
>> poll = models.ForeignKey(Poll)
>> choice_text = models.CharField(max_length=200)
>> votes = models.IntegerField(default=0)
>> def __str__(self):
>> return self.choice_text
>>
>> Thanks in advance
>> Rafał
>>
>

-- 
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/4614f29c-5d27-4332-b648-99c610adf626%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for ways to improve my skills

2016-04-13 Thread Rafał Szymański
I can recommend http://codingforentrepreneurs.com/ and 
http://tangowithdjango.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5342e7f7-b208-4519-8006-7a852577e6d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Shouldn't formset show number of forms according to number o dicts in initial?

2016-06-17 Thread Rafał Szymański
I'd like to ask for a little help.

I'd like to show few forms with on page using formset_factory. Number of 
forms should be dependent on number of dictionaries set in inital 
parameter. But the result is that one form is showed with three options 
avaliable to choose according to dicts from nitial. Shouldn't formset show 
number of forms according to number o dicts in initial with no use of extra 
param?

Thanks in advance.
Rafal

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1f1558c8-8377-487f-8b82-a78ddfdf3adb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Fully understanding of TemplateView - Can you take a look at my video course, please?

2017-09-15 Thread Rafał Szymański
Hi guys!
Can you take a look at my video course about TemplateView, please?

Django GCBV - Fully undestanding of TemplateView.

It's free and it's on Udemy.

Here the link 
https://www.udemy.com/django-gcbv-fully-understanding-of-templateview/

Thanks a lot for time, advice, comment, help, any effort.

Have a great weekend!

Rafal

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9d996d5c-281e-4848-9c7f-3048779a8e06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: generic views empty args problem

2017-09-15 Thread Rafał Szymański
Does it help?

return super(SampleUpdateView, self).get(request, project_name, *args, 
**kwargs)



W dniu czwartek, 14 września 2017 13:25:06 UTC+2 użytkownik Adrian Jasiński 
napisał:
>
>
>
> When I have in my urlpatterns args and kwargs in any of generic views then 
> the view is loosing args (it's returning empty tuple)
>
> Simple example of url:
>
>
> url(r"^(\w+)/test1/(?P[0-9]+)/list/$", SamplesUpdateView.as_view(), 
> name='update_view'),
>
>
> Simple code for my view:
>
> class SamplesUpdateView(UpdateView):
> model = Sample
>
> def get(self, request, project_name, *args, **kwargs):
> print("project_name", project_name)
> return super().get(request, project_name, *args, **kwargs)
>  
>
> It works ok when I pass only args or kwargs into url.
>
>
> THE PROBLEM occurs in ALL generic view (CreateView, UpdateView, 
> DeleteVIew, ListView).
> I can't find it myself why it's happening. I consider it a bug and added 
> ticket for it:
>
> https://code.djangoproject.com/ticket/28587
>
> Any help in this?
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/657eae49-106d-4b1e-b0c8-076e45d41962%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.