Create objects using a start date, an end date and time list

2018-02-15 Thread Kakar Nyori
I have an Event model, and each event will have different shows.

class Event(models.Model):
title = models.CharField(max_length=200)

class Show(models.Model):
event = models.ForeignKey(Event, on_delete=models.CASCADE)
date_time = models.DateTimeField(unique=True)

class Ticket(models.Model):
show = models.ForeignKey(Show)
seat = models.ForeignKey(Seat)

class Meta:
unique_together = ('show', 'seat')

I need to create shows based on the start date and end date provide by the 
user. Suppose this is a JSON post:

{
"event_id": 1,
"start_date": "2018-02-16",
"end_date": "2018-02-20",
"time_list": ["11:00 AM", "8:00 PM"]
}

>From the above JSON example, I need to create Show starting like this:

# Start with the start_date as the date, and for each time from the 
time_list
Show.objects.create(
event = 1,
date_time = datetime.strptime('2018-02-16 11:00 AM', "%Y-%m-%d 
%I:%M %p")
)
Show.objects.create(
event = 1,
date_time = datetime.strptime('2018-02-16 8:00 PM', "%Y-%m-%d %I:%M 
%p")
)
# Next date after the start_date, i.e., 16+1 = 17
Show.objects.create(
event = 1,
date_time = datetime.strptime('2018-02-17 8:00 PM', "%Y-%m-%d %I:%M 
%p")
)
.
.
.
# Create Show objects till the end_date and for each time from the 
time_list
Show.objects.create(
event = 1,
date_time = datetime.strptime('2018-02-20 8:00 PM', "%Y-%m-%d %I:%M 
%p")
)

Right now this is how I am creating Show objects:

def create_show_by_datetime(self, request):
event_id = request.data['event_id']
start_date = request.data['start_date']
end_date = request.data['end_date']
time_list = request.data['time_list']

format = '%Y-%m-%d'
delta_days = datetime.strptime(end_date, format).date() - 
datetime.strptime(start_date, format).date()
delta_days = delta_days.days + 1

for i in range(delta_days):
day = datetime.strptime(start_date, format) + timedelta(days=i)
for i in range(len(time_list)):
hrs = datetime.strptime(time_list[i], "%I:%M %p").hour
mins = datetime.strptime(time_list[i], "%I:%M %p").minute
event = Event.objects.get(id=event_id)
dt = day + timedelta(hours=hrs, minutes=mins)
show = Show.objects.create(
event=event,
date_time=dt
)

But I am really hoping there's much more elegant way than how I am doing. I 
am using python 3, django 2 and django rest frameowork. Could you please 
help me?

Thank you

-- 
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/813ca752-f1e1-47d7-9ebb-a8bdb7e2ed59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Migrating from django user model to a custom user model

2017-03-14 Thread Kakar Nyori


I am following these two references (one 
 and two 
)
 
to have a custom user model in order to authenticate via email and also to 
add an extra field to it.


class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
unique=True,
max_length=254,
)
mobile_number = models.IntegerField(unique=True)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)

objects = UserManager()
...
...
class Meta:
db_table = 'auth_user'
...
...


As you can see, I have added the db_table='auth_user' into the Meta fields 
of the class. Also, I have included AUTH_USER_MODEL = 'accounts.User' and 
the User model app (i.e., accounts) into the INSTALLED_APPS in settings.py. 
Further more, I deleted the migrations folder from the app.


Then tried migrating:

$ python manage.py makemigrations accountsMigrations for 'accounts':
  accounts/migrations/0001_initial.py:
- Create model User

$ python manage.py migrate accounts

Which gives me an error:

django.db.migrations.exceptions.InconsistentMigrationHistory: Migration 
admin.0001_initial is applied before its dependency accounts.0001_initial 
on database 'default'.

How can I migrate from the existing django user model into a custom user 
model? Could you guys please help me out.


Thank you

-- 
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/4acb65c3-04a2-47b8-8a51-fbb0ec587f37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is the best combination of components when installing Django on Windows 10?

2016-12-28 Thread Kakar Nyori
Hi,

I use windows, and I too was confused about these things. The best 
recommendation I got was to use *Vagrant, *and to this day I use it. 

*"Vagrant is a tool for building complete development environments."*

Basically you select an environment like ubuntu OS (called vagrant box), 
and then you add it as your vagrant environment. With this as your local 
development you get many benefits:

1. Since you will eventually be using OS like ubuntu in production, you get 
the same environment for the development as well.
2. You can play around with the environment.
3. And since you have the production like environment, you can basically do 
all the stuff you would do in production. Like you want gunicorn, ok, 
install it in your vagrant environment and use it.
4. You can administer and practice in the machine like you would do for the 
production.
5. You can have the same exact configuration that is in your production 
machine.

Hope this will be helpful to you as it was for me. And again, this may not 
be the best practice for someone else.

Cheers!

Kakar.

-- 
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/dd29d891-2f17-411c-9a5c-a102e2ce0ae2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Understanding django channels persistant data

2016-12-20 Thread Kakar Nyori
Hi,

Yes that was it. Although I was getting this error:
*ERROR - worker - Error processing message with consumer 
myproject.consumers.ws_message:*

But this was corrected after the *enforce_ordering *was added into the 
consumer function. Thank you so much for your help and for introducing such 
a great tool for us.

Kakar Nyori

-- 
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/bbeb22a4-4d01-4673-8f0c-2fe60de33ed0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Understanding django channels persistant data

2016-12-20 Thread Kakar Nyori
Wow, from the creator himself! Thank you.
>
>
Just so we're clear, *message.channel_session['key']* is the same as 
*request.session['key']*, did I get you correctly?

And there's just this another confusion, why can't we us *"text": 
message.content['text']*, but instead its *"text": message['text']*?

Thank you
Kakar Nyori

-- 
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/fdf12336-d67d-4759-8d45-02493b5cd341%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Understanding django channels persistant data

2016-12-20 Thread Kakar Nyori
I am trying to grasp the concept of persistant data in django channels
.
I have searched the reference and other parts but didn't clear my
confusion. I would really appreciate if you help me understand better.

consumers.py:

@channel_sessiondef ws_connect(message):
# Work out room name from path (ignore slashes)
room = message.content['path'].strip("/")
# Save room in session and add us to the group
message.channel_session['room'] = room
Group("chat-%s" % room).add(message.reply_channel)

Q.1 In the above line message.channel_session['room'], is the room another
property of the message? Like it tells which session the message belongs to?

@channel_sessiondef ws_message(message):
Group("chat-%s" % message.channel_session['room']).send({
"text": message['text'],
})

Q2. In the line Group("chat-%s" % message.channel_session['room']).send({,
why are we not using the *room* variable like in the ws_connect() function,
but instead we are using the channels_session?

@channel_sessiondef ws_disconnect(message):
Group("chat-%s" %
message.channel_session['room']).discard(message.reply_channel)

Q3. Same like above, why are we not using the *room* variable to discard
from the group? Also is it not neccesary to remove the room from the
session?

-- 
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/CA%2B8okoJ70Nba%3Dfw9k-10C3UASXMwFkayR7ApdjTEVg1s23bT-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to django with jquery-mobile

2015-07-29 Thread Kakar Nyori
Django provides many features for the template (extends, block content
etc.) I am just learning jquery mobile, but so far when using jquery
mobile, there's just one actual html page and inside it we have to create a
page (data-role="page"). So, how can we utilize the django's templating
features with jquery mobile? Or how to django with jquery mobile? Please
help me understand this concept. Thank you.

-- 
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/CA%2B8okoKmk3cjs6N-OiafJoA-wLT57aWzbVpk4NGaTdF7xffQzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: amazon s3 and django - Allow only the users from my website and not the anonymous users

2015-02-07 Thread Kakar Nyori
Hello,
thank you for the response. Could you please give an example as to how to 
do that above mentioned?
Thank you.

On Friday, February 6, 2015 at 11:10:50 PM UTC+5:30, Nikolas 
Stevenson-Molnar wrote:
>
>  It sounds like you want to use signed URLs. Since you're using storages, 
> this should be the default if you use the "url" property. E.g.,
>
> signed_url = status_obj.image.url
>
> Then keep the file itself private. No one will be able to access it 
> without a signed URL, and you can control who gets a signed URL in your 
> Django app.
>
> _Nik
>
> On 2/6/2015 7:51 AM, Kakar Nyori wrote:
>  
>  I am using amazon s3 to store uploaded user images. My problems are:
>
>  - If I permit or grantee for me, I cannot upload or download the 
> contents.
> - If I permit or grantee for everyone, all the users and (especially) 
> anonymous users will be able to see the contents, which I don't want.
>
>  So, my question is, what do I do so that only the users from my website 
> can upload, download and delete the content? 
>
>  In that I have conditions that:
>
>   1. Only the users (user1, user2, user3, ...) who are following the user
> (user0) can download/view the content?
>  2. Only the user who uploaded the view can delete the content.
>
>  models.py:
>
>  *def get_upload_file_name(instance, filename):*
> *return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), 
> filename)*
>
>  *PRIVACY = (*
> *('H','Hide'),*
> *('F','Followers'),*
> *('A','All'),*
> *)*
>
>  *class Status(models.Model):*
> *body = models.TextField(max_length=200)*
> *image = models.ImageField(blank=True, null=True, 
> upload_to=get_upload_file_name)*
> *privacy = models.CharField(max_length=1,choices=PRIVACY, 
> default='F')*
> *pub_date = models.DateTimeField(auto_now_add=True, 
> auto_now=False)*
> *user = models.ForeignKey(User)*
>
>  settings.py:
>
>  * DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'*
>
>  * AWS_ACCESS_KEY_ID = 'AKIAJQWEN46SZLYWFDMMA'*
>
>  * AWS_SECRET_ACCESS_KEY = '2COjFM30gC+rty571E8eNSDYnTdV4cE3aEd1iFTH'*
>
>  * AWS_STORAGE_BUCKET_NAME = 'yesme'*
>  -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/cbc5c0d5-cc42-4a67-9414-2fb74fceed1e%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/cbc5c0d5-cc42-4a67-9414-2fb74fceed1e%40googlegroups.com?utm_medium=email_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/b62f01f0-c775-4b8a-afe8-4d6da8e4a351%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


amazon s3 and django - Allow only the users from my website and not the anonymous users

2015-02-06 Thread Kakar Nyori
I am using amazon s3 to store uploaded user images. My problems are:

- If I permit or grantee for me, I cannot upload or download the contents.
- If I permit or grantee for everyone, all the users and (especially) 
anonymous users will be able to see the contents, which I don't want.

So, my question is, what do I do so that only the users from my website can 
upload, download and delete the content? 

In that I have conditions that:

 1. Only the users (user1, user2, user3, ...) who are following the user
(user0) can download/view the content?
 2. Only the user who uploaded the view can delete the content.

models.py:

*def get_upload_file_name(instance, filename):*
*return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), 
filename)*

*PRIVACY = (*
*('H','Hide'),*
*('F','Followers'),*
*('A','All'),*
*)*

*class Status(models.Model):*
*body = models.TextField(max_length=200)*
*image = models.ImageField(blank=True, null=True, 
upload_to=get_upload_file_name)*
*privacy = models.CharField(max_length=1,choices=PRIVACY, 
default='F')*
*pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)*
*user = models.ForeignKey(User)*

settings.py:

* DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'*

* AWS_ACCESS_KEY_ID = 'AKIAJQWEN46SZLYWFDMMA'*

* AWS_SECRET_ACCESS_KEY = '2COjFM30gC+rty571E8eNSDYnTdV4cE3aEd1iFTH'*

* AWS_STORAGE_BUCKET_NAME = 'yesme'*

-- 
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/cbc5c0d5-cc42-4a67-9414-2fb74fceed1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Handle multiple modelforms in one html form

2015-01-17 Thread Kakar Nyori
A user will have photos which will be related with their specific album.

So this was the model for that:

class Album(models.Model):
> user = models.ForeignKey(User)
> title = models.CharField(max_length=200)
> pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)
> update = models.DateTimeField(auto_now_add=False, auto_now=True)
> class Photo(models.Model):
> photo_privacy = models.CharField(max_length=1,choices=PRIVACY, 
> default='F')
> user = models.ForeignKey(User)
> caption = models.TextField()
> image = models.ImageField(upload_to=get_upload_file_name)
> pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)



Views.py:

def create_album(request, user_name):
> user = User.objects.get(username=unquote(user_name))
> if request.method=='POST':
> pform = AlbumPhotoForm(request.POST, request.FILES)
> aform = AlbumForm(request.POST)
> p_valid = pform.is_valid()
> a_valid = aform.is_valid()
> if p_valid and a_valid:
> photo = pform.save(commit=False)
> album = aform.save(commit=False)
> photo.user = user
> album.user = user
> album.save()
> photo.album = album
> photo.save()
> return HttpResponseRedirect('/'+user.username+'/photos')
> else:
> return render(request, 'create_album.html',{
> 'pform':pform,
> 'aform':aform
> })
> else:
> pform = AlbumPhotoForm()
> aform = AlbumForm()
> return render(request, 'create_album.html', {
> 'pform':pform,
> 'aform':aform
> })


And the form:

 enctype="multipart/form-data">
> {% csrf_token %}
> {{ aform.as_p }}
> {{ pform.as_p }}
> 
> 


This works fine if I only have to upload one file (photo) with that form.

However what I want to do is, show minimum of three input for uploading 
photos to the new album:

 enctype="multipart/form-data">
> {% csrf_token %}
> {{ aform.as_p }}
> {{ pform.as_p }}
> {{ pform.as_p }}
> {{ pform.as_p }}
> 
> 


When doing so, only the last *pform* is gets saved. And the other two 
*pform*s are ignored. How do I get to save all the three forms of photo (
*pforms*) accordingly?

Or is there any other way around? Your help will be much appreciated! Thank 
you.

-- 
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/c6dc8dba-c627-4776-9421-49120da64c18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Authenticate users with both username and email

2015-01-15 Thread Kakar Nyori


I have extendted the *UserCreationForm* with email and other fields, so 
that I could authenticate a user with both its username and email.

forms.py:

> class UserCreationForm(UserCreationForm):
> class Meta:
> model = User
> fields = ('first_name', 'last_name', 'username', 'email',)


 
views.py:

def auth_view(request):
> username = request.POST.get('username','')
> password = request.POST.get('password','')
> user = auth.authenticate(username=username, password=password)
> if user is not None:
> auth.login(request, user)
> return HttpResponseRedirect('/')
> elif:
> user = auth.authenticate(email=username, password=password)
> if user is not None:
> auth.login(request, user)
> return HttpResponseRedirect('/')
> else:
> return HttpResponseRedirect('/accounts/invalid_login')


html:


> {%csrf_token%}
> Email or Username:
> 
> Password:
> 
> 
> 



In the views I tried giving both the *username* and *email *as input from 
the form as *name*, and check to see if username and password authenticate. 
If not then check whether email and password authenticate. But its not 
working. How do I solve this problem? Please kindly help me. Thank you.

-- 
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/0cb8e818-3145-4e91-a374-7b018092f4fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Uploadfile form and CSS Style

2014-11-18 Thread Kakar Nyori
Hello Russo,

You need to select the input button in the css. Something like this:

input[type=submit] {
background-color: transparent;
border:none;
cursor:pointer;
background-color:blue;
color:white;
}

Note that this will select every "submit" type button in your html. So if
you don't want all of them to be like the above, then you need to provide
the ID and and then select the submit button. You can check it by the *inspect
element tool, *as Collin has described. Or you can manually do it in your
forms as Donarb has described.

Hope this will make some sense.

Cheers!

On Tue, Nov 18, 2014 at 6:12 AM, donarb <don...@nwlink.com> wrote:

> On Monday, November 17, 2014 5:00:54 AM UTC-8, Russo wrote:
>>
>> Hi James,
>>
>> sorry I'm new on Django, can you give me some code example? I mean, hot
>> to define the CLASS or ID into the html with elements like this {{
>> form.docfile }} ?
>>
>> Regards
>> Russo
>>
>>
>> El jueves, 13 de noviembre de 2014 15:48:16 UTC-4:30, James Schneider
>> escribió:
>>>
>>> If you are manually expressing the form, then you can add classes and
>>> ID's to any or all elements in the form. Even if you are using something
>>> like the {{ form.as_p }} method to display the form, you can still style it
>>> using CSS styles at the tag level. Just include a custom CSS file with your
>>> template.
>>>
>>> -James
>>> On Nov 13, 2014 12:13 PM, "Russo" <arus...@musicparticles.com> wrote:
>>>
>>>>  Hi Kakar,
>>>>
>>>> but i tried and there is not way to change the bottom style, see the
>>>> html code
>>>>
>>>> 
>>>> >>> enctype="multipart/form-data">
>>>> {% csrf_token %}
>>>>
>>>> {{ form.non_field_errors }}
>>>>     {{ form.docfile.label_tag }} {{ form.docfile.help_text
>>>> }}
>>>> 
>>>> {{ form.docfile.errors }}
>>>> {{ form.docfile }}
>>>> 
>>>> 
>>>> 
>>>>
>>>> as it is a form there is no way to change style ¿?
>>>>
>>>> Regards/AR
>>>>
>>>>
>>>> El 13/11/2014 a las 03:37 p.m., Kakar Nyori escribió:
>>>>
>>>> Then you need to apply css to the form.
>>>>
>>>> On Fri, Nov 14, 2014 at 1:16 AM, Russo <arus...@musicparticles.com>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> i just implemented the uploadfile form on Django, and everything goes
>>>>> greate, but i would like to do if it is possible to apply CSS styles to 
>>>>> the
>>>>> upload botton on the forms, Anybody knows this?
>>>>>
>>>>> Regards
>>>>> Russo
>>>>>
>>>>> --
>>>>> 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.
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/django-users/54650A9B.8040004%40musicparticles.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...@googlegroups.com.
>>>> To post to this group, send email to django...@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/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%
>>>> 2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.googl

Re: Want to change home->blog to Admin home -> blog

2014-11-15 Thread Kakar Nyori
Your question is unclear. Please try to elaborate more.

On Sat, Nov 15, 2014 at 4:37 PM, Sachin Tiwari 
wrote:

>
>
> On Thursday, November 13, 2014 7:49:28 PM UTC+5:30, Sachin Tiwari wrote:
>>
>>  Hi All,
>>
>>  I want to change Home link at admin page to Admin Home -> blog -> ...
>>
>>  I tried by modifying  base.html and base_site.html in my
>> templates/admin/, but it would not work
>>
>>  {% block breadcrumbs %}
>> 
>> {% trans ' Admin Home' %}
>> {% if title %}  {{ title }}{% endif %}
>> 
>> {% endblock %}
>>
>>
>>
> Please help
>
> --
> 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/e1a4bc9d-e946-40b9-b5a5-db87b3c75515%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/CA%2B8okoLyPKzeDyvzLTKQZFdGxN3wexqABvpSghxBK3YRwBH7Zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Uploadfile form and CSS Style

2014-11-13 Thread Kakar Nyori
Then you need to apply css to the form.

On Fri, Nov 14, 2014 at 1:16 AM, Russo  wrote:

> Hi,
>
> i just implemented the uploadfile form on Django, and everything goes
> greate, but i would like to do if it is possible to apply CSS styles to the
> upload botton on the forms, Anybody knows this?
>
> Regards
> Russo
>
> --
> 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/54650A9B.8040004%40musicparticles.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/CA%2B8oko%2Bawro-H19b7XG-LXnNc4r%2BmFX0qTx_7kkvSmo%3Dvkg30A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Swampdragon, the realtime framework for Django seems interesting. But will it scale ?

2014-11-11 Thread Kakar Nyori
Oooh! Nice one. But its very new though. I would also like to hear from the
experts!!! Thanks for the post though

On Wed, Nov 12, 2014 at 10:07 AM, Suren Sth  wrote:

> I recently came across Swampdragon ( Visit official site
> ). I am curious can it be used in production
> sites and will it scale ? If it can be, what is the best way?
>
> --
> 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/74092e59-801e-48f6-ba99-9d6231516b84%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/CA%2B8oko%2BJX98KnUG9erPqHiKtBYLkKypVg32pmeR-dcG5__dVhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django + Database Connections

2014-11-11 Thread Kakar Nyori
Very nicely explained.

On Wed, Nov 12, 2014 at 2:55 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> Hi Edward,
>
> On Tue, Nov 11, 2014 at 12:30 AM, Edward Armes 
> wrote:
>
>> Hi there,
>>
>> I am currently looking at Django for a personal project. While I
>> understand how a lot of it works I can't wrap my head around how the actual
>> DB querying is done specifically what part of Django actually looks at the
>> database (I'm not talking about Manager, Models or Querysets, but the
>> actual parts of Django that use the ORM's to get data from the database
>> itself).
>>
>> If a reason is required without going into detail on my current
>> half-baked idea, I'm specifically looking how to handle database operations
>> that have a significant return time by marrying asynchronous environments
>> with synchronous ones. While it may be more efficant to use a non-Django
>> database handler. For now I want to look into using the Django framework
>> without needing additional imports.
>>
>>
> It's not that a *reason* is required - it's that it's not entirely clear
> what you're asking for.
>
> The thing is, Django *itself* doesn't do a lot of querying - Django is a
> template system, and a forms layer, and a database ORM, all nicely
> integrated, so you can easily compose the pieces to do something useful.
> There are places where the forms layer will issue queries (e.g., if you
> want to display a form that has a  representing the available
> options from a model), but that's really at the level of "give me a
> queryset that represents the options I want to display".
>
> The only part of Django *itself* that "uses" Django is the contents of the
> contrib apps - most importantly, contrib.admin, but there are others.
>
> The idea of marrying async and synchronous environments isn't a new one -
> it was the subject of a Google Summer of Code project this year, the result
> of which will hopefully be committed to trunk for 1.8. The core of that
> project was to formalise the API around Django's model layer so that you
> can write a "duck typed" object that will be a substitute for a Django
> model (subject to certain constraints and limitations). Search the
> Django-Developer archive for "Meta Refactor" if you want more details.
> However, that won't let you get away "without needing additional imports" -
> at some point, you're going to need to import your async layer, because
> Django doesn't have one.
>
> I don't know if any of this helps... hopefully it does :-)
>
> 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/CAJxq848_Oy_oWhLnu5h8dfgT1MW8CKny_ZQKZcQ4nCdO9_W%2B5g%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/CA%2B8oko%2BZquCXnCV5k9WRMevYRMX4Unca_EhimKTQdCCcuzqQAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: broken image on my django production site. Why is it?

2014-11-02 Thread Kakar Nyori
I think, you should add "static"/ in your html:



Or else change your directory settings.


On Sat, Nov 1, 2014 at 8:21 PM, rdyact  wrote:

>
> 
> I just product my site using Heroku and I got a odd problem with my media
> images broken. Here is my site structure on Heroku.
>
>  -- app
> -- manage.py
> -- mysite
>-- settings
>  -- __init__.py
>  -- base.py
>  -- production.py
> -- static
>-- media
>   -- product
> -- images
>   --
>-- static_dirs
>-- static_root
>
>
> In my app/mysite/settings/ *init*.py
>
> from .base import *try:
> from .local import *
> live = Falseexcept:
> live = Trueif live:
> from .production import *
>
> and in my base.py
>
> import os
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
> STATIC_URL = '/static/'
> MEDIA_URL = '/media/'
> MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')
> STATIC_ROOT = os.path.join(BASE_DIR, 'static', 'static_root')
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'static', 'static_dirs'),)
> TEMPLATE_DIRS = (
> os.path.join(BASE_DIR, 'templates'),)
>
>
> and in my production.py, I annotated as below.
>
> # Static asset configuration# import os# BASE_DIR = 
> os.path.dirname(os.path.abspath(__file__))# STATIC_ROOT = 'staticfiles'# 
> STATIC_URL = '/static/'# STATICFILES_DIRS = (# os.path.join(BASE_DIR, 
> 'static'),# )
>
> Finally, I ran server and I got still broken image shown on my page. When
> I look the image carefully through "google inspect element",I can still see
> the probably right path as below.
>
> 
>
> But when I see my /static/media/products/images/ folder, there were images
> created on development statge only, not the images I just created on
> production site. (aws.png)
>
> As still beginner for django development, It is a tough to find answer
> even after few hour's googling.
>
> Thanks always.
>
>
>  --
> 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/2f1eb33e-c1c0-417f-8665-b8f239540f4d%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/CA%2B8okoLAeWvJKPDYAGcLR7XYOMDT1CohqcZWEsek3PtbpZdzXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


no module in error log django-1.3.7

2014-10-22 Thread Kakar Nyori
Hello,
I am trying to run a python app in pythonanywhere.com. If I run the project
through the bash it runs without any error. But when I see it in the
browser with the name like myproject.pythonanywhere.com, it display
"something went wrong".
And when I check in the error log, it show me this:

no module named appname.

What went wrong?

This is the path structure of the project:

projectname
--__init__.py
--manage.py
--settings.py
--urls.py
--appname
--__init__.py
--admin.py
--forms.py
--models.py
--views.py
--tests.py
--static
--css
--style.css
--js
--ui.js
--templates
--index.html

-- 
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/CA%2B8okoLeb9u4pf5MGvKX2jkb5c1LsyUJx4CDC9qt6uD0uCeh2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to make a phone number field mandatory like password.

2014-09-26 Thread Kakar Nyori
You can do it in the form itself.

On Fri, Sep 26, 2014 at 8:49 PM, Sachin Tiwari 
wrote:

> Hi
>
> I am learning django and I want to add a phone number field which would be
> mandatory when we use add user button in users section.
>
> I  tried it with blank=False or null=False but it would not work for me.
>
> I am also using django-phone-number field package.
>
>
> Thanks
>
> --
> 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/0ba53eda-e569-4521-b83a-4c883ee962e3%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/CA%2B8okoK3UHV0pV3kZ9CT7kRKik70%2B20XVBcdsDv58cKDR%3Dv_kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re:Autoupdate

2014-04-14 Thread Kakar Nyori
Ajax is the way to go. Or else, web sockets.
On Apr 14, 2014 5:59 PM, "Saransh Mehta"  wrote:

> I want some data to autoupdate on my homepage as more entries come into
> the database. It is more or less like the news feed feature of Facebook.
> How do we do that?
>
>  --
> 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/736ef367-3ca0-456b-8c8e-3f792946dca4%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/CA%2B8okoLaCnGSf7Zd8RQK_Wd8bC3jTWPaP8HUU%3DpmutJTcn%2BS8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and Long Polling

2014-03-23 Thread Kakar Nyori
You mean requesting db in the given time?


On Sun, Mar 23, 2014 at 8:50 AM, Venkatraman S  wrote:

> Why not use (async)callbacks?
>
> -V
>
>
> On Sun, Mar 23, 2014 at 1:11 AM, Robin Lery  wrote:
>
>> Hello,
>> I need to implement long polling in my application to retrieve the
>> events. But I have no idea how to do it. I know the concept of long
>> polling, i.e to leave the connection open, until an event occurs. But how
>> do I do implement this in my project. If you could give me a simple long
>> polling example of client side and the views i guess, I would really
>> appreciate.
>>
>> Thank you!
>>
>> --
>> 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/CA%2B4-nGpvKHcMg-mMRbf7%2BVceCAkRwipt_8NvojEw43ALhC2YBw%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/CAN7tdFQKUvNQ69NA_K58R1tz2R_HW2eE%2BvwrFr-7hqVRUDO8tg%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/CA%2B8oko%2Bc2VGkb4Wu%2Bd-ko2_ROyD1xROjvUyYWW_QHKMNK9K_AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Review needed

2014-03-02 Thread Kakar Nyori
Hello,
This may be long, but I really need your help. I have a class *Asset*, 
which is the *base class* of another *classes *(like *Photo, Question, 
Video etc.*) Basically its a *Multiple Table Inheritance*. I need this to 
get all the post or all the *objects* of the user. And it does what I want. 
But I saw that, many were against *Multiple Table Inheritance, *or if not 
they discouraged MTI. So, I really need to know that, *how much will it 
matter*? Or is there any other way to achieve it. To get all the objects of 
a *User*? Please help me decide what to do. If I am not clear, please ask 
me. I will really appreciate if anyone would guide me through this.

Thank you.

*This are my models:*


class Asset(models.Model):
user = models.ForeignKey(User, related_name = "user_objects")
likes = models.ManyToManyField(User, through="Like", 
related_name="Liked_user")
comments = models.ManyToManyField(User, through="Comment", 
related_name="Commented_user")
timestamp = models.DateTimeField(auto_now = True, auto_now_add= False)
updated = models.DateTimeField(auto_now = False, auto_now_add = True)

class Meta:
ordering = ['-timestamp']

def __unicode__(self):
return self.__class__.__name__

class Like(models.Model):
asset = models.ForeignKey(Asset)
liked_by = models.ForeignKey(User)
liked_time = models.DateTimeField(auto_now = True, auto_now_add = False)

def __unicode__(self):
return "%s likes %s" % (self.liked_by, self.asset)

class Comment(models.Model):
asset = models.ForeignKey(Asset)
comment_by = models.ForeignKey(User)
liked_time = models.DateTimeField(auto_now = True, auto_now_add = False)

def __unicode__(self):
return "%s likes %s" % (self.comment_by, self.asset)

def get_upload_file_name(instance, filename):
return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), filename)

class Album(Asset):
title = models.CharField(max_length=200)
description = models.TextField()

def __unicode__(self):
return self.__class__.__name__


class Picture(Asset):
description = models.TextField()
image = models.ImageField(upload_to=get_upload_file_name)
album = models.ForeignKey(Album, null=True, blank=True, default = None)

def __unicode__(self):
return self.__class__.__name__

class BackgroundImage(Picture):
pass

class ProfilePicture(Picture):
pass

class Tag(models.Model):
title = models.CharField(max_length=40)
description = models.TextField()

def __unicode__(self):
return self.title

class Question(Asset):
title = models.CharField(max_length=200)
description = models.TextField()
tags = models.ManyToManyField(Tag)

def __unicode__(self):
return self.title

class Answer(Asset):
description = models.TextField()
question = models.ForeignKey(Question)

def __unicode__(self):
return self.description

-- 
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/871d20b8-17a3-4ed4-bb8e-3c0befb5121f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.