Giter Site home page Giter Site logo

django-randomprimary's People

Contributors

jbrendel avatar vatsalparekh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-randomprimary's Issues

invalid literal for int() with base 10

Django 1.4

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/link/link/add/
Django Version: 1.4
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: 'AGw62'
Exception Location: C:\Python27\lib\site-packages\django\db\models\fields__init__.py in get_prep_value, line 537
Python Version: 2.7.3

I have changed id = models.CharField to id = models.AutoField

To my understanding this is because somewhere a string is passed where only a integer can be passed. In my views I'm using render_to_response, get_object_or_404, RequestContext. Are there any limitations? I have also tried applying RandomPrimaryIdModel instead of models.Model in the Poll class created in the official Django tutorial for Django 1.4 (https://docs.djangoproject.com/en/1.4/intro/tutorial01/) and it raises the same error.

No profanity filter

Just occurred to me - these are going in your urls, and you never know what you might spell at random.

Seriously, leaving out the vowels would probably avoid this issue, with fairly small cost in reducing the key space.

Add blank=true

Hello and thanks for your awesome model. The only issue I found after a considerable amount of debugging was that it behaves slightly differently to an AutoField: AutoFields appear to have blank=True by default, so that they (correctly) are not required to be set in forms. RandomPrimaryIdModel has blank=False, which generates an "xxx is required" error on form submission and prevents automatic key generation. I would suggest changing this section

    id = models.CharField(db_index    = True,
                          primary_key = True,
                          max_length  = CRYPT_KEY_LEN_MAX+1+len(KEYPREFIX)+len(KEYSUFFIX),
                          unique      = True)

to

    id = models.CharField(db_index    = True,
                          primary_key = True,
                          max_length  = CRYPT_KEY_LEN_MAX+1+len(KEYPREFIX)+len(KEYSUFFIX),
                          unique      = True,
                          blank       = True)

This fixed the problem for me. Otherwise it works very smoothly and as expected!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.