Friday, 9 November 2012

Apache/2.2.15 (CentOS) Server forbidden error . not permission to access FOLDER


Forbidden

You don't have permission to access / on this server.

Apache/2.2.15 (CentOS) Server at 1.208.52.12 Port 80
CENT OS 

for changing file permission in CENT OS 

go to ur project directory ... like  /opt/prashant/project_directory/

write command :

chmod -R 755 /app_name 




755  in linux number notation for file permission


Prashant Gaur

Wednesday, 17 October 2012

convert queue into stack and make list work as queue and stack both

now we will see how one can convert QUEUE into STACK into python -- !


from collections import deque

list =[1,2,3,4,5]

queue_list = deque(list)

now queue_list will work as a queue object .... :)
---------------------------------------------------------------
you can extract any element from queue_list by using--

queue_list.popleft()
----------------------------------------this all thing is working as a queue object
now we just need to use a simple method pop() to work queue_list as a stack
-------------------------------------------------------------------------------------------------
queue_list.pop()
u can use also queue_list.popleft()  to work this list as a queue.


Thank You
Meet Me
Prashant Gaur


Monday, 1 October 2012

custom enum field in django to support mysql ENUM datatype :) :)

Hi friends ,

  As we know enum data type is used to reduce memory in database . we can pass string as input and can get output as string ---but in really it will strore in DB as 1 digit number starts from 0  with increase of 1 .
   but django does not provide us default django field so we need to make our own CUSTOM ENUM FIELD . you can go through djnago docs to know about it Django DOCS 

but for enum you just make youe own class



# Class which describe Custom Field of name Enum

class EnumField(models.Field):

    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = 104
        super(EnumField, self).__init__(*args, **kwargs)
        if not self.choices:
            raise AttributeError('EnumField requires `choices` attribute.')

    def db_type(self):
        return "enum(%s)" % ','.join("'%s'" % k for (k, _) in self.choices)


# choices means data in string form to display in mysql and django admin interface

STATE =(('C' , 'C'),
            ('P', 'P),
            ('F, 'F'),
            ('F', 'F'),
            ('R', 'R'),)



# model for orderstate field 


class Table(models.Model):
    state = EnumField(choices=STATE,verbose_name ='orderstate')


now u can make your own enum field and any custom field by just edit some code in custom class
method -- >>  db_type is used for making db data type here it is enum    
and in __init__  --> you can customize your model and field in admin interface



Django Developer 



Monday, 24 September 2012

How to create dump .sql file in Mysql :) :)

First Start your command prompt or Terminal

now rum this command


mysqldump --opt --user=username --password pathofdumpfile

when i do Debug=False in settings.py Django is not able to serve static files of :(


you do nt need to worry about this your  Production server[APACHE ] will handle all static files .

And on your local server u can start your server by using this command
---> manage.py runserver --insecure

this will work




Prashant Gaur
Python Developer